From baf82080ca8807b1feafc4d3fd5aad783a152b37 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 26 Feb 2019 17:57:41 +0100 Subject: [PATCH] Bugfixing --- get-forge-modules | 2 +- lib/webhooks/forge_module_info.py | 17 +++++++++++++---- lib/webhooks/get_forge_modules.py | 31 ++++++++++--------------------- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/get-forge-modules b/get-forge-modules index f6d7f86..4c9c0b9 100755 --- a/get-forge-modules +++ b/get-forge-modules @@ -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() diff --git a/lib/webhooks/forge_module_info.py b/lib/webhooks/forge_module_info.py index f3c9e6f..2a3c9e7 100644 --- a/lib/webhooks/forge_module_info.py +++ b/lib/webhooks/forge_module_info.py @@ -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 diff --git a/lib/webhooks/get_forge_modules.py b/lib/webhooks/get_forge_modules.py index f14c2fa..09e8bc7 100644 --- a/lib/webhooks/get_forge_modules.py +++ b/lib/webhooks/get_forge_modules.py @@ -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): -- 2.39.5