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:
+1
-9
@@ -1,4 +1,3 @@
|
||||
import subprocess
|
||||
from app_images import init_images_router
|
||||
from app_files import init_files_router
|
||||
from app_pods import init_pods_router
|
||||
@@ -9,6 +8,7 @@ from fastapi import FastAPI
|
||||
import requests_unixsocket
|
||||
from common import (
|
||||
_systemctl as _common_systemctl,
|
||||
run,
|
||||
)
|
||||
import uvicorn
|
||||
|
||||
@@ -44,13 +44,5 @@ app.include_router(init_pods_router(
|
||||
app.include_router(init_system_router(SESSION, PODMAN_API_BASE, WORKLOADS_DIR))
|
||||
|
||||
|
||||
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)
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run(app, host="0.0.0.0", port=8000)
|
||||
|
||||
Reference in New Issue
Block a user