Coverage for src/ph/frontend.py: 100.0%
17 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-28 08:17 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-28 08:17 +0000
1"""Request a safe game-frontend refresh from the active target launcher."""
3import os
4from collections.abc import Mapping
5from pathlib import Path
7from ph.targets import DARKOS, LinuxTarget
9REFRESH_FILE_ENV = DARKOS.refresh_marker_environment
12def request_game_frontend_refresh(
13 environment: Mapping[str, str] | None = None,
14 target: LinuxTarget = DARKOS,
15) -> bool:
16 """Ask the active target launcher to refresh its game frontend after exit."""
18 values = os.environ if environment is None else environment
19 configured_path = values.get(target.refresh_marker_environment, "").strip()
20 if not configured_path:
21 return False
22 refresh_file = Path(configured_path)
23 try:
24 refresh_file.parent.mkdir(parents=True, exist_ok=True)
25 refresh_file.touch()
26 except OSError:
27 return False
28 return True