重构添加统一异常处理

This commit is contained in:
xinzhu.yin
2026-04-20 15:34:45 +08:00
parent 2e92b48496
commit b1b14c2d49
8 changed files with 114 additions and 61 deletions

View File

@@ -72,30 +72,26 @@ def check_com_connections(self):
try:
# 检测TV连接
ucd_connected = self.check_port_connection(is_ucd=True)
self.root.after(
0,
lambda: self.update_connection_indicator(
self.ucd_status_indicator, ucd_connected
),
self._dispatch_ui(
self.update_connection_indicator,
self.ucd_status_indicator, ucd_connected,
)
# 检测CA连接
ca_connected = self.check_port_connection(is_ucd=False)
self.root.after(
0,
lambda: self.update_connection_indicator(
self.ca_status_indicator, ca_connected
),
self._dispatch_ui(
self.update_connection_indicator,
self.ca_status_indicator, ca_connected,
)
# 更新状态栏
self.root.after(0, lambda: self.status_var.set("连接检测完成"))
self._dispatch_ui(self.status_var.set, "连接检测完成")
# 重新启用所有控件
self.root.after(0, self.enable_com_widgets)
self._dispatch_ui(self.enable_com_widgets)
except Exception as e:
self.root.after(0, lambda: self.log_gui.log(f"连接检测出错: {e}"))
self.root.after(0, self.enable_com_widgets)
self._dispatch_ui(self.log_gui.log, f"连接检测出错: {e}")
self._dispatch_ui(self.enable_com_widgets)
# 启动线程
threading.Thread(target=check_connections, daemon=True).start()