tiandytdd

This commit is contained in:
Ankle committed 2026-09-15 11:32:36 +08:00
1 parent ddea6d0578
commit 5746fa10db
5 files changed
+122 -20

No files matched your search

+33 -13
View File
@@ -10,6 +10,7 @@ from datetime import datetime
import io
import json
import math
import os
from pathlib import Path
import re
import select
@@ -906,16 +907,33 @@ def deploy_config(scan: dict) -> None:
finally:
local_temp.unlink(missing_ok=True)
subprocess.run(["docker", "restart", "smart-cam"], check=True,
stdout=subprocess.DEVNULL)
deadline = time.monotonic() + 90
while time.monotonic() < deadline:
try:
core.api("GET", "/api/v1/scan/status", timeout=5)
return
except (SystemExit, subprocess.SubprocessError):
time.sleep(2)
raise RuntimeError("smart-cam重启后90秒内scan HTTP服务未就绪")
unit = subprocess.run(
["systemctl", "show", "-p", "LoadState", "--value", "smart-cam.service"],
text=True, capture_output=True,
)
if unit.returncode == 0 and unit.stdout.strip() == "loaded":
restart = ["systemctl", "restart", "smart-cam.service"]
if os.geteuid() != 0:
restart = ["sudo", "-n", *restart]
result = subprocess.run(restart, text=True, capture_output=True)
if result.returncode:
detail = result.stderr.strip() or result.stdout.strip()
raise RuntimeError(
"宿主机由smart-cam.service管理容器,但无法通过systemd重启。"
"请使用root执行本向导,或为systemctl restart smart-cam.service配置sudo权限。"
f"\n{detail}"
)
else:
subprocess.run(
["docker", "restart", "smart-cam"], check=True,
stdout=subprocess.DEVNULL,
)
if not core.wait_for_scan_http_stable(timeout=180, stable_seconds=15):
raise RuntimeError(
"smart-cam重启后未能连续稳定运行15秒。请执行 "
"systemctl status smart-cam.service 和 docker logs --tail 100 smart-cam 查因。"
)
def run_test_scan() -> dict:
@@ -1068,9 +1086,11 @@ def acquire_calibration_control() -> bool:
say("已临时暂停巡航;标定结束或正常中断时会自动恢复。", color=YELLOW)
try:
# This is a synchronization barrier: GET waits behind any PTZ command
# already in flight when patrol was paused, then claims manual control.
core.get_ptz()
# This synchronization barrier waits behind the one PTZ command that
# was already in flight when patrol was paused. Tiandy emulated
# absolute moves can legitimately take up to 135 seconds.
say("正在等待已暂停巡航的最后一条PTZ指令结束……")
core.get_ptz(timeout=160)
except BaseException:
if should_resume:
try: