mirror of
https://github.com/KenanZhu/AutoLibrary.git
synced 2026-06-18 15:33:03 +08:00
fix(ALMainWorkers): 修复 AutoLibWorker 中基础检查未通过时,运行线程错误返回导致结束信号未发送的问题
This commit is contained in:
+28
-28
@@ -44,8 +44,7 @@ class AutoLibWorker(QThread, MsgBase):
|
|||||||
current_time = time.strftime("%H:%M", time.localtime())
|
current_time = time.strftime("%H:%M", time.localtime())
|
||||||
if current_time >= "23:30" or current_time <= "07:30":
|
if current_time >= "23:30" or current_time <= "07:30":
|
||||||
self._showTrace(
|
self._showTrace(
|
||||||
"当前时间不在图书馆开放时间内\n"\
|
"当前时间不在图书馆开放时间内, 请在 07:30 - 23:30 之间尝试"
|
||||||
" 请在 07:30 - 23:30 之间尝试"
|
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
@@ -58,7 +57,7 @@ class AutoLibWorker(QThread, MsgBase):
|
|||||||
if not all(
|
if not all(
|
||||||
os.path.exists(path) for path in self.__config_paths.values()
|
os.path.exists(path) for path in self.__config_paths.values()
|
||||||
):
|
):
|
||||||
self._showTrace("配置文件路径不存在, 请检查配置文件路径是否正确。")
|
self._showTrace("配置文件路径不存在, 请检查配置文件路径是否正确")
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -96,32 +95,33 @@ class AutoLibWorker(QThread, MsgBase):
|
|||||||
):
|
):
|
||||||
|
|
||||||
auto_lib = None
|
auto_lib = None
|
||||||
try:
|
self._showTrace("AutoLibrary 开始运行")
|
||||||
if not self.checkTimeAvailable():
|
if not self.checkTimeAvailable()\
|
||||||
return
|
or not self.checkConfigPaths():
|
||||||
if not self.checkConfigPaths():
|
# time or config existence check failed, skip and finish
|
||||||
return
|
pass
|
||||||
self._showTrace("AutoLibrary 开始运行")
|
else:
|
||||||
if not self.loadConfigs():
|
try:
|
||||||
raise Exception("配置文件加载失败")
|
if not self.loadConfigs():
|
||||||
auto_lib = AutoLib(
|
raise Exception("配置文件加载失败")
|
||||||
self._input_queue,
|
auto_lib = AutoLib(
|
||||||
self._output_queue,
|
self._input_queue,
|
||||||
self.__run_config
|
self._output_queue,
|
||||||
)
|
self.__run_config
|
||||||
groups = self.__user_config.get("groups")
|
|
||||||
for group in groups:
|
|
||||||
if not group["enabled"]:
|
|
||||||
self._showTrace(f"任务组 {group["name"]} 已跳过")
|
|
||||||
continue
|
|
||||||
self._showTrace(f"正在运行任务组 {group["name"]}")
|
|
||||||
auto_lib.run(
|
|
||||||
{ "users": group.get("users", []) }
|
|
||||||
)
|
)
|
||||||
except Exception as e:
|
groups = self.__user_config.get("groups")
|
||||||
self._showTrace(f"AutoLibrary 运行时发生异常 : {e}")
|
for group in groups:
|
||||||
self.finishedWithErrorSignal.emit()
|
if not group["enabled"]:
|
||||||
return
|
self._showTrace(f"任务组 {group["name"]} 已跳过")
|
||||||
|
continue
|
||||||
|
self._showTrace(f"正在运行任务组 {group["name"]}")
|
||||||
|
auto_lib.run(
|
||||||
|
{ "users": group.get("users", []) }
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
self._showTrace(f"AutoLibrary 运行时发生异常 : {e}")
|
||||||
|
self.finishedWithErrorSignal.emit()
|
||||||
|
return
|
||||||
if auto_lib:
|
if auto_lib:
|
||||||
auto_lib.close()
|
auto_lib.close()
|
||||||
self._showTrace("AutoLibrary 运行结束")
|
self._showTrace("AutoLibrary 运行结束")
|
||||||
|
|||||||
Reference in New Issue
Block a user