feat(printer): badge print queue, Pi worker, captive-portal setup, admin printing view
- migration 20261018170000: pgmq badge_print/badge_print_dlq, print_stations, token-gated printer RPCs (claim/complete/fail/heartbeat), admin RPCs, welcome_checkin enqueue; badge_print_tests.sql (101 assertions) - apps/printer: Python worker (Playwright render -> brother_ql via pyusb), comitup captive-portal (Wi-Fi + HTTPS endpoint + anon key + token), arm64 image build + idempotent Pi setup/install scripts, 77 pytest - apps/admin: Printing view, station management/DLQ, global printer status pill, Print button on Registrations, standalone print renderer entry (print.html -> dist-print) with bundled fonts - docs: printing.md + architecture/schema/rpcs/tests/admin-app updates, apps/printer/AGENT.md operating manual - e2e: printing.spec.ts
This commit is contained in:
1 parent
04f3f55b78
commit
c980effddc
55 files changed
+7406
-29
No files matched your search
@@ -0,0 +1,39 @@
|
||||
"""Read the comitup network state file written by the host."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import socket
|
||||
from pathlib import Path
|
||||
|
||||
UNKNOWN = {"state": "UNKNOWN", "ssid": None, "ip": None}
|
||||
|
||||
|
||||
def _detect_ip() -> str | None:
|
||||
# UDP connect trick: picks the source address of the default route, no traffic sent.
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
try:
|
||||
sock.connect(("8.8.8.8", 53))
|
||||
return str(sock.getsockname()[0])
|
||||
except OSError:
|
||||
return None
|
||||
finally:
|
||||
sock.close()
|
||||
|
||||
|
||||
def read_network(path: str) -> dict:
|
||||
try:
|
||||
raw = json.loads(Path(path).read_text())
|
||||
except (OSError, ValueError):
|
||||
result = dict(UNKNOWN)
|
||||
result["ip"] = _detect_ip()
|
||||
return result
|
||||
if not isinstance(raw, dict):
|
||||
result = dict(UNKNOWN)
|
||||
result["ip"] = _detect_ip()
|
||||
return result
|
||||
return {
|
||||
"state": str(raw.get("state") or "UNKNOWN"),
|
||||
"ssid": raw.get("ssid") or None,
|
||||
"ip": raw.get("ip") or None,
|
||||
"updated_at": raw.get("updated_at"),
|
||||
}
|
||||
Reference in new issue
Block a user