update
This commit is contained in:
@@ -11,6 +11,7 @@ import json
|
||||
import uuid
|
||||
import platform
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox
|
||||
from pathlib import Path
|
||||
@@ -51,7 +52,7 @@ def _status_icon(ok, warn=False):
|
||||
return "\u2717", _ERR
|
||||
|
||||
|
||||
def collect_status() -> list[dict]:
|
||||
def collect_status(parent_app=None) -> list[dict]:
|
||||
"""Sammelt alle Statuspunkte. Gibt Liste von dicts mit name, value, ok, detail."""
|
||||
checks = []
|
||||
|
||||
@@ -345,6 +346,75 @@ def collect_status() -> list[dict]:
|
||||
"detail": "Firewall-Status konnte nicht vollstaendig geprueft werden",
|
||||
})
|
||||
|
||||
if parent_app is not None and hasattr(parent_app, "get_practice_id"):
|
||||
try:
|
||||
pid_snap = (parent_app.get_practice_id() or "").strip()
|
||||
if not pid_snap:
|
||||
checks.append({
|
||||
"name": "Hetzner Profil-Snapshot",
|
||||
"value": "practice_id fehlt",
|
||||
"ok": False,
|
||||
"detail": "Keine fuehrende Praxis-ID im lokalen Profil.",
|
||||
})
|
||||
else:
|
||||
bu = parent_app.get_backend_url().rstrip("/")
|
||||
tok = parent_app.get_backend_token()
|
||||
uid_snap = (parent_app._user_profile.get("empfang_user_id") or "").strip()
|
||||
req = urllib.request.Request(
|
||||
f"{bu}/empfang/practice/profile",
|
||||
method="GET",
|
||||
)
|
||||
req.add_header("X-API-Token", tok)
|
||||
req.add_header("X-Practice-Id", pid_snap)
|
||||
if uid_snap:
|
||||
req.add_header("X-AzA-Empfang-User-Id", uid_snap)
|
||||
resp = urllib.request.urlopen(req, timeout=12)
|
||||
body = json.loads(resp.read().decode("utf-8"))
|
||||
pr = body.get("practice") or {}
|
||||
us = body.get("user") if isinstance(body.get("user"), dict) else {}
|
||||
lcm = body.get("license_customer_email") or ""
|
||||
warns = body.get("warnings") or []
|
||||
lines = [
|
||||
f"Praxisname: {pr.get('name') or '—'}",
|
||||
f"Praxis-Fachrichtung: {pr.get('specialty') or '—'}",
|
||||
f"Lizenz-E-Mail: {lcm or '—'}",
|
||||
f"Admin-E-Mail: {pr.get('admin_email') or '—'}",
|
||||
f"Kontakt-E-Mail (Profil): {pr.get('contact_email') or '—'}",
|
||||
]
|
||||
if us:
|
||||
lines.append(
|
||||
"Benutzer: "
|
||||
f"{us.get('display_name') or '—'} | "
|
||||
f"Titel: {us.get('title') or '—'} | "
|
||||
f"Fach: {us.get('specialty_user') or '—'} | "
|
||||
f"E-Mail: {us.get('email') or '—'}",
|
||||
)
|
||||
warn_txt = ""
|
||||
if isinstance(warns, list) and warns:
|
||||
warn_txt = "Warnungen: " + "; ".join(str(w) for w in warns[:10])
|
||||
snap_ok = not bool(warns)
|
||||
checks.append({
|
||||
"name": "Hetzner Profil-Snapshot (Lesen)",
|
||||
"value": "abgerufen — siehe Detail",
|
||||
"ok": snap_ok,
|
||||
"warn": not snap_ok,
|
||||
"detail": "\n".join(lines) + (f"\n{warn_txt}" if warn_txt else ""),
|
||||
})
|
||||
except urllib.error.HTTPError as exc_http:
|
||||
checks.append({
|
||||
"name": "Hetzner Profil-Snapshot",
|
||||
"value": f"HTTP {exc_http.code}",
|
||||
"ok": False,
|
||||
"detail": (exc_http.read() or b"").decode("utf-8", errors="ignore")[:240],
|
||||
})
|
||||
except Exception as exc:
|
||||
checks.append({
|
||||
"name": "Hetzner Profil-Snapshot",
|
||||
"value": "Abruf fehlgeschlagen",
|
||||
"ok": False,
|
||||
"detail": str(exc)[:240],
|
||||
})
|
||||
|
||||
return checks
|
||||
|
||||
|
||||
@@ -431,7 +501,7 @@ def show_systemstatus(parent):
|
||||
).pack(side="left", fill="x", expand=True)
|
||||
|
||||
def _run_checks():
|
||||
checks = collect_status()
|
||||
checks = collect_status(parent)
|
||||
status_data[0] = checks
|
||||
_populate(checks)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user