15 lines
889 B
Python
15 lines
889 B
Python
#!/usr/bin/env python3
|
|
"""offpoll.py N SECONDS — print the off-site run's own status (the page's /backup/offbox/status) every SECONDS, N times."""
|
|
import json, os, sys, time
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))); import ctl
|
|
for i in range(int(sys.argv[1])):
|
|
t = time.strftime("%H:%M:%SZ", time.gmtime())
|
|
try:
|
|
c, d = ctl.call("GET", "/backup/offbox/status", timeout=90)
|
|
p = d.get("progress") or {}
|
|
print(t, d.get("status"), f"phase={p.get('phase')} app={p.get('current_app')} {p.get('percent')}% {p.get('done_human')}/{p.get('total_human')}"
|
|
f" files {p.get('files_done')}/{p.get('total_files')} snaps={d.get('snapshots')} last_err={str(d.get('last_error'))[:160]!r}", flush=True)
|
|
except Exception as e: # noqa: BLE001
|
|
print(t, "NO ANSWER", type(e).__name__, flush=True)
|
|
time.sleep(int(sys.argv[2]))
|