fix(cli): sys.path-Fix für direktes Skript-Aufrufen + Wrapper voice-agent-admin
- cli.py fügt lxc-frontend/ zu sys.path hinzu, sodass `python /pfad/zu/cli.py <cmd>` aus jedem Verzeichnis funktioniert (vorher nur via `python -m app.cli` aus dem App-Verzeichnis) - install.sh legt /usr/local/bin/voice-agent-admin als Wrapper an, damit man einfach `sudo voice-agent-admin list` aufrufen kann
This commit is contained in:
+17
-7
@@ -1,7 +1,11 @@
|
||||
"""CLI-Tool für Notfall-User-Verwaltung.
|
||||
|
||||
Aufruf am LXC:
|
||||
sudo -u deploy /var/www/voice-agent/lxc-frontend/.venv/bin/python -m app.cli <befehl> [...]
|
||||
Aufruf am LXC (von überall, absoluter Pfad):
|
||||
sudo -u deploy /var/www/voice-agent/lxc-frontend/.venv/bin/python \\
|
||||
/var/www/voice-agent/lxc-frontend/app/cli.py <befehl> [...]
|
||||
|
||||
Bequemer ist der Wrapper (vom install.sh angelegt):
|
||||
sudo voice-agent-admin <befehl> [...]
|
||||
|
||||
Befehle:
|
||||
list — alle User auflisten
|
||||
@@ -14,13 +18,19 @@ Befehle:
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from sqlmodel import Session, select
|
||||
# Damit Skript auch ohne `cd` und ohne `-m` läuft: lxc-frontend/ auf sys.path.
|
||||
_LXC_FRONTEND = Path(__file__).resolve().parent.parent
|
||||
if str(_LXC_FRONTEND) not in sys.path:
|
||||
sys.path.insert(0, str(_LXC_FRONTEND))
|
||||
|
||||
from app.core.auth import hash_password, verify_password
|
||||
from app.core.db import engine, init_db
|
||||
from app.core.migrate import run_migrations
|
||||
from app.models.user import User
|
||||
from sqlmodel import Session, select # noqa: E402
|
||||
|
||||
from app.core.auth import hash_password, verify_password # noqa: E402
|
||||
from app.core.db import engine, init_db # noqa: E402
|
||||
from app.core.migrate import run_migrations # noqa: E402
|
||||
from app.models.user import User # noqa: E402
|
||||
|
||||
|
||||
def _setup() -> None:
|
||||
|
||||
Reference in New Issue
Block a user