From: Frank Brehm Date: Wed, 2 Jan 2019 09:59:36 +0000 (+0100) Subject: Changes because of changed API of fb_tools X-Git-Tag: 1.6.4^2~88 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=cc4c1a390ce5155195a132669ad1419808b29c5a;p=pixelpark%2Fpuppetmaster-webhooks.git Changes because of changed API of fb_tools --- diff --git a/lib/webhooks/deploy.py b/lib/webhooks/deploy.py index 266476c..6d867a0 100644 --- a/lib/webhooks/deploy.py +++ b/lib/webhooks/deploy.py @@ -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) diff --git a/lib/webhooks/r10k.py b/lib/webhooks/r10k.py index 227f5e9..3a59b6a 100644 --- a/lib/webhooks/r10k.py +++ b/lib/webhooks/r10k.py @@ -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