From: Frank Brehm Date: Thu, 14 Mar 2019 15:50:03 +0000 (+0100) Subject: Changing logging, moving method read_puppetfile() from lib/webhooks/get_forge_modules... X-Git-Tag: 1.6.4^2~32 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=119ac5dee1de4f4e6aa1cae4c2b9233c0e70c9b4;p=pixelpark%2Fpuppetmaster-webhooks.git Changing logging, moving method read_puppetfile() from lib/webhooks/get_forge_modules.py to lib/webhooks/base_app.py --- diff --git a/lib/webhooks/base_app.py b/lib/webhooks/base_app.py index c96b49f..299edb7 100644 --- a/lib/webhooks/base_app.py +++ b/lib/webhooks/base_app.py @@ -46,6 +46,8 @@ from .module_info import ModuleInfo from .module_list import ModuleInfoDict +from .puppetfile import Puppetfile + from .xlate import __module_dir__ as __xlate_module_dir__ from .xlate import __base_dir__ as __xlate_base_dir__ from .xlate import __mo_file__ as __xlate_mo_file__ @@ -805,6 +807,15 @@ class BaseHookApp(BaseApplication): root_log.addHandler(lh_console) + if self.verbose < 3: + paramiko_logger = logging.getLogger('paramiko.transport') + charsetprober_logger = logging.getLogger('chardet.charsetprober') + charsetprober_logger.setLevel(logging.INFO) + if self.verbose < 1: + paramiko_logger.setLevel(logging.WARNING) + else: + paramiko_logger.setLevel(logging.INFO) + return # ------------------------------------------------------------------------- @@ -1179,6 +1190,31 @@ class BaseHookApp(BaseApplication): return + # ------------------------------------------------------------------------- + def read_puppetfile(self, env): + + LOG.info(_("Reading Puppetfile of environment {!r} ...").format(env)) + + pfile = Puppetfile( + env_root_dir=self.puppet_root_env_dir, environment=env, + appname=self.appname, verbose=self.verbose, base_dir=self.base_dir, + initialized=True) + + if self.verbose > 1: + LOG.debug("Got Puppetfile:\n{}".format(pp(pfile.as_dict()))) + + pfile_modules = None + try: + pfile_modules = pfile.read_modules() + except PuppetfileError as e: + LOG.warn(str(e)) + else: + if self.verbose > 2: + LOG.debug("Successful read {!r}.".format(pfile.filename)) + if pfile_modules: + for module_info in pfile_modules.values(): + self.env_modules[env].append(module_info) + # ------------------------------------------------------------------------- def read_cache_file(self, only_main_branches=True): diff --git a/lib/webhooks/get_forge_modules.py b/lib/webhooks/get_forge_modules.py index 8693795..e4f28ed 100644 --- a/lib/webhooks/get_forge_modules.py +++ b/lib/webhooks/get_forge_modules.py @@ -231,7 +231,10 @@ class GetForgeModulesApp(BaseHookApp): for env in self.environments: LOG.debug("Evaluating environment {!r} ..".format(env)) - self.read_puppetfile(env) + pfile_modules = self.read_puppetfile(env) + if pfile_modules: + for module_info in pfile_modules.values(): + self.env_modules[env].append(module_info) self.read_metadata_files(env) if self.verbose > 2: LOG.debug("ModuleInfoDict:\n{}".format(pp(self.env_modules[env].as_dict()))) @@ -353,31 +356,6 @@ class GetForgeModulesApp(BaseHookApp): return ModuleInfo.init_from_json( json_data, env, appname=self.appname, verbose=self.verbose, base_dir=self.base_dir) - # ------------------------------------------------------------------------- - def read_puppetfile(self, env): - - LOG.info(_("Reading Puppetfile of environment {!r} ...").format(env)) - - pfile = Puppetfile( - env_root_dir=self.puppet_root_env_dir, environment=env, - appname=self.appname, verbose=self.verbose, base_dir=self.base_dir, - initialized=True) - - if self.verbose > 1: - LOG.debug("Got Puppetfile:\n{}".format(pp(pfile.as_dict()))) - - pfile_modules = None - try: - pfile_modules = pfile.read_modules() - except PuppetfileError as e: - LOG.warn(str(e)) - else: - if self.verbose > 2: - LOG.debug("Successful read {!r}.".format(pfile.filename)) - if pfile_modules: - for module_info in pfile_modules.values(): - self.env_modules[env].append(module_info) - # ------------------------------------------------------------------------- def init_puppet_environments(self):