You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
report_app/app/tools/get_final_name.py

29 lines
929 B
Python

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import os
import re
import logging
# 获取日志记录器
logger = logging.getLogger(__name__)
def get_final_name(download_dir):
try:
# 判断是否生成日报成功如果成功则转成html返回前端
report_name_dict = {}
if os.listdir(download_dir):
final_files = os.listdir(download_dir)
for file in final_files:
if re.match(r".*简版.*", file):
report_name_dict["report_sim_name"] = download_dir + "/" + file
else:
report_name_dict["report_name"] = download_dir + "/" + file
return report_name_dict["report_sim_name"], report_name_dict["report_name"]
except FileNotFoundError:
logger.exception(f"获取最终日报或简报路径失败:{FileNotFoundError}")
except KeyError:
logger.exception(f"获取最终日报或简报路径失败:{KeyError}")