mirror of
https://github.com/andrey271192/WARP-Web-UI-Relay-Beta.git
synced 2026-09-20 11:55:35 +00:00
fix: handle missing system commands
This commit is contained in:
5
app.py
5
app.py
@@ -84,6 +84,11 @@ def run_cmd(cmd, timeout=120):
|
|||||||
start = time.time()
|
start = time.time()
|
||||||
try:
|
try:
|
||||||
proc = subprocess.run(cmd, shell=False, capture_output=True, text=True, timeout=timeout)
|
proc = subprocess.run(cmd, shell=False, capture_output=True, text=True, timeout=timeout)
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
dur_ms = int((time.time() - start) * 1000)
|
||||||
|
msg = f"command not found: {e.filename or cmd[0]}"
|
||||||
|
log_event("error", "command_not_found", cmd=cmd, duration_ms=dur_ms, stderr=msg)
|
||||||
|
return 127, "", msg
|
||||||
except subprocess.TimeoutExpired as e:
|
except subprocess.TimeoutExpired as e:
|
||||||
dur_ms = int((time.time() - start) * 1000)
|
dur_ms = int((time.time() - start) * 1000)
|
||||||
log_event("error", "command_timeout", cmd=cmd, duration_ms=dur_ms)
|
log_event("error", "command_timeout", cmd=cmd, duration_ms=dur_ms)
|
||||||
|
|||||||
Reference in New Issue
Block a user