]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Bugfixing
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 26 Feb 2019 16:57:41 +0000 (17:57 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 26 Feb 2019 16:57:41 +0000 (17:57 +0100)
get-forge-modules
lib/webhooks/forge_module_info.py
lib/webhooks/get_forge_modules.py

index f6d7f861ccd6821165ff69e4a2df62caa3f5cfd3..4c9c0b90ede3647b444c909cb694aba8f70914ec 100755 (executable)
@@ -23,7 +23,7 @@ LOG = logging.getLogger(MY_APPNAME)
 
 app = GetForgeModulesApp(appname=MY_APPNAME, base_dir=base_dir)
 
-if app.verbose > 2:
+if app.verbose > 1:
     LOG.debug("{c} object:\n{o}".format(c=app.__class__.__name__, o=app))
 
 app()
index f3c9e6facb316a14e266272208b3514d635eadbd..2a3c9e765aac7a3fd0f2484376208d6245940acf 100644 (file)
@@ -31,7 +31,7 @@ from .base_module_info import BaseModuleInfoError, BaseModuleInfo
 
 from .module_meta_info import ModuleMetadata
 
-__version__ = '0.6.3'
+__version__ = '0.6.4'
 
 LOG = logging.getLogger(__name__)
 
@@ -1477,6 +1477,10 @@ class ForgeModuleInfo(BaseModuleInfo):
         if value is None:
             self._superseded_by = None
             return
+        if isinstance(value, collections.Mapping):
+            self._superseded_by = copy.copy(value)
+            return
+
         v = str(value).strip()
         if value == '':
             self._superseded_by = None
@@ -1678,9 +1682,14 @@ class ForgeModuleInfo(BaseModuleInfo):
                 js_info['owner'], appname=appname, verbose=verbose, base_dir=base_dir)
 
         if module_info.superseded_by:
+            subst = module_info.superseded_by
+            if verbose > 2:
+                LOG.debug("Superseded info:\n" + pp(subst))
+            if 'slug' in subst:
+                subst = subst['slug']
             LOG.warning(_(
                 "Module {c!r} is deprecated at Puppet forge and should be substituted "
-                "by module {n!r}.").format(c=module_info.slug, n=module_info.superseded_by))
+                "by module {n!r}.").format(c=module_info.slug, n=subst))
 
         return module_info
 
@@ -1695,14 +1704,14 @@ class ForgeModuleInfo(BaseModuleInfo):
 
         if 'slug' not in data:
             msg = _("Did not found {!r}-definition in data for forge module:").format(
-                'slug') + '\n' + pp(data))
+                'slug') + '\n' + pp(data)
             LOG.error(msg)
             return None
 
         full_name = data['slug'].strip()
         if full_name == '':
             msg = _("Found empty {!r}-definition in data for forge module:").format(
-                'slug') + '\n' + pp(data))
+                'slug') + '\n' + pp(data)
             LOG.error(msg)
             return None
 
index f14c2fa6c152da5dd5b373361628f6877b0c927c..09e8bc76fe2b53a6adc7ff18a63da2d946e8612f 100644 (file)
@@ -84,8 +84,6 @@ class GetForgeModulesApp(BaseHookApp):
         self.http_timeout = self.default_http_timeout
         self.modules = None
         self._do_forge = True
-        self.forge_modules = None
-        self.env_modules = None
 
         description = _(
             "Collects information about all used Puppet Modules from {url!r} "
@@ -239,18 +237,17 @@ class GetForgeModulesApp(BaseHookApp):
         LOG.info(msg)
         self.print_out(msg)
         modules_done = []
+        self.forge_modules = []
 
-        i = 0
         for env in self.environments:
 
             for full_name in self.env_modules[env].keys():
                 if full_name in modules_done:
                     continue
-                self.get_forge_module_info(full_name)
+                module_info = self.get_forge_module_info(full_name)
+                if module_info:
+                    self.forge_modules.append(module_info)
                 modules_done.append(full_name)
-                i += 1
-                if i >= 3:
-                    break
             if not self.verbose:
                 if self.modules[full_name].forge_avail:
                     print('.', end='', flush=True)
@@ -267,22 +264,14 @@ class GetForgeModulesApp(BaseHookApp):
             appname=self.appname, verbose=self.verbose, base_dir=self.base_dir, )
 
         if module_info:
-            if self.verbose > 2:
+            if self.verbose > 3:
                 LOG.debug(_("Got module info from Forge:") + '\n' + pp(module_info.as_dict()))
+            else:
+                LOG.debug(_("Got module info from Forge for module {!r}.").format(full_name))
         else:
-            LOG.warn(_("Got no module info for {!r} from Forge.").format(full_name))
-
-#        module_info = self.modules[full_name]
-#
-#        module_info_forge = ModuleInfo.get_from_forge(
-#            full_name, forge_uri=self.forge_uri, http_timeout=self.http_timeout,
-#            appname=self.appname, verbose=self.verbose, base_dir=self.base_dir, )
-#
-#        if module_info_forge:
-#            module_info.merge_in(module_info_forge)
-#        else:
-#            module_info.set_ts_checked()
-#            module_info.forge_avail = False
+            LOG.info(_("Got no module info for {!r} from Forge.").format(full_name))
+
+        return module_info
 
     # -------------------------------------------------------------------------
     def read_metadata_files(self, env):