fix(webui): /api/status устойчив при недоступном atxctl; WS-баннер в клиента, не в порт

В console-режиме на arm atxctl нет по пути — status больше не падает (power=unknown).
WS: баннер 'console ready' уходит в веб-клиент, а не записывается в serial (не мусорим на экран сервера).
This commit is contained in:
toros
2026-09-08 23:39:26 +05:00
parent 49b6cf89f4
commit 912e0a7b28
+7 -2
View File
@@ -118,7 +118,11 @@ async def api_power_cycle():
@app.get("/api/status") @app.get("/api/status")
async def api_status(): async def api_status():
s = power_mod.status() try:
s = power_mod.status()
except Exception as e:
log.warning("power status unavailable: %s", e)
s = {"power": "unknown", "powered_on": None}
return { return {
"power": s["power"], "power": s["power"],
"powered_on": s["powered_on"], "powered_on": s["powered_on"],
@@ -150,7 +154,8 @@ async def ws_console(ws: WebSocket):
await ws.close() await ws.close()
return return
console.send(("\r\nATXPI console ready. driver=%s\r\n" % DRIVER).encode()) # баннер шлём клиенту (в ws), а НЕ в порт — не пишем на экран сервера.
await ws.send_bytes(("\r\nATXPI console ready. driver=%s\r\n" % DRIVER).encode())
async def reader(): async def reader():
try: try: