Startprobe und Wuerfel-Bruecke beenden am Ende ihre SHARINGAN-Dienste (Ports aus der B-Zeile), damit der Laeufer eigene startet (Vorfall 03.12. 17:58)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,35 @@ def quelle(grund):
|
||||
return "Motor: " + g[:40]
|
||||
|
||||
|
||||
def dienst_ports(env):
|
||||
"""Ports der SHARINGAN-Dienste aus der Umgebung der Probe (MOTOR_*_ADRESSE=host:port)."""
|
||||
return sorted({int(v.rsplit(":", 1)[1]) for k, v in env.items() if k.endswith("_ADRESSE") and k.startswith("MOTOR_") and ":" in v and v.rsplit(":", 1)[1].isdigit()})
|
||||
|
||||
|
||||
def dienst_pids(ports, prozesse):
|
||||
"""PIDs der pokerbench-Prozesse, deren Befehlszeile auf einem dieser Ports lauscht (--port <p>). prozesse: [(pid, name, befehlszeile)]."""
|
||||
return sorted(pid for pid, name, cmd in prozesse if str(name).startswith("pokerbench-") and any(re.search(r"--port %d\b" % p, str(cmd)) for p in ports))
|
||||
|
||||
|
||||
def dienst_beenden(pids):
|
||||
import subprocess
|
||||
for pid in pids:
|
||||
subprocess.run(["taskkill", "/PID", str(pid), "/F"], capture_output=True, creationflags=0x08000000 | 0x4000)
|
||||
|
||||
|
||||
def dienste_beenden(env):
|
||||
import subprocess
|
||||
ports = dienst_ports(env)
|
||||
if not ports or sys.platform != "win32":
|
||||
return []
|
||||
aus = subprocess.run(["powershell", "-NoProfile", "-Command", "Get-CimInstance Win32_Process -Filter \"Name like 'pokerbench-%'\" | % { '{0}\t{1}\t{2}' -f $_.ProcessId, $_.Name, $_.CommandLine }"],
|
||||
capture_output=True, text=True, creationflags=0x08000000 | 0x4000).stdout
|
||||
prozesse = [tuple(z.split("\t", 2)) for z in aus.splitlines() if z.count("\t") >= 2]
|
||||
pids = dienst_pids(ports, [(int(a), b, c) for a, b, c in prozesse if a.isdigit()])
|
||||
dienst_beenden(pids)
|
||||
return pids
|
||||
|
||||
|
||||
def position(q):
|
||||
n = q.get("seats") or 6; k = q.get("buttonSeat"); s = q.get("heroSeat")
|
||||
if k is None or s is None:
|
||||
@@ -92,6 +121,9 @@ def main():
|
||||
json.dump(summe, open(os.path.join(o.aus, "summe.json"), "w", encoding="utf-8"), indent=1, ensure_ascii=False)
|
||||
json.dump([{"q": it["q"], "hand": it.get("hand"), "antwort": a} for it, a in zip(items, antw)], open(os.path.join(o.aus, "antworten.json"), "w", encoding="utf-8"), ensure_ascii=False)
|
||||
json.dump(grob, open(os.path.join(o.aus, "grob.json"), "w", encoding="utf-8"), indent=1, ensure_ascii=False)
|
||||
# 03.12. (Vorfall 17:58: von einer Probe gestartete Dienste blieben stehen, der Laeufer nutzte sie, der Waechter hielt sie an):
|
||||
# die Dienste dieser Probe am Ende beenden, damit der Laeufer seine eigenen startet
|
||||
print("Dienste beendet: %s" % dienste_beenden(env), flush=True)
|
||||
print("STARTPROBE " + json.dumps({kk: summe[kk] for kk in ("anfragen", "minuten", "quelle", "sharingan_anteil", "ungueltig", "abstuerze", "grob_zahl")}, ensure_ascii=False), flush=True)
|
||||
|
||||
|
||||
|
||||
@@ -54,6 +54,8 @@ def main():
|
||||
"antworten_nicht_sharingan": nicht_sh, "abstuerze": tode}
|
||||
json.dump({"summe": summe, "lagen": aus}, open(o.aus, "w", encoding="utf-8"), ensure_ascii=False, indent=1)
|
||||
print("WUERFEL-BRUECKE " + json.dumps(summe, ensure_ascii=False))
|
||||
import farm_rein_startprobe as P
|
||||
print("Dienste beendet: %s" % P.dienste_beenden(env), flush=True) # nie fremd gestartete Dienste fuer den Laeufer stehen lassen
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user