feat: SFM event forwarding added. v0.3.0

This commit is contained in:
2026-05-19 04:31:35 +00:00
parent 0e2fe7c1e3
commit 4312efc15c
10 changed files with 1947 additions and 28 deletions
+25 -2
View File
@@ -1,5 +1,5 @@
"""
Thor Watcher — System Tray Launcher v0.2.0
Thor Watcher — System Tray Launcher v0.3.0
Requires: pystray, Pillow, tkinter (stdlib)
Run with: pythonw thor_tray.py (no console window)
@@ -420,7 +420,25 @@ class WatcherTray:
else:
api_str = "API off"
return "Running — {} | {} unit(s) | scan {}".format(api_str, unit_count, age_str)
base_line = "Running — {} | {} unit(s) | scan {}".format(api_str, unit_count, age_str)
sfm_status = self.state.get("sfm_status", "disabled")
if sfm_status in ("ok", "fail", "ready"):
counts = self.state.get("last_forward_counts") or {}
fwd = counts.get("forwarded", 0)
errs = counts.get("errors", 0)
last_fwd = self.state.get("last_forward")
if last_fwd is not None:
fwd_age = int((datetime.now() - last_fwd).total_seconds())
fwd_age_str = "{}s ago".format(fwd_age) if fwd_age < 60 else "{}m ago".format(fwd_age // 60)
else:
fwd_age_str = "pending"
sfm_line = "SFM {} | {} fwd, {} err | last {}".format(
sfm_status.upper(), fwd, errs, fwd_age_str,
)
return base_line + "\n" + sfm_line
return base_line
def _tray_status(self):
status = self.state.get("status", "starting")
@@ -431,12 +449,17 @@ class WatcherTray:
api_status = self.state.get("api_status", "disabled")
if api_status == "fail":
return "missing" # red — API failing
sfm_status = self.state.get("sfm_status", "disabled")
if api_status == "ok" and sfm_status == "fail":
return "pending" # amber — heartbeat OK but forwarder is failing
if api_status == "disabled":
return "pending" # amber — running but not reporting
return "ok" # green — running and API good
def _build_menu(self):
return pystray.Menu(
pystray.MenuItem("Thor Watcher v{}".format(_CURRENT_VERSION), None, enabled=False),
pystray.Menu.SEPARATOR,
pystray.MenuItem(lambda item: self._status_text(), None, enabled=False),
pystray.Menu.SEPARATOR,
pystray.MenuItem("Settings...", self._open_settings),