publish update.py
This commit is contained in:
parent
85fc7edd74
commit
bc896e2916
1 changed files with 46 additions and 17 deletions
63
update.py
63
update.py
|
|
@ -220,9 +220,35 @@ def running_scripts():
|
||||||
return [s for s in allw if s in (out or "")]
|
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):
|
def announce(cfg_path):
|
||||||
"""Post a definitive install/update confirmation to Discord — always fires (not
|
"""Post a definitive install/update report to Discord — always fires (not deduped):
|
||||||
deduped), so you can SEE the watchers came up and which ones are live."""
|
which watchers are up + a self-diagnostic of what's missing, so silence is explainable."""
|
||||||
try:
|
try:
|
||||||
import eve_orehold_watcher as w
|
import eve_orehold_watcher as w
|
||||||
cp = configparser.ConfigParser()
|
cp = configparser.ConfigParser()
|
||||||
|
|
@ -230,10 +256,12 @@ def announce(cfg_path):
|
||||||
run_now = running_scripts()
|
run_now = running_scripts()
|
||||||
short = ", ".join(s.replace("eve_", "").replace("_watcher.py", "").replace(".py", "")
|
short = ", ".join(s.replace("eve_", "").replace("_watcher.py", "").replace(".py", "")
|
||||||
for s in run_now) or "none"
|
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()
|
host = socket.gethostname()
|
||||||
w._discord(cp, "🟢 eve-watcher updated",
|
w._discord(cp, "🟢 eve-watcher updated",
|
||||||
f"On **{host}** — {len(run_now)} process(es) up: {short}.\n"
|
f"On **{host}** — {len(run_now)} up: {short}\n{diag_line}\n"
|
||||||
"Say `!mining on` to start the live feed (rock/hold/local/audio).")
|
"`!mining on` starts the live feed. ❌ items above are why something's quiet.")
|
||||||
print(f"announced: {len(run_now)} running — {short}")
|
print(f"announced: {len(run_now)} running — {short}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"announce skipped: {e}")
|
print(f"announce skipped: {e}")
|
||||||
|
|
@ -302,19 +330,20 @@ def ensure_daily_task():
|
||||||
def main():
|
def main():
|
||||||
print("=== Eve watcher setup / auto-update ===")
|
print("=== Eve watcher setup / auto-update ===")
|
||||||
cfg, first = ensure_config()
|
cfg, first = ensure_config()
|
||||||
changed = update_code()
|
try:
|
||||||
deps() # ensure deps every explicit run (cheap if satisfied)
|
update_code()
|
||||||
ensure_tesseract(cfg)
|
deps() # ensure deps every explicit run (cheap if satisfied)
|
||||||
# explicit run (installer/logon/daily) = clean restart + re-announce heartbeats
|
ensure_tesseract(cfg)
|
||||||
for hb in glob.glob(os.path.join(HERE, ".hb_*")):
|
for hb in glob.glob(os.path.join(HERE, ".hb_*")): # re-announce heartbeats
|
||||||
try:
|
try:
|
||||||
os.remove(hb)
|
os.remove(hb)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
start_watchers(cfg)
|
start_watchers(cfg)
|
||||||
ensure_logon_autostart()
|
ensure_logon_autostart()
|
||||||
ensure_daily_task()
|
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.")
|
print("\nDone. Hands-off from here: it updates + keeps itself running automatically.")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue