]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Changes because of changed API of fb_tools
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 2 Jan 2019 09:59:36 +0000 (10:59 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 2 Jan 2019 09:59:36 +0000 (10:59 +0100)
lib/webhooks/deploy.py
lib/webhooks/r10k.py

index 266476cddbdd14c6889a5cfc4a6c892b41f562f9..6d867a09bee6bcd13c95ce24737f3084e8ead344 100644 (file)
@@ -235,20 +235,23 @@ class WebhookDeployApp(BaseHookApp):
                 if branch:
                     cmd += ['-b', branch]
 
-            (ret_val, stdoutdata, stderrdata) = self.handler.call(cmd, sudo=self.do_sudo)
+            proc = self.handler.call(cmd, sudo=self.do_sudo)
 
-            if stdoutdata:
-                msg = _("Output:") + "\n{}".format(to_str(stdoutdata))
+            if proc.stdout:
+                msg = _("Output:") + "\n{}".format(proc.stdout)
                 self.print_out(msg)
             else:
                 LOG.debug("No output.")
 
-            if stderrdata:
-                cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd))
-                msg = _("Error messages on {c!r}:\n{e}").format(c=cmd_str, e=to_str(stderrdata))
-                if ret_val:
-                    self.error_data.append(msg)
+            if proc.stderr:
+                cmd_str = ' '.join(map(lambda x: pipes.quote(x), proc.args))
+                msg = _("Error messages on {c!r}:\n{e}").format(c=cmd_str, e=proc.stderr)
+                msg_rc = _("Returncode was {}.").format(proc.returncode)
                 self.print_out(msg)
+                if proc.returncode:
+                    self.print_out(msg_rc)
+                    self.error_data.append(msg)
+                    self.error_data.append(msg_rc)
 
         finally:
             os.chdir(cur_dir)
index 227f5e94fe1c25e64a3612bdccc12b801ce90268..3a59b6a68c3858c165b3cd90f24c3aabae52319e 100644 (file)
@@ -302,21 +302,24 @@ class R10kHookApp(BaseHookApp):
         if self.verbose > 3:
             cmd.append('--debug')
 
-        (ret_val, stdoutdata, stderrdata) = self.handler.call(cmd, sudo=self.do_sudo)
+        proc = self.handler.call(cmd, sudo=self.do_sudo)
 
-        if stdoutdata:
-            msg = "Output:\n{}".format(to_str(stdoutdata))
+        if proc.stdout:
+            msg = "Output:\n{}".format(proc.stdout)
             self.print_out(msg)
         else:
             LOG.debug("No output.")
 
-        if stderrdata:
-            cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd))
-            msg = "Error messages on '{c}':\n{e}".format(c=cmd_str, e=to_str(stderrdata))
-            if ret_val:
+        if proc.stderr:
+            cmd_str = ' '.join(map(lambda x: pipes.quote(x), proc.args))
+            msg = "Error messages on '{c}':\n{e}".format(c=cmd_str, e=proc.stderr)
+            msg_rc = "Returncode was {}.".format(proc.returncode)
+            self.print_out(msg)
+            if proc.returncode:
+                self.print_out(msg_rc)
                 self.error_data.append(msg)
+                self.error_data.append(msg_rc)
                 res = False
-            self.print_out(msg)
 
         return res
 
@@ -342,21 +345,24 @@ class R10kHookApp(BaseHookApp):
             self.ref, '--puppetfile', '--verbose', r10k_loglevel
         ]
 
-        (ret_val, stdoutdata, stderrdata) = self.handler.call(cmd, sudo=self.do_sudo)
+        proc = self.handler.call(cmd, sudo=self.do_sudo)
 
-        if stdoutdata:
-            msg = "Output:\n{}".format(to_str(stdoutdata))
+        if proc.stdout:
+            msg = "Output:\n{}".format(proc.stdout)
             self.print_out(msg)
         else:
             LOG.debug("No output.")
 
         if stderrdata:
-            cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd))
-            msg = "Error messages on '{c}':\n{e}".format(c=cmd_str, e=to_str(stderrdata))
-            if ret_val:
+            cmd_str = ' '.join(map(lambda x: pipes.quote(x), proc.args))
+            msg = "Error messages on '{c}':\n{e}".format(c=cmd_str, e=proc.stderr)
+            msg_rc = "Returncode was {}.".format(proc.returncode)
+            self.print_out(msg)
+            if proc.returncode:
+                self.print_out(msg_rc)
                 self.error_data.append(msg)
+                self.error_data.append(msg_rc)
                 res = False
-            self.print_out(msg)
 
         return res