#!/usr/bin/env python3 """Embed reviewed pure Python into the standalone canonical runner; no runtime exec/import from SMB.""" from pathlib import Path ROOT=Path(__file__).resolve().parent RUNNER=ROOT.parent/'deploy-runner/nodedc-deploy' START='# BEGIN GENERATED DEVICE CORE AUTODEPLOY LIBRARY\n' END='# END GENERATED DEVICE CORE AUTODEPLOY LIBRARY\n' def section(): output=START+'def device_autodeploy_library():\n' for name in ('deployment_queue.py','gitea_source.py','controller.py'): source=(ROOT/name).read_text() lines=[line for line in source.splitlines() if not line.startswith('from deployment_queue import ')] output+=' # Source: infra/device-core-deploy/'+name+'\n' output+='\n'.join(' '+line if line else '' for line in lines)+'\n\n' return output+' return DeploymentQueue, GiteaSource, Controller, (QueueError, SourceError)\n'+END if __name__=='__main__': current=RUNNER.read_text() if START in current: before,rest=current.split(START,1);_,after=rest.split(END,1) current=before+section()+after else: current=current.replace('\ndef main(argv):','\n'+section()+'\n\ndef main(argv):',1) RUNNER.write_text(current)