diff --git a/update.py b/update.py index d5ec488..c03206d 100644 --- a/update.py +++ b/update.py @@ -20,8 +20,10 @@ First time on a new PC (or just paste the install one-liner): python eve_orehold_watcher.py --snip # one-time GUI step for OCR hold alerts """ import configparser +import glob import os import shutil +import socket import subprocess import sys @@ -208,6 +210,35 @@ def watchers_running(): return 0 +def running_scripts(): + """Which watcher scripts are actually running right now (by command line).""" + if not WIN: + return [] + _, out = ps("Get-CimInstance Win32_Process -Filter \"Name='pythonw.exe'\" | " + "Select-Object -ExpandProperty CommandLine") + allw = WATCHER_SCRIPTS + ("eve_autoupdate.py",) + return [s for s in allw if s in (out or "")] + + +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.""" + try: + import eve_orehold_watcher as w + cp = configparser.ConfigParser() + cp.read(cfg_path, encoding="utf-8-sig") + run_now = running_scripts() + short = ", ".join(s.replace("eve_", "").replace("_watcher.py", "").replace(".py", "") + for s in run_now) or "none" + 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).") + print(f"announced: {len(run_now)} running — {short}") + except Exception as e: + print(f"announce skipped: {e}") + + def stop_watchers(): # all of ours run as pythonw on an eve_*.py script (watchers + autoupdate poller) _kill_scripts(("eve_",)) @@ -272,15 +303,18 @@ def main(): print("=== Eve watcher setup / auto-update ===") cfg, first = ensure_config() changed = update_code() - if changed or first: - deps() - ensure_tesseract(cfg) - if changed or first or watchers_running() == 0: - start_watchers(cfg) - else: - print("• up to date and watchers already running — nothing to restart.") + 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 print("\nDone. Hands-off from here: it updates + keeps itself running automatically.")