You've already forked FrameTour-RenderWorker
							
							定时清理目录下无用文件
This commit is contained in:
		
							
								
								
									
										27
									
								
								index.py
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user