|
|
@@ -2,12 +2,11 @@ import os
|
|
|
import random
|
|
|
import shutil
|
|
|
import string
|
|
|
-import threading
|
|
|
-import time
|
|
|
|
|
|
from datetime import datetime
|
|
|
from openpyxl import load_workbook
|
|
|
from Log import logger
|
|
|
+from main import scheduler
|
|
|
|
|
|
|
|
|
def clear_blank_rows(sheet):
|
|
|
@@ -27,17 +26,14 @@ def copy_data(source_sheet, target_sheet, start_row):
|
|
|
|
|
|
|
|
|
def delete_file_after_delay(file_path, delay_minutes):
|
|
|
- delay_seconds = delay_minutes * 60
|
|
|
-
|
|
|
def delete_file():
|
|
|
- time.sleep(delay_seconds)
|
|
|
try:
|
|
|
if os.path.exists(file_path):
|
|
|
os.remove(file_path)
|
|
|
except Exception as e:
|
|
|
logger.error(f"定时删除Excel文件时发生错误: {e}")
|
|
|
|
|
|
- threading.Thread(target=delete_file).start()
|
|
|
+ scheduler.add_job(delete_file, 'interval', minutes=delay_minutes, id=f"delete_{file_path}")
|
|
|
|
|
|
|
|
|
def run_conformity(file_path, print_path):
|
|
|
@@ -82,7 +78,7 @@ def run_conformity(file_path, print_path):
|
|
|
template_excel.save(output_path)
|
|
|
template_excel.close()
|
|
|
|
|
|
- delete_file_after_delay(output_path, 5)
|
|
|
+ delete_file_after_delay(output_path, 3)
|
|
|
|
|
|
try:
|
|
|
for filename in os.listdir(file_path):
|