From 407d25570a5444f53e35b59f5211b81807706971 Mon Sep 17 00:00:00 2001 From: KenanZhu <3471685733@qq.com> Date: Fri, 2 Jan 2026 00:30:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(ALMainWorkers):=20=E4=BF=AE=E5=A4=8D=20Auto?= =?UTF-8?q?LibWorker=20=E4=B8=AD=E5=9F=BA=E7=A1=80=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E6=9C=AA=E9=80=9A=E8=BF=87=E6=97=B6=EF=BC=8C=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E9=94=99=E8=AF=AF=E8=BF=94=E5=9B=9E=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=BB=93=E6=9D=9F=E4=BF=A1=E5=8F=B7=E6=9C=AA=E5=8F=91?= =?UTF-8?q?=E9=80=81=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gui/ALMainWorkers.py | 56 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/gui/ALMainWorkers.py b/src/gui/ALMainWorkers.py index 6452094..f49686a 100644 --- a/src/gui/ALMainWorkers.py +++ b/src/gui/ALMainWorkers.py @@ -44,8 +44,7 @@ class AutoLibWorker(QThread, MsgBase): current_time = time.strftime("%H:%M", time.localtime()) if current_time >= "23:30" or current_time <= "07:30": self._showTrace( - "当前时间不在图书馆开放时间内\n"\ - " 请在 07:30 - 23:30 之间尝试" + "当前时间不在图书馆开放时间内, 请在 07:30 - 23:30 之间尝试" ) return False return True @@ -58,7 +57,7 @@ class AutoLibWorker(QThread, MsgBase): if not all( os.path.exists(path) for path in self.__config_paths.values() ): - self._showTrace("配置文件路径不存在, 请检查配置文件路径是否正确。") + self._showTrace("配置文件路径不存在, 请检查配置文件路径是否正确") return False return True @@ -96,32 +95,33 @@ class AutoLibWorker(QThread, MsgBase): ): auto_lib = None - try: - if not self.checkTimeAvailable(): - return - if not self.checkConfigPaths(): - return - self._showTrace("AutoLibrary 开始运行") - if not self.loadConfigs(): - raise Exception("配置文件加载失败") - auto_lib = AutoLib( - self._input_queue, - 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", []) } + self._showTrace("AutoLibrary 开始运行") + if not self.checkTimeAvailable()\ + or not self.checkConfigPaths(): + # time or config existence check failed, skip and finish + pass + else: + try: + if not self.loadConfigs(): + raise Exception("配置文件加载失败") + auto_lib = AutoLib( + self._input_queue, + self._output_queue, + self.__run_config ) - except Exception as e: - self._showTrace(f"AutoLibrary 运行时发生异常 : {e}") - self.finishedWithErrorSignal.emit() - return + 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: + self._showTrace(f"AutoLibrary 运行时发生异常 : {e}") + self.finishedWithErrorSignal.emit() + return if auto_lib: auto_lib.close() self._showTrace("AutoLibrary 运行结束")