add python3.6

This commit is contained in:
2026-07-14 15:17:46 +08:00
parent e022c6829e
commit 3ef5926f75
+19 -2
View File
@@ -110,18 +110,35 @@ def inject_globals():
# ════════════════════════════════════════════════════════════════════ # ════════════════════════════════════════════════════════════════════
# BIND helpers # 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): def run_cmd(cmd, timeout=10):
"""Run shell command, return (returncode, stdout, stderr).""" """Run shell command, return (returncode, stdout, stderr)."""
try: 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() return r.returncode, r.stdout.strip(), r.stderr.strip()
except subprocess.TimeoutExpired: except subprocess.TimeoutExpired:
return -1, "", "Command timed out" return -1, "", "Command timed out"
except Exception as e: except Exception as e:
return -1, "", str(e) return -1, "", str(e)
def bind_service_status(): def bind_service_status():
rc, out, _ = run_cmd("systemctl is-active named 2>&1") rc, out, _ = run_cmd("systemctl is-active named 2>&1")
enabled_rc, _, _ = run_cmd("systemctl is-enabled named 2>&1") enabled_rc, _, _ = run_cmd("systemctl is-enabled named 2>&1")