]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Simplyfication of class PpDeployZonesApp
authorFrank Brehm <frank@brehm-online.com>
Tue, 7 Dec 2021 15:07:23 +0000 (16:07 +0100)
committerFrank Brehm <frank@brehm-online.com>
Tue, 7 Dec 2021 15:07:23 +0000 (16:07 +0100)
lib/pp_admintools/deploy_zones_from_pdns.py

index 3fb732db4172a24182612b5363782221eb0ff3b9..1495f4e964d6888433f74bb4089a88ac3904652a 100644 (file)
@@ -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):