publish update.py

This commit is contained in:
brockdarnold 2026-06-14 17:00:26 +00:00
parent 85fc7edd74
commit bc896e2916

View file

@ -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,11 +330,11 @@ def ensure_daily_task():
def main():
print("=== Eve watcher setup / auto-update ===")
cfg, first = ensure_config()
changed = update_code()
try:
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_*")):
for hb in glob.glob(os.path.join(HERE, ".hb_*")): # re-announce heartbeats
try:
os.remove(hb)
except Exception:
@ -314,7 +342,8 @@ def main():
start_watchers(cfg)
ensure_logon_autostart()
ensure_daily_task()
announce(cfg) # definitive Discord confirmation of what's running
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.")