import subprocess,sys,pathlib
locale,name=sys.argv[1:3]
root=pathlib.Path(__file__).parent
session='selection-proof-diagnostic'
for args in [('open','com.t3tools.t3code.dev','t3code-dev://settings/language'),('tap',f'label="{name}"'),('snapshot',)]:
 subprocess.run(['agent-device',*args,'--session',session],check=True,stdout=subprocess.DEVNULL)
for kind in ['single','plural']:
 with (root/f'head-{locale}-{kind}.log').open('w') as log:
  subprocess.run(['python3',str(root/'flow.py'),'head',locale,kind],check=True,stdout=log,stderr=subprocess.STDOUT)
 print(f'{locale} {kind} captured',flush=True)
