refactor: verplaats run() duplicaat naar common.py
run() stond identiek in app.py en app_system.py. Verplaatst naar common.py als single source of truth; beide modules importeren nu de centrale versie. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ from fastapi import APIRouter, HTTPException
|
||||
from common import (
|
||||
_podman_get_json as _common_podman_get_json,
|
||||
_systemctl as _common_systemctl,
|
||||
run,
|
||||
)
|
||||
|
||||
|
||||
@@ -68,14 +69,6 @@ def init_system_router(session, podman_api_base: str, workloads_dir: str) -> API
|
||||
"api_raw_sample": api_containers[0] if isinstance(api_containers, list) and api_containers else api_containers,
|
||||
}
|
||||
|
||||
def run(cmd):
|
||||
try:
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, check=False)
|
||||
output = (result.stdout or "") + (result.stderr or "")
|
||||
return result.returncode, output.strip()
|
||||
except Exception as e:
|
||||
return 1, str(e)
|
||||
|
||||
def _systemctl(cmd):
|
||||
return _common_systemctl(cmd, run)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user