From 3ef5926f75c6959698d3b7343071db56052e4a37 Mon Sep 17 00:00:00 2001 From: cnbugs <717192502@qq.com> Date: Tue, 14 Jul 2026 15:17:46 +0800 Subject: [PATCH] add python3.6 --- app.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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")