43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
from time import sleep
|
|
|
|
import biz.task
|
|
import config
|
|
from telemetry import init_opentelemetry
|
|
from template import load_local_template
|
|
from util import api
|
|
|
|
import os
|
|
import glob
|
|
|
|
load_local_template()
|
|
import logging
|
|
|
|
LOGGER = logging.getLogger(__name__)
|
|
init_opentelemetry()
|
|
|
|
while True:
|
|
# print(get_sys_info())
|
|
print("waiting for task...")
|
|
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)
|
|
try:
|
|
biz.task.start_task(task)
|
|
except Exception as e:
|
|
LOGGER.error("task_start error", exc_info=e)
|