main
John Lauer
Adopt native-reviewed Board31 library corrections and publish process clip
17c4685
"""Show an isolated library-review board for recording, without replacing the project board."""
from pathlib import Path
import json,subprocess,zipfile,base64,shutil
root=Path(__file__).resolve().parents[1];out=root/'checkpoints/library-label-review';remote='C:/Users/john/adom-projects/adom-custom-electronic-load/review/library-label-candidate'
def call(v,a,label):
p=subprocess.run(['adom-bridge','--target','AdomLapper','--ai-thread','adom-custom-load',v,json.dumps(a)],capture_output=True,text=True);d=json.loads(p.stdout);(out/(label+'.json')).write_text(json.dumps(d,indent=2)+'\n');assert p.returncode==0 and d.get('success',d.get('ok',True)) and not d.get('errors') and d.get('exitCode',0)==0,d;return d
# Only close the verified task-owned windows; never discard unsaved work.
state=call('kicad_routing_state',{'filePath':'C:/Users/john/adom-projects/adom-custom-electronic-load/review/bourns-land-candidate/bourns-land-candidate.kicad_pcb'},'previous-live-state')
assert state['revision']=='220ff87203aeecc41b5a40ff9e5b371fc7e7de11853c1205fde01494316c9b7a'
for hwnd in [3155444,18417858]:call('desktop_close_window',{'hwnd':hwnd},f'close-{hwnd}')
script="$p=Get-Process -Id 11228 -ErrorAction SilentlyContinue; if($p){if(-not $p.WaitForExit(10000)){throw 'Task editor still running; inspect save prompt'}}"
call('run_script',{'interpreter':'powershell','scriptB64':base64.b64encode(script.encode()).decode(),'reason':'Wait for only the task-owned editor to exit before opening candidate'},'previous-exit')
# Candidate already contains all selected models.
zpath=out/'viewer-inputs.zip'
with zipfile.ZipFile(zpath,'w',zipfile.ZIP_DEFLATED) as z:
for p in [out/'library-label-candidate.kicad_pcb',out/'library-label-candidate.kicad_pro',out/'library-label-candidate.kicad_dru',out/'fp-lib-table']+list((out/'lib').rglob('*.kicad_mod'))+list((out/'3d').glob('*.step')):z.write(p,p.relative_to(out))
call('send_files',{'filePaths':[str(zpath)],'dest':remote+'/','reason':'Prepare isolated library candidate for requested engineering video'},'viewer-send')
script=f"$ErrorActionPreference='Stop'\nExpand-Archive -LiteralPath '{remote}/viewer-inputs.zip' -DestinationPath '{remote}' -Force\n"
call('run_script',{'interpreter':'powershell','scriptB64':base64.b64encode(script.encode()).decode(),'reason':'Unpack task-owned review assets without changing project board'},'viewer-unpack')
r=call('kicad_open_board',{'filePath':remote+'/library-label-candidate.kicad_pcb','foreground':False},'viewer-open');print(json.dumps({k:v for k,v in r.items() if k!='output'})[:4200])