Die Welt nannte 'pokerfreak' nur noch in zwei Harness-Zeilen - der Rest waren veraltete Rust-Pruefungen im Pruefordner, die der Aufbau nie auffrischte.
73 lines
2.4 KiB
Python
73 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Wohin unsere Werkzeuge schauen.
|
|
|
|
Vorgabe ist der Klon (`mock/`): Logpfad, Debug-Port und Fensterregel zeigen dorthin. Wer den
|
|
Client daneben meint, nennt sein Log (`COINPOKER_LOG`); `CDP_PORT` geht ebenfalls vor.
|
|
|
|
Der Klon (`python3 mock/start.py` ohne Angaben) liegt genau dort: Lobby auf KLON_PORT,
|
|
Chrome-Debug-Port KLON_CDP, Log KLON_LOG. `lobby/cdp.mjs` traegt dieselbe Regel fuer den Port.
|
|
|
|
python3 umgebung.py # zeigt, wohin es gerade geht
|
|
"""
|
|
import os
|
|
import tempfile
|
|
|
|
_WURZEL = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
# Die Naht zu einer angedockten Engine (docs/SCHNITTSTELLE.md): EIN Treffpunkt, feste Namen darin.
|
|
STREFFPUNKT_DATEIEN = ("shadow.jsonl", "strom.jsonl", "spielplan.json", "ausweichen", "cockpit.json",
|
|
"stop", "eigene_taste")
|
|
|
|
|
|
def treffpunkt():
|
|
"""Wo Welt und Engine sich treffen. Vorgabe: betrieb/scratch - und ohne betrieb/ das eigene
|
|
scratch/ (so heisst es dort, wo es keinen betrieb-Ordner gibt)."""
|
|
ausdruecklich = os.environ.get("SCRATCH")
|
|
if ausdruecklich:
|
|
return ausdruecklich
|
|
if os.path.isdir(os.path.join(_WURZEL, "betrieb")):
|
|
return os.path.join(_WURZEL, "betrieb", "scratch")
|
|
return os.path.join(_WURZEL, "scratch")
|
|
|
|
|
|
|
|
KLON_PORT = 9401
|
|
KLON_CDP = 9402
|
|
KLON_LOG = os.path.join(tempfile.gettempdir(), "coinpoker-klon.log")
|
|
|
|
|
|
def engine():
|
|
"""Das Kommando der Engine: ausdruecklich (ENGINE), sonst hier im Baum."""
|
|
ausdruecklich = os.environ.get("ENGINE")
|
|
if ausdruecklich:
|
|
return ausdruecklich
|
|
ziel = os.path.join(_WURZEL, "betrieb", "runner.py")
|
|
return f"{os.environ.get('PYTHON', 'python3')} {ziel}"
|
|
|
|
|
|
def klon():
|
|
"""Vorgabe ist der Klon. Wer den Client meint, nennt dessen Log (`COINPOKER_LOG`) -
|
|
oder, alt, `CLIENT=1` bzw. `COINPOKER_MOCK=0`."""
|
|
if os.environ.get("COINPOKER_LOG"):
|
|
return False
|
|
return os.environ.get("CLIENT") != "1" and os.environ.get("COINPOKER_MOCK") != "0"
|
|
|
|
|
|
def log():
|
|
return os.environ.get("COINPOKER_LOG") or KLON_LOG
|
|
|
|
|
|
def cdp_port():
|
|
return int(os.environ.get("CDP_PORT") or KLON_CDP)
|
|
|
|
|
|
def fensterregel():
|
|
""""titel": Tischfenster am Titel `NLH <Nummer>` (Klon-Chrome);
|
|
"prozess": Fenster des Spielprozesses (Client)."""
|
|
return "titel" if klon() else "prozess"
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print(f"{'Klon' if klon() else 'Client'}: Log {log()}, CDP-Port {cdp_port()}, "
|
|
f"Fenster nach {fensterregel()}")
|