"""Set a mark on an app's ladder entry N in the DRILL catalog, commit, push, and wait for the box's clone. Usage: python3 drillmark.py ''""" import json, sys, subprocess, time import walk as w app, idx, marks = sys.argv[1], int(sys.argv[2]), json.loads(sys.argv[3]) p = f"{w.DRILL}/templates/{app}/.felhom.yml" w.sh(["git", "-C", w.DRILL, "pull", "-q", "--rebase", "origin", "main"], timeout=120) lines = open(p).read().split("\n") i = lines.index("update_ladder:") + 1 + idx e = json.loads(lines[i][4:]); e["marks"] = marks lines[i] = " - " + json.dumps(e, ensure_ascii=False) open(p, "w").write("\n".join(lines)) w.sh(["git", "-C", w.DRILL, "commit", "-qam", f"NIGHT-C {app} step {idx+1} marks {json.dumps(marks)}"]) w.sh(["git", "-C", w.DRILL, "push", "-q", "origin", "main"], timeout=120) head = w.sh(["git", "-C", w.DRILL, "rev-parse", "--short", "HEAD"]).stdout.strip() w.login() for k in range(40): w.sync_rescan() got = w.guest("cd /var/lib/docker/volumes/felhom-controller-data/_data/data/catalog-cache && git rev-parse --short HEAD").strip() if got == head: print(f"{app} step {idx+1} marks={marks}; box clone at {head} after {k+1} sync(s)"); break time.sleep(8) else: sys.exit("box never caught up to " + head)