Run a shell command and return (returncode, stdout, stderr)
(cmd, timeout=10)
| 123 | return isinstance(value, str) and bool(_FW_IFACE_RE.match(value)) |
| 124 | |
| 125 | def _run_cmd(cmd, timeout=10): |
| 126 | """Run a shell command and return (returncode, stdout, stderr)""" |
| 127 | try: |
| 128 | result = subprocess.run( |
| 129 | cmd, capture_output=True, text=True, timeout=timeout |
| 130 | ) |
| 131 | return result.returncode, result.stdout.strip(), result.stderr.strip() |
| 132 | except subprocess.TimeoutExpired: |
| 133 | return -1, "", "Command timed out" |
| 134 | except FileNotFoundError: |
| 135 | return -1, "", f"Command not found: {cmd[0]}" |
| 136 | except Exception as e: |
| 137 | return -1, "", str(e) |
| 138 | |
| 139 | |
| 140 | def get_firewall_status(): |
no outgoing calls
no test coverage detected