Files
propresenter-auto-notes/tools/remote_measure.py
T

24 lines
1.1 KiB
Python
Raw Normal View History

2026-10-13 15:58:03 -04:00
"""Dev helper: run measure.JXA on the ProPresenter Mac (via the ingest Mac) from a laptop."""
import json, os, subprocess, sys, tempfile
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "src"))
import measure as M
HOP = "checklist-ingest"
PROP = "napropresenter@10.1.14.225"
KEY = "~/.ssh/id_status_panel"
def measure(items):
if not items:
return []
payload = json.dumps([{"rtf": it["rtf"].decode("latin-1"), "w": it["w"]} for it in items])
script = M.JXA
remote = ("d=$(mktemp -d); cat > $d/in.json; printf '%%s' %s | base64 -D > $d/m.js; "
"osascript -l JavaScript $d/m.js $d/in.json; rm -rf $d") % (
__import__("shlex").quote(__import__("base64").b64encode(script.encode()).decode()))
cmd = ["ssh", HOP, "ssh -i %s -o BatchMode=yes %s %s" % (KEY, PROP, __import__("shlex").quote(remote))]
p = subprocess.run(cmd, input=payload, capture_output=True, text=True, timeout=300)
if p.returncode != 0 or not p.stdout.strip():
raise M.Unavailable(p.stderr[-500:])
return json.loads(p.stdout)