Files
EscapistsReintroduced/docs/evidence/terrain-loader-feasibility-2026-10-01/probe-4/runner.py
T
jakub 6a667d8deb Capture current mission, AI, map and administration development
Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
2026-10-13 22:52:53 +02:00

33 lines
2.9 KiB
Python

from pathlib import Path
import sys,os,json,subprocess,time,fcntl,shutil
ROOT=Path('/home/jakub/devel/escapistsrereintroduced');sys.path.insert(0,str(ROOT/'tools'))
from headless_game import assert_prefix_idle,cleanup_owned_run
from external_addons import policy,prepare_profile
steam=Path.home()/'.local/share/Steam';compat=Path('/tmp/erri-headless-compat');profile=Path('/tmp/erri-terrain-header-probe4');profile.mkdir()
lock=(compat/'.erri-workbench.lock').open('a');fcntl.flock(lock,fcntl.LOCK_EX|fcntl.LOCK_NB);assert_prefix_idle(compat)
addons=profile/'addons';addons.mkdir()
external=steam/'steamapps/compatdata/1874880/pfx/drive_c/users/steamuser/Documents/My Games/ArmaReforger/addons'
prepare_profile(addons,external,policy(ROOT),profile/'external-cache.json')
for name,target in [('ArmaReforger',steam/'steamapps/common/Arma Reforger/addons/data'),('ERR_Core',Path('/tmp/erri-terrain-header-source4')),('Nogova',Path('/home/jakub/devel/gabreta/addons/NogovaReforger'))]:
(addons/name).symlink_to(target,target_is_directory=True)
config={'bindAddress':'127.0.0.1','bindPort':22991,'game':{'name':'Private terrain header probe','password':'private-local-probe','scenarioId':'{C1E20667DCE324ED}Missions/ERR_Everon.conf','maxPlayers':1,'visible':False,'supportedPlatforms':['PLATFORM_PC'],'gameProperties':{'battlEye':False,'missionHeader':{'World':'{52BA23DC05308E33}Worlds/Nogova/Nogova.ent'}}}}
(profile/'server.json').write_text(json.dumps(config,indent=2))
proton=steam/'steamapps/common/Proton - Experimental/proton';game=steam/'steamapps/common/Arma Reforger'
cmd=['gamescope','--backend','headless','-W','1280','-H','720','-w','1280','-h','720','-r','30','--',str(proton),'run',str(game/'ArmaReforgerSteamDiag.exe'),'-server','{C1E20667DCE324ED}Missions/ERR_Everon.conf','-config','Z:'+str(profile/'server.json'),'-addonsDir','Z:'+str(addons),'-addons','2528466DE220D91C,70C981A53E02B64F','-profile','Z:'+str(profile),'-noBackend','-bindIP','127.0.0.1','-bindPort','22991','-maxFPS','30','-logconsole','-noSound','-noSplash','-noThrow','-disableCrashReporter']
env=os.environ.copy();env.update(STEAM_COMPAT_DATA_PATH=str(compat),STEAM_COMPAT_CLIENT_INSTALL_PATH=str(steam),WINEPREFIX=str(compat/'pfx'),PULSE_SINK='erri_tests_silent')
(profile/'command.json').write_text(json.dumps(cmd,indent=2))
child=None;started=time.time()
with (profile/'launch.log').open('w') as log:
try:
child=subprocess.Popen(cmd,cwd=game,env=env,stdout=log,stderr=subprocess.STDOUT,start_new_session=True)
while time.time()-started<110 and child.poll() is None:
sessions=sorted((profile/'logs').glob('logs_*/console.log'))
if sessions:
text=sessions[-1].read_text(errors='replace')
if 'WORLD : Entities load' in text or 'Unable to initialize the game' in text:break
time.sleep(1)
finally:
if child:
report=cleanup_owned_run(child,proton,env,compat);(profile/'cleanup.json').write_text(json.dumps(report,indent=2));print(report)
print(profile)