From cc4c1a390ce5155195a132669ad1419808b29c5a Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 2 Jan 2019 10:59:36 +0100 Subject: [PATCH] Changes because of changed API of fb_tools --- lib/webhooks/deploy.py | 19 +++++++++++-------- lib/webhooks/r10k.py | 36 +++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 23 deletions(-) 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 -- 2.39.5