From bc896e29164359f25f410552a96c643506adbb16 Mon Sep 17 00:00:00 2001 From: brockdarnold Date: Sun, 14 Jun 2026 17:00:26 +0000 Subject: [PATCH] publish update.py --- update.py | 63 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/update.py b/update.py index c03206d..5448b90 100644 --- a/update.py +++ b/update.py @@ -220,9 +220,35 @@ def running_scripts(): return [s for s in allw if s in (out or "")] +def _diagnostics(cp): + """Self-check the things that make watchers silent, so we can see the root cause.""" + import shutil as _sh + checks = [] + # Tesseract (hold % + rock readers need it) + std = r"C:\Program Files\Tesseract-OCR\tesseract.exe" + tess = _sh.which("tesseract") or (std if os.path.exists(std) else + (cp.get("ocr", "tesseract_cmd", fallback="").strip() or None)) + checks.append(("tesseract", bool(tess and os.path.exists(tess) if tess and ":" in str(tess) else tess))) + # audio deps + for mod in ("numpy", "soundcard"): + try: + __import__(mod); checks.append((mod, True)) + except Exception: + checks.append((mod, False)) + # EVE log dirs (combat/chat need them) + docs = os.path.expanduser("~/Documents/EVE/logs") + one = os.path.expanduser("~/OneDrive/Documents/EVE/logs") + checks.append(("EVE Gamelogs", os.path.isdir(docs + "/Gamelogs") or os.path.isdir(one + "/Gamelogs"))) + checks.append(("EVE Chatlogs", os.path.isdir(docs + "/Chatlogs") or os.path.isdir(one + "/Chatlogs"))) + # calibrated regions + checks.append(("hold region", bool(cp.get("ocr", "region", fallback="").strip()))) + checks.append(("survey region", bool(cp.has_section("rock") and cp.get("rock", "region", fallback="").strip()))) + return checks + + def announce(cfg_path): - """Post a definitive install/update confirmation to Discord — always fires (not - deduped), so you can SEE the watchers came up and which ones are live.""" + """Post a definitive install/update report to Discord — always fires (not deduped): + which watchers are up + a self-diagnostic of what's missing, so silence is explainable.""" try: import eve_orehold_watcher as w cp = configparser.ConfigParser() @@ -230,10 +256,12 @@ def announce(cfg_path): run_now = running_scripts() short = ", ".join(s.replace("eve_", "").replace("_watcher.py", "").replace(".py", "") for s in run_now) or "none" + diag = _diagnostics(cp) + diag_line = " ".join(f"{'✅' if ok else '❌'}{name}" for name, ok in diag) host = socket.gethostname() w._discord(cp, "🟢 eve-watcher updated", - f"On **{host}** — {len(run_now)} process(es) up: {short}.\n" - "Say `!mining on` to start the live feed (rock/hold/local/audio).") + f"On **{host}** — {len(run_now)} up: {short}\n{diag_line}\n" + "`!mining on` starts the live feed. ❌ items above are why something's quiet.") print(f"announced: {len(run_now)} running — {short}") except Exception as e: print(f"announce skipped: {e}") @@ -302,19 +330,20 @@ def ensure_daily_task(): def main(): print("=== Eve watcher setup / auto-update ===") cfg, first = ensure_config() - changed = update_code() - deps() # ensure deps every explicit run (cheap if satisfied) - ensure_tesseract(cfg) - # explicit run (installer/logon/daily) = clean restart + re-announce heartbeats - for hb in glob.glob(os.path.join(HERE, ".hb_*")): - try: - os.remove(hb) - except Exception: - pass - start_watchers(cfg) - ensure_logon_autostart() - ensure_daily_task() - announce(cfg) # definitive Discord confirmation of what's running + try: + update_code() + deps() # ensure deps every explicit run (cheap if satisfied) + ensure_tesseract(cfg) + for hb in glob.glob(os.path.join(HERE, ".hb_*")): # re-announce heartbeats + try: + os.remove(hb) + except Exception: + pass + start_watchers(cfg) + ensure_logon_autostart() + ensure_daily_task() + finally: + announce(cfg) # ALWAYS report to Discord (even if a step above failed) print("\nDone. Hands-off from here: it updates + keeps itself running automatically.")