From: Frank Brehm Date: Tue, 7 Dec 2021 15:07:23 +0000 (+0100) Subject: Simplyfication of class PpDeployZonesApp X-Git-Tag: 0.4.1~5^2~6 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=61a438e8761b56050dab2f9a25198ef64176d059;p=pixelpark%2Fpp-admin-tools.git Simplyfication of class PpDeployZonesApp --- diff --git a/lib/pp_admintools/deploy_zones_from_pdns.py b/lib/pp_admintools/deploy_zones_from_pdns.py index 3fb732d..1495f4e 100644 --- a/lib/pp_admintools/deploy_zones_from_pdns.py +++ b/lib/pp_admintools/deploy_zones_from_pdns.py @@ -739,34 +739,44 @@ class PpDeployZonesApp(PpPDNSApplication): LOG.info(_("Checking syntax correctness of named.conf ...")) cmd = shlex.split(str(self.cmd_checkconf)) - if 'named-checkconf' in self.cmd_checkconf and self.verbose > 2: + if self.verbose > 2: cmd.append('-p') cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd)) LOG.debug(_("Executing: {}").format(cmd_str)) - std_out = None - std_err = None - ret_val = None - - with Popen(cmd, stdout=PIPE, stderr=PIPE) as proc: - try: - std_out, std_err = proc.communicate(timeout=10) - except TimeoutExpired: - proc.kill() - std_out, std_err = proc.communicate() - ret_val = proc.wait() + result = super(BaseApplication, self).run( + cmd, stdout=PIPE, stderr=PIPE, timeout=10, check=False, may_simulate=False) - LOG.debug(_("Return value: {!r}").format(ret_val)) - if std_out and std_out.strip(): - LOG.warn(_("Output on {}").format('STDOUT') + ' ' + to_str(std_out.strip())) - if std_err and std_err.strip(): - LOG.warn(_("Output on {}").format('STDERR') + ' ' + to_str(std_err.strip())) + if self.verbose > 2: + LOG.debug(_("Result:") + '\n' + str(result)) - if ret_val: + if result.returncode: return False - return True +# std_out = None +# std_err = None +# ret_val = None + +# with Popen(cmd, stdout=PIPE, stderr=PIPE) as proc: +# try: +# std_out, std_err = proc.communicate(timeout=10) +# except TimeoutExpired: +# proc.kill() +# std_out, std_err = proc.communicate() +# ret_val = proc.wait() + +# LOG.debug(_("Return value: {!r}").format(ret_val)) +# if std_out and std_out.strip(): +# LOG.warn(_("Output on {}").format('STDOUT') + ' ' + to_str(std_out.strip())) +# if std_err and std_err.strip(): +# LOG.warn(_("Output on {}").format('STDERR') + ' ' + to_str(std_err.strip())) + +# if ret_val: +# return False + +# return True + # ------------------------------------------------------------------------- def apply_config(self):