main
John Lauer Preserve board29, component assets and scaffold-fit correction candidate with reviewed footage c54169e
#!/usr/bin/env python3
"""Transfer this project to the selected user's native KiCad; never installs KiCad."""
import json,subprocess,zipfile,shutil
from pathlib import Path
P=Path(__file__).resolve().parents[1];HOST='C:/Users/john/adom-projects/adom-custom-electronic-load';PY='C:/Users/john/AppData/Local/Programs/KiCad/10.0/bin/python.exe'
def ab(verb,args):
 r=subprocess.run(['adom-bridge','--target','AdomLapper','--ai-thread','adom-custom-load',verb,json.dumps(args)],capture_output=True,text=True)
 obj=json.loads(r.stdout);(P/'design'/('host-'+verb+'.json')).write_text(json.dumps(obj,indent=2))
 if obj.get('success') is False or obj.get('status')=='error':raise RuntimeError(obj)
 return obj
shutil.copy(P/'design/netlist.json',P/'kicad/netlist.json')
with zipfile.ZipFile('/tmp/custom-load-kicad.zip','w',zipfile.ZIP_DEFLATED) as z:
 for p in (P/'kicad').rglob('*'):
  if p.is_file() and p.suffix not in ('.svg','.html','.log'):z.write(p,str(p.relative_to(P)))
ab('send_files',{'filePaths':['/tmp/custom-load-kicad.zip'],'dest':HOST,'reason':'Update the custom-load engineering draft and native schematic'})
code=f"import zipfile,runpy;zipfile.ZipFile('{HOST}/custom-load-kicad.zip').extractall('{HOST}');runpy.run_path('{HOST}/kicad/build_board.py',run_name='__main__')"
r=ab('shell_execute',{'command':f'"{PY}" -c "{code}"','reason':'Generate the custom load draft with native KiCad','timeoutSeconds':45});print(r.get('stdout'),r.get('stderr'))
r=ab('pull_file',{'filePaths':[HOST+'/kicad/adom-custom-electronic-load.kicad_pcb',HOST+'/kicad/build_board.json'],'saveTo':str(P/'kicad')});print('board returned')