diff --git a/app.py b/app.py index 86d628a..d31ed40 100644 --- a/app.py +++ b/app.py @@ -110,18 +110,35 @@ def inject_globals(): # ════════════════════════════════════════════════════════════════════ # BIND helpers # ════════════════════════════════════════════════════════════════════ +# python3.7 +#def run_cmd(cmd, timeout=10): +# """Run shell command, return (returncode, stdout, stderr).""" +# try: +# r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout) +# return r.returncode, r.stdout.strip(), r.stderr.strip() +# except subprocess.TimeoutExpired: +# return -1, "", "Command timed out" +# except Exception as e: +# return -1, "", str(e) +# python3.6 def run_cmd(cmd, timeout=10): """Run shell command, return (returncode, stdout, stderr).""" try: - r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout) + r = subprocess.run( + cmd, + shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + universal_newlines=True, + timeout=timeout + ) return r.returncode, r.stdout.strip(), r.stderr.strip() except subprocess.TimeoutExpired: return -1, "", "Command timed out" except Exception as e: return -1, "", str(e) - def bind_service_status(): rc, out, _ = run_cmd("systemctl is-active named 2>&1") enabled_rc, _, _ = run_cmd("systemctl is-enabled named 2>&1")