okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
be32c7f3f
main
1"""The Python Control the app's host talks to, for the config snapshot: ``python control_shim.py drafting plan|fetch ...``. 2 3The app's host runs ``strata drafting plan --config ...`` and ``strata drafting fetch --config ... --if-needed`` before a Load. Here the same commands run through the 4real strata_cli on the simulated machine (STRATA_SNAPSHOT_WORLD names the world file), with the download replaced by a recorder (tests/snapshot/world.py).""" 5 6from __future__import annotations 7 8import json 9import os 10import sys 11from pathlib import Path 12 13ROOT = Path (__file__ ).resolve ().parents [2 ] 14sys .path .insert (0 ,str (ROOT )) 15 16 17def main (argv :list [str ])-> int : 18from tests .snapshot .driver import run_cli 19from tests .snapshot .matrix import machine ,model_set 20from tests .snapshot .world import World 21spec = json .loads (Path (os .environ ["STRATA_SNAPSHOT_WORLD" ]).read_text (encoding = "utf-8" )) 22world = World (machine (spec ["machine" ]),model_set (spec ["set" ]),Path (spec ["root" ])) 23with world .patched (): 24code ,out ,err = run_cli (argv ) 25log = Path (spec ["root" ])/ "shim-fetches.jsonl" 26with log .open ("a" ,encoding = "utf-8" )as f : 27for item in world .fetches : 28f .write (json .dumps (item )+ "\n" ) 29sys .stdout .write (out ) 30sys .stderr .write (err ) 31return code 32 33 34if __name__ == "__main__" : 35raise SystemExit (main (sys .argv [1 :]))