from pathlib import Path import datetime,hashlib,json,os,platform,subprocess root=Path(__file__).resolve().parent record=json.loads((root/'extraction-check.json').read_text(encoding='utf-8')) bundle=Path(record['bundle']) run=root/'native-reopen';run.mkdir(exist_ok=False) work=root/'working' sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest() env=os.environ.copy();system=os.environ['SystemRoot'];env['PATH']=str(Path(system)/'System32')+';'+system for k in list(env): if k.startswith(('CARGO_','RUST','LLVM','WGPU','ARCADIA_')):del env[k] cmd=[str(bundle/'arcadia-studio.exe')] start={'source':'6e7c4ddaf0775198384a8c4882809ea8e14b2976','package_source':'ea23e229260d7d050b3c3b88e77c3a851e936abe','start':datetime.datetime.now(datetime.timezone.utc).isoformat(),'command':cmd,'cwd':str(work),'path':env['PATH'],'platform':platform.platform(),'binary_sha256':sha(Path(cmd[0])),'runtime_sha256':sha(bundle/'libunwind.dll')} assert start['binary_sha256']==record['sha256']['arcadia-studio.exe'] with (run/'stdout.log').open('xb') as out,(run/'stderr.log').open('xb') as err: child=subprocess.Popen(cmd,cwd=work,env=env,stdout=out,stderr=err,creationflags=subprocess.CREATE_NO_WINDOW) start['pid']=child.pid;(run/'started.json').write_text(json.dumps(start,indent=2)+'\n',encoding='utf-8');print(json.dumps(start,indent=2),flush=True) code=child.wait() inventory={p.relative_to(bundle).as_posix():sha(p) for p in bundle.rglob('*') if p.is_file()} finish={**start,'exit_code':code,'finished':datetime.datetime.now(datetime.timezone.utc).isoformat(),'stdout_bytes':(run/'stdout.log').stat().st_size,'stderr_bytes':(run/'stderr.log').stat().st_size,'package_files_unchanged':inventory==record['sha256']} (run/'finished.json').write_text(json.dumps(finish,indent=2)+'\n',encoding='utf-8');print(json.dumps(finish,indent=2),flush=True) assert code==0 and finish['stdout_bytes']==finish['stderr_bytes']==0 and finish['package_files_unchanged']