component
RC0402FR-0733KL - YAGEO
Public Made by Adomby adom
Thick film chip resistor 33 kOhm +/-1 %, 1/16 W, 50 V, 0402 (1005 metric)
main
"""Put the datasheet marking code on the top coat of a chip resistor STEP.
Uses the shared step2glb service's /laser-etch endpoint in flat mode: the body is
untouched and the code is added as its own floating solid group (Adom.LaserEtch)
just above the top coat. The input STEP is never modified.
usage: etch.py in.step CODE out.step jobname
prints one JSON line: service, version, job id, sha256 of input and output.
"""
import sys, json, time, hashlib, urllib.request
S = "https://step2glb-gmdoncpxdwx0.adom.cloud"
src, code, out, job = sys.argv[1:5]
H = {"X-Client": "claude-esc3", "X-Job-Name": f"{job}-marking-{code}"}
sha = lambda b: hashlib.sha256(b).hexdigest()
data = open(src, "rb").read()
def req(url, body=None, extra=None):
r = urllib.request.Request(url, data=body, headers={**H, **(extra or {})}, method="POST" if body is not None else "GET")
with urllib.request.urlopen(r, timeout=120) as f:
return f.read()
health = json.loads(req(S + "/health"))
j = json.loads(req(f"{S}/laser-etch?name={code}&mode=flat", data, {"Content-Type": "application/octet-stream"}))
jid = j["job_id"]
for _ in range(60):
st = json.loads(req(f"{S}/jobs/{jid}"))
if st["status"] in ("complete", "failed"):
break
time.sleep(2)
if st["status"] != "complete":
print("FAILED", st); sys.exit(1)
res = req(f"{S}/jobs/{jid}/result")
open(out, "wb").write(res)
print(json.dumps({"service": S, "service_version": health.get("version"), "service_git": health.get("git_sha_short"),
"endpoint": f"/laser-etch?name={code}&mode=flat", "job_id": jid, "code": code,
"input_sha256": sha(data), "output_sha256": sha(res), "output_bytes": len(res)}))