#!/usr/bin/env python3 """ extract_proxy.py Run this to write the embedded remote proxy to a standalone file `tools/must_pv1800_proxy.py`. The main script uploads this proxy over SFTP and runs it on the remote host. Usage: python3 tools/extract_proxy.py """ import pathlib import re src = pathlib.Path(__file__).parent.parent / "must_pv1800_monitor.py" text = src.read_text() m = re.search(r"_REMOTE_PROXY_SCRIPT = r'''(.*?)'''", text, re.DOTALL) if not m: raise SystemExit("could not find _REMOTE_PROXY_SCRIPT in must_pv1800_monitor.py") out = pathlib.Path(__file__).parent / "must_pv1800_proxy.py" out.write_text(m.group(1)) out.chmod(0o755) print(f"wrote {out} ({out.stat().st_size} bytes)")