publish update.py
This commit is contained in:
parent
67745839db
commit
bfd8984f38
1 changed files with 28 additions and 4 deletions
32
update.py
32
update.py
|
|
@ -170,11 +170,36 @@ def ensure_tesseract(cfg_path):
|
|||
print(f"• Tesseract ready: {path}")
|
||||
|
||||
|
||||
def _kill_scripts(names):
|
||||
"""Force-stop pythonw processes whose command line names any of `names`."""
|
||||
if not WIN:
|
||||
return
|
||||
pats = " -or ".join(f"$_.CommandLine -like '*{n}*'" for n in names)
|
||||
ps("Get-CimInstance Win32_Process -Filter \"Name='pythonw.exe'\" | "
|
||||
f"Where-Object {{ {pats} }} | "
|
||||
"ForEach-Object { Stop-Process -Id $_.ProcessId -Force }")
|
||||
|
||||
|
||||
def _start_script(name):
|
||||
if not WIN:
|
||||
return
|
||||
ps(f"Start-Process pythonw -ArgumentList '\"{os.path.join(HERE, name)}\"' "
|
||||
f"-WorkingDirectory '{HERE}' -WindowStyle Hidden")
|
||||
|
||||
|
||||
def restart_mining_watchers():
|
||||
"""Restart only the data watchers (not the autoupdate poller) — used by the
|
||||
poller to bring the watchers onto freshly-pulled code without killing itself."""
|
||||
_kill_scripts(WATCHER_SCRIPTS)
|
||||
for n in WATCHER_SCRIPTS:
|
||||
_start_script(n)
|
||||
|
||||
|
||||
def watchers_running():
|
||||
if not WIN:
|
||||
return 0
|
||||
_, out = ps("(Get-CimInstance Win32_Process -Filter \"Name='pythonw.exe'\" "
|
||||
"| Where-Object { $_.CommandLine -like '*watcher*' }).Count")
|
||||
"| Where-Object { $_.CommandLine -like '*eve_*' }).Count")
|
||||
try:
|
||||
return int(out or "0")
|
||||
except ValueError:
|
||||
|
|
@ -182,9 +207,8 @@ def watchers_running():
|
|||
|
||||
|
||||
def stop_watchers():
|
||||
ps("Get-CimInstance Win32_Process -Filter \"Name='pythonw.exe'\" | "
|
||||
"Where-Object { $_.CommandLine -like '*watcher*' } | "
|
||||
"ForEach-Object { Stop-Process -Id $_.ProcessId -Force }")
|
||||
# all of ours run as pythonw on an eve_*.py script (watchers + autoupdate poller)
|
||||
_kill_scripts(("eve_",))
|
||||
|
||||
|
||||
def start_watchers(cfg_path):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue