gokul/macro-six-usbc
USB-powered ATmega32U4 controller board with protected/switched 5 V power, six tactile keys, rotary encoder, reset/boot/ISP interfaces, power LED, and six daisy-chained SK6812 RGB LEDs driven through MOSFETs.
- Version
- 0.1.6
- License
- MIT
- Stars
- 0
enclosure/fetch-models.py
"""Download only the supplier models referenced by this board, for local fit checks."""
from pathlib import Path
import concurrent.futures
import hashlib
import json
import urllib.request
root=Path(__file__).resolve().parents[1]
j=json.loads((root/"outputs/release/board.circuit.json").read_text())
sources={e["source_component_id"]:e["name"] for e in j if e["type"]=="source_component"}
rows={}
for e in j:
if e["type"]!="cad_component":continue
for kind in ["obj","step"]:
url=e.get("model_"+kind+"_url")
if url:rows[url]=(sources[e["source_component_id"]],kind)
cache=root/"work/enclosure-models";cache.mkdir(parents=True,exist_ok=True)
def fetch(row):
url,(name,kind)=row;path=cache/(name+"."+kind)
if not path.exists():path.write_bytes(urllib.request.urlopen(url,timeout=60).read())
content=path.read_bytes()
return dict(component=name,format=kind,url=url,sha256=hashlib.sha256(content).hexdigest(),bytes=len(content))
with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor:
result=list(executor.map(fetch,rows.items()))
out=root/"enclosure/exports";out.mkdir(parents=True,exist_ok=True)
(out/"model-provenance.json").write_text(json.dumps(result,indent=2)+"\n")
print("Supplier models cached:",len(result))