diff --git a/client/umgebung.py b/client/umgebung.py index 092c464e..4fd00c9b 100644 --- a/client/umgebung.py +++ b/client/umgebung.py @@ -39,6 +39,17 @@ KLON_CDP = 9402 KLON_LOG = os.path.join(tempfile.gettempdir(), "coinpoker-klon.log") +def engine(): + """Das Kommando der Engine: ausdruecklich (POKERFREAK_ENGINE), sonst der Nachbar, sonst hier.""" + ausdruecklich = os.environ.get("POKERFREAK_ENGINE") + if ausdruecklich: + return ausdruecklich + nachbar = os.path.join(os.path.dirname(_WURZEL), "pokerfreak", "betrieb", "runner.py") + eigen = os.path.join(_WURZEL, "betrieb", "runner.py") + ziel = nachbar if os.path.exists(nachbar) else eigen + return f"{os.environ.get('PYTHON', 'python3')} {ziel}" + + def klon(): # Vorgabe: der Klon. Nur ein ausdrueckliches "1" zeigt auf den Client. return os.environ.get("COINPOKER_CLIENT") != "1" diff --git a/sicht/steuern.py b/sicht/steuern.py index 117f49da..763a60a9 100644 --- a/sicht/steuern.py +++ b/sicht/steuern.py @@ -32,7 +32,7 @@ import umgebung # noqa: E402 treffpunkt = umgebung.treffpunkt # Naht (docs/SCHNITTSTELLE.md) # Die Engine ist ein KOMMANDO, kein Pfad: eine Welt dockt hier ihre Engine an. -ENGINE = os.environ.get("POKERFREAK_ENGINE") or f"{sys.executable} {os.path.join(WURZEL, 'betrieb', 'runner.py')}" +ENGINE = umgebung.engine() def engine_befehl(): diff --git a/tests/lauf.py b/tests/lauf.py index ffcd820d..311f4930 100644 --- a/tests/lauf.py +++ b/tests/lauf.py @@ -71,7 +71,17 @@ WACHE_DATEI = os.path.join(tempfile.gettempdir(), f"pf-wache-{os.getpid()}.txt") def umgebung(): """Ohne Tisch (CDP_PORT) und mit eigenem Not-Aus-Ordner (hand/notaus.py).""" - umg = dict(os.environ, CDP_PORT=SPERRPORT, POKERFREAK_STOPP_ORDNER=tempfile.mkdtemp(prefix="pf-stopp-")) + umg = dict(os.environ) + sys.path.insert(0, os.path.join(HIER, "..", "client")) + try: + import umgebung as _umg # die Naht kennt die Engine (Nachbar oder ausdruecklich) + umg.setdefault("POKERFREAK_ENGINE", _umg.engine()) + _er = os.path.dirname(os.path.dirname(os.path.abspath(_umg.engine().split()[-1]))) + _pfade = [os.path.join(_er, d) for d in ("hand", "betrieb", "mcp", "lobby", "entscheiden")] + umg["PYTHONPATH"] = os.pathsep.join([p for p in _pfade + [umg.get("PYTHONPATH", "")] if p]) + except Exception: + pass + umg.update(CDP_PORT=SPERRPORT, POKERFREAK_STOPP_ORDNER=tempfile.mkdtemp(prefix="pf-stopp-")) if umg.get("MOCK_HEADLESS") != "0": # kein Prozess einer Prüfung fasst die Maus an (tests/wache/) umg["PYTHONPATH"] = os.pathsep.join(p for p in (WACHE, umg.get("PYTHONPATH")) if p) umg["POKERFREAK_WACHE_DATEI"] = WACHE_DATEI