main
John Lauer
Preserve board29, component assets and scaffold-fit correction candidate with reviewed footage
c54169e
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/kicad';py='C:/Users/john/AppData/Local/Programs/KiCad/10.0/bin/python.exe';cli=py.replace('python.exe','kicad-cli.exe')
def ab(v,a):
r=subprocess.run(['adom-bridge','--target','AdomLapper','--ai-thread','adom-custom-load',v,json.dumps(a)],capture_output=True,text=True);d=json.loads(r.stdout)
if d.get('success') is False or d.get('exitCode',0)!=0:raise RuntimeError(str({k:d.get(k)for k in ['error','exitCode','stdout','stderr']}))
return d
shutil.copy(P/'design/netlist.json',P/'kicad/netlist.json')
files=['build_board.py','place_candidate.py','placement-moves.json','placement-candidate.kicad_dru','netlist.json','lib/Load.pretty/TI_DGS0010A.kicad_mod']
with zipfile.ZipFile('/tmp/custom-load-candidate.zip','w')as z:
for f in files:z.write(P/'kicad'/f,f)
ab('send_files',{'filePaths':['/tmp/custom-load-candidate.zip'],'dest':host,'reason':'Generate native placement review candidate without modifying the open board'})
code=f"import zipfile,runpy,os;os.environ['ADOM_LOAD_BUILD_NAME']='placement-source';zipfile.ZipFile('{host}/custom-load-candidate.zip').extractall('{host}');runpy.run_path('{host}/build_board.py',run_name='__main__');runpy.run_path('{host}/place_candidate.py',run_name='__main__')"
r=ab('shell_execute',{'command':f'"{py}" -c "{code}"','timeoutSeconds':60,'reason':'Native placement and reference-label review'});print(r.get('stdout'),r.get('stderr'))
r=ab('shell_execute',{'command':f'"{cli}" pcb drc --format json -o "{host}/candidate-drc.json" "{host}/placement-candidate.kicad_pcb"','timeoutSeconds':120,'reason':'Native acceptance check of the updated placement draft'});print(r.get('stdout'),r.get('stderr'))
ab('pull_file',{'filePaths':[host+'/'+f for f in ['placement-candidate.kicad_pcb','placement-candidate.json','candidate-drc.json']],'saveTo':str(P/'kicad')})