import importlib.util
import json
import os
import sys
from pathlib import Path
root=Path(__file__).resolve().parents[1]
spec=importlib.util.spec_from_file_location('remote',root.parent/'2026-11-01_icerti-fight-r5_r01/remote.py')
remote=importlib.util.module_from_spec(spec);spec.loader.exec_module(remote)
os.umask(0o077)
name=sys.argv[1];output=root/'private'/(name+'.json')
assert not output.exists()
raw=remote.python((root/'helpers'/(name+'.py')).read_text(),sudo=True,timeout=60)
data=json.loads(raw);output.write_bytes(raw)
print(json.dumps({'saved':str(output),'keys':list(data)}))
