publish eve_orehold_watcher.py

This commit is contained in:
brockdarnold 2026-06-15 00:40:06 +00:00
parent 6262630705
commit 6b631026ec

View file

@ -33,10 +33,24 @@ import json
import os
import re
import socket
import subprocess
import sys
import time
import urllib.request
# Stop child processes (Tesseract on every OCR scan, etc.) from flashing a console
# window. Patches subprocess so every spawned process gets CREATE_NO_WINDOW on Windows.
# All watchers import this module, so this covers the whole fleet.
if os.name == "nt":
_CREATE_NO_WINDOW = 0x08000000
_orig_popen_init = subprocess.Popen.__init__
def _popen_no_window(self, *a, **k):
k["creationflags"] = k.get("creationflags", 0) | _CREATE_NO_WINDOW
_orig_popen_init(self, *a, **k)
subprocess.Popen.__init__ = _popen_no_window
HERE = os.path.dirname(os.path.abspath(__file__))
CONFIG_PATH = os.path.join(HERE, "config.ini")
@ -425,8 +439,10 @@ def run_ocr(cp):
tail = f"filling {rate_m3min:,.0f} m³/min · full <t:{full_at}:R>"
else:
tail = "not growing yet — lasers/drones idle?"
_discord_live(cp, "hold", "⛏️ Ore hold",
f"{pct:.0f}% ({cur:,}/{cap:,} m³) · {tail}")
act = " · 🟠 **COMPRESS NOW**" if pct >= alert_pct else \
(" · compress soon" if pct >= 80 else "")
_discord_live(cp, "hold", f"⛏️ {socket.gethostname()} ore hold",
f"{pct:.0f}% ({cur:,}/{cap:,} m³) · {tail}{act}")
last_status = time.time()
was_mining = mining
if pct < reset_pct: