From 358207efdc54afb64bd68500741064d51464cfb0 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Sun, 16 Feb 2025 18:15:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E6=B8=85=E7=90=86=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E4=B8=8B=E6=97=A0=E7=94=A8=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/index.py b/index.py index 09197b7..84e4958 100644 --- a/index.py +++ b/index.py @@ -5,15 +5,36 @@ import config from template import load_local_template from util import api -load_local_template() +import os +import glob +load_local_template() +import logging + +LOGGER = logging.getLogger(__name__) while True: # print(get_sys_info()) print("waiting for task...") - task_list = api.sync_center() + try: + task_list = api.sync_center() + except Exception as e: + LOGGER.error("sync_center error", exc_info=e) + sleep(5) + continue if len(task_list) == 0: + # 删除当前文件夹下所有以.mp4、.ts结尾的文件 + for file_globs in ['*.mp4', '*.ts', 'tmp_concat*.txt']: + for file_path in glob.glob(file_globs): + try: + os.remove(file_path) + print(f"Deleted file: {file_path}") + except Exception as e: + LOGGER.error(f"Error deleting file {file_path}", exc_info=e) sleep(5) for task in task_list: print("start task:", task) - biz.task.start_task(task) + try: + biz.task.start_task(task) + except Exception as e: + LOGGER.error("task_start error", exc_info=e)