# -*- coding: utf-8 -*- r'''等 2 小时长测跑完,中途定期报告进度。 用法: python _build/rp_wait.py [总等待秒数] [检查间隔秒数] ''' from __future__ import annotations import sys import time from pathlib import Path sys.path.insert(0, str(Path(__file__).parent)) from devssh import run # noqa: E402 def once(label: str) -> None: out = run("bash /root/rppg.sh 2>&1", timeout=300)[1] print(" ────── %s ──────" % label) # 只留关键行 for line in out.splitlines(): s = line.strip() if not s: continue if any(k in s for k in ("样本数", "已完成", "状态码", "最近 3 条", "非 200", "时间", "测试进程", "rp_long2h", "rpp30", "200", "000", "502", "530", "quic=", "http2=", "明细", "输出日志")): print(" " + s) print() def main() -> int: total = int(sys.argv[1]) if len(sys.argv) > 1 else 3600 every = int(sys.argv[2]) if len(sys.argv) > 2 else 900 waited = 0 n = 0 while waited < total: step = min(every, total - waited) time.sleep(step) waited += step n += 1 once("检查点 %d(已等 %d 分钟)" % (n, waited // 60)) return 0 if __name__ == "__main__": sys.exit(main())