From: Frank Brehm Date: Mon, 20 Aug 2018 13:11:25 +0000 (+0200) Subject: Changin lib/webhooks/r10k.py to use method call() from base handler class X-Git-Tag: 0.8.4^2~2 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=71e94e4d210a3ff277884d6aaffa796e5091934f;p=pixelpark%2Fpuppetmaster-webhooks.git Changin lib/webhooks/r10k.py to use method call() from base handler class --- diff --git a/lib/webhooks/__init__.py b/lib/webhooks/__init__.py index b65ba7f..77e89e3 100644 --- a/lib/webhooks/__init__.py +++ b/lib/webhooks/__init__.py @@ -1,6 +1,6 @@ #!/bin/env python3 # -*- coding: utf-8 -*- -__version__ = '0.8.2' +__version__ = '0.8.3' # vim: ts=4 et list diff --git a/lib/webhooks/base_app.py b/lib/webhooks/base_app.py index 7c8cc2b..6e1c541 100644 --- a/lib/webhooks/base_app.py +++ b/lib/webhooks/base_app.py @@ -128,7 +128,8 @@ class BaseHookApp(BaseObject): self.search_curl_bin() self.handler = BaseHandler( - appname=self.appname, verbose=self.verbose, base_dir=self.base_dir) + appname=self.appname, verbose=self.verbose, base_dir=self.base_dir, + simulate=self.simulate) return diff --git a/lib/webhooks/handler.py b/lib/webhooks/handler.py index b9046f1..8ec2cbd 100644 --- a/lib/webhooks/handler.py +++ b/lib/webhooks/handler.py @@ -363,6 +363,7 @@ class BaseHandler(BaseObject): if sudo is None: sudo = self.sudo if sudo: + cmd_list.insert(0, '-n') cmd_list.insert(0, self.sudo_cmd) if simulate is None: diff --git a/lib/webhooks/r10k.py b/lib/webhooks/r10k.py index 8f3d486..ded2df5 100644 --- a/lib/webhooks/r10k.py +++ b/lib/webhooks/r10k.py @@ -270,29 +270,12 @@ class R10kHookApp(BaseHookApp): elif self.verbose > 1: r10k_loglevel = 'debug' - cmd = [] - if self.do_sudo: - cmd = ['sudo', '-n'] - - cmd += [ + cmd = [ self.r10k_bin, 'deploy', 'environment', self.ref, '--puppetfile', '--verbose', r10k_loglevel ] - cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd)) - if self.verbose > 2: - LOG.debug("Cmd: {}".format(pp(cmd))) - LOG.info("Executing: {}".format(cmd_str)) - - if self.simulate: - LOG.warn("Simulation mode, don't executing {!r}.".format(self.r10k_bin)) - time.sleep(3) - return res - - LOG.debug("Really executing ...") - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stdoutdata, stderrdata) = proc.communicate() - ret_val = proc.wait() + (ret_val, stdoutdata, stderrdata) = self.handler.call(cmd, sudo=self.do_sudo) LOG.debug("Return value: {}".format(ret_val)) if stdoutdata: