NA's page keys name the other locations with a problem in a blue band; PROP OUT reads Chronicles
- campuses.remote_summary -> custom variable sp_remote; band flashes until acknowledged there, steady after, "SC?" when silent
- nav_locations_band (NA only); red stays for NA's own problems
- PROP OUT: /Volumes/Location Assets/{date} on NA ProP (Chronicles share)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+26
-1
@@ -104,6 +104,7 @@ def http_json(url, body=None, timeout=3):
|
||||
# --- the pages (the hub only) -----------------------------------------------------------
|
||||
|
||||
VIEW = {"state": "sp_state_view", "heartbeat": "sp_hb_view"}
|
||||
REMOTE = make_page.REMOTE_VAR # which other locations have a problem: the blue band on NA's page-number keys
|
||||
SELECT = "sp_view"
|
||||
VIEW_CMD = "sp_view_cmd" # a tap or hold on the LOCATION page, passed on to that location's own watchdog
|
||||
MODE = "sp_view_mode" # "" = that location's status page, "RESTART" = its Restart page
|
||||
@@ -205,7 +206,7 @@ def ensure_variables(cfg, ids):
|
||||
from settings import campus
|
||||
have, _ = campus.companion_state(cfg)
|
||||
want = [n for cid in ids for n in ("sp_state_" + cid, "sp_hb_" + cid) if n not in have]
|
||||
want += [n for n in (VIEW["state"], VIEW["heartbeat"], SELECT, VIEW_CMD, MODE) if n not in have]
|
||||
want += [n for n in (VIEW["state"], VIEW["heartbeat"], SELECT, VIEW_CMD, MODE, REMOTE) if n not in have]
|
||||
if not want:
|
||||
return
|
||||
comp = cfg.get("companion") or {}
|
||||
@@ -385,6 +386,8 @@ class Mirror:
|
||||
threads.append(t)
|
||||
for t in threads:
|
||||
t.join(2)
|
||||
if (data.get("pages") or {}).get("overview"):
|
||||
self.site.comp.set_custom(REMOTE, json.dumps(remote_summary(others, self.remote, time.time()), separators=(",", ":")))
|
||||
# The LOCATION page shows the tapped location: its keys moved onto their cells.
|
||||
pick = (self.site.comp.get_custom(SELECT) or "").strip().lower() # held as "WS": the back key shows it
|
||||
if pick not in others and others:
|
||||
@@ -404,6 +407,28 @@ class Mirror:
|
||||
self.site.comp.set_custom(VIEW["heartbeat"], str(st.get("hb") or "0"))
|
||||
|
||||
|
||||
def remote_summary(others, remote, now, stale=30):
|
||||
"""{"t", "n", "x", "f"}: the other locations with something down (their ALL key not "ALL OK", or not
|
||||
answering: "SC?"), named by id; "f" = 1 while any of them is still flashing (not acknowledged there)."""
|
||||
names, flashing = [], False
|
||||
for cid in sorted(others):
|
||||
st = remote.get(cid)
|
||||
tag = cid.upper()
|
||||
if not st or now - float(st.get("hb") or 0) > stale:
|
||||
names.append(tag + "?")
|
||||
flashing = True
|
||||
continue
|
||||
try:
|
||||
all_ = json.loads(st.get("state") or "{}").get("all") or {}
|
||||
except ValueError:
|
||||
all_ = {}
|
||||
if not all_ or str(all_.get("x") or "").startswith("ALL OK"):
|
||||
continue
|
||||
names.append(tag)
|
||||
flashing = flashing or all_.get("b") != all_.get("b2")
|
||||
return {"t": int(now), "n": len(names), "x": " ".join(names), "f": 1 if flashing else 0}
|
||||
|
||||
|
||||
def campus_command(keys, text, now, restart=False):
|
||||
"""The LOCATION page's taps and holds ("tap 1 3 <time>;hold 0 2 <time>") as that location's own
|
||||
commands ("ack hd1", "restart hd1 <time>"; on its Restart page a hold is "force rs_x <time>" and a
|
||||
|
||||
Reference in New Issue
Block a user