feat: STF设备管理彻底删除(脚本+断开+STF API清记录)+ 一键重连(后台跑connect脚本)+ 跳过原因日志区分离线/未就绪 + SSH超时错误分类
This commit is contained in:
@@ -131,3 +131,28 @@ def remove_device(ip):
|
||||
msgs.append(out.strip() or (f"adb disconnect 执行完成(exit {code})" if code == 0 else "adb disconnect 无输出"))
|
||||
_log.info(f"STF 移除设备 {ip}: {msgs}")
|
||||
return msgs
|
||||
|
||||
|
||||
def delete_device(ip, stf=None):
|
||||
"""彻底删除设备:脚本移除 + disconnect + 清 STF 池记录(幽灵设备)。"""
|
||||
msgs = remove_device(ip)
|
||||
if stf is not None:
|
||||
ok, msg = stf.delete_device(f"{_norm_ip(ip)}:5555")
|
||||
msgs.append(msg)
|
||||
_log.info(f"STF 彻底删除设备 {ip}: {msgs}")
|
||||
return msgs
|
||||
|
||||
|
||||
def reconnect_all():
|
||||
"""一键重连:后台运行 220 的 connect_devices.sh(cron 之外的立即补连)。
|
||||
|
||||
脚本对未连接设备逐个 connect(不可达设备可能挂 40s+),全程可能 1-3 分钟,
|
||||
因此 nohup 后台执行立即返回,不阻塞请求;结果用"刷新"看设备连接状态。
|
||||
"""
|
||||
cmd = (f"nohup bash {shlex.quote(STF_SCRIPT_PATH)} >/tmp/connect_devices.out 2>&1 &")
|
||||
code, out, err = _ssh(cmd, timeout=15)
|
||||
if code != 0:
|
||||
raise StfDevError(f"启动重连失败: {err.strip() or out.strip()}")
|
||||
_log.info("STF 一键重连已在 220 后台启动")
|
||||
return True, ("重连已在 220 后台执行(对未连接设备逐个 connect,约 1-3 分钟),"
|
||||
"稍后点\"刷新\"查看设备连接状态")
|
||||
|
||||
Reference in New Issue
Block a user