]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Changing logging, moving method read_puppetfile() from lib/webhooks/get_forge_modules...
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 14 Mar 2019 15:50:03 +0000 (16:50 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 14 Mar 2019 15:50:03 +0000 (16:50 +0100)
lib/webhooks/base_app.py
lib/webhooks/get_forge_modules.py

index c96b49f7d1b84ab0ebfd712cd9c3b409a71b1a6d..299edb7a0bf513ea753c54efaaf3e2d5ee500b0f 100644 (file)
@@ -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):
 
index 869379596828f63cd44bc7eebeecac93750a17ed..e4f28ed9ca8b75cae06a5f231c0370ca209a0d72 100644 (file)
@@ -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):