28 lines
1.9 KiB
Python
28 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""meili_drive.py push | run <template> <label> <EVDIR> [collect_s] — from DooPlex: push the R-1338 tools (+ the capped
|
|
definition as /opt/upg/templates/wanderer-meili) to the bench, run meili_bench.py there, copy its evidence back."""
|
|
import base64, importlib.util, io, os, sys, tarfile
|
|
H = "/mnt/5_hdd/felhom.eu/git/app-catalog-felhom.eu/scripts"
|
|
SP = "/tmp/claude-1000/-mnt-5-hdd-felhom-eu-git/0b76c4d7-9b39-4e4e-869d-d0d2c6006331/scratchpad"
|
|
EVB = SP + "/night/bench"
|
|
spec = importlib.util.spec_from_file_location("rf", os.path.join(H, "retest-floating.py"))
|
|
rf = importlib.util.module_from_spec(spec); sys.path.insert(0, H); spec.loader.exec_module(rf)
|
|
if sys.argv[1] == "push":
|
|
b = io.BytesIO()
|
|
with tarfile.open(fileobj=b, mode="w:gz") as t:
|
|
t.add(EVB + "/tools/meili_bench.py", arcname="meili_bench.py")
|
|
t.add(EVB + "/meili_collect.sh", arcname="meili_collect.sh")
|
|
t.add(SP + "/defs/wanderer-meili", arcname="templates/wanderer-meili")
|
|
r = rf.bench("cd /opt/upg && base64 -d > /tmp/m.tgz <<'B64'\n%s\nB64\ntar xzf /tmp/m.tgz && rm -f /tmp/m.tgz && ls -a templates/wanderer-meili && echo pushed"
|
|
% base64.b64encode(b.getvalue()).decode(), timeout=300)
|
|
print(r.stdout, r.stderr[-300:]); sys.exit(0 if "pushed" in r.stdout else 1)
|
|
tdir, label, ev = sys.argv[2:5]
|
|
cs = sys.argv[5] if len(sys.argv) > 5 else "600"
|
|
os.makedirs(ev, exist_ok=True)
|
|
r = rf.bench("cd /opt/upg && rm -rf evidence/R1338-%s && timeout 2400 python3 meili_bench.py %s %s %s > /opt/upg/R1338-%s.log 2>&1; echo rc=$?"
|
|
% (label, tdir, label, cs, label), timeout=2600)
|
|
print(r.stdout.strip()[-300:], r.stderr.strip()[-300:])
|
|
pull = rf.bench("cd /opt/upg && tar czf - R1338-%s.log evidence/R1338-%s 2>/dev/null | base64 -w0" % (label, label), timeout=600)
|
|
tarfile.open(fileobj=io.BytesIO(base64.b64decode(pull.stdout.strip()))).extractall(ev)
|
|
print("evidence ->", ev)
|