fix(heartFC_Cycleinfo): 添加目录创建失败时的异常处理和备用方案
当目录创建失败时,捕获异常并打印错误信息,同时将日志文件写入到temp目录下作为备用方案
This commit is contained in:
@@ -98,7 +98,12 @@ class CycleDetail:
|
|||||||
# 如果目录不存在,则创建目录
|
# 如果目录不存在,则创建目录
|
||||||
dir_name = os.path.dirname(file_path)
|
dir_name = os.path.dirname(file_path)
|
||||||
if dir_name and not os.path.exists(dir_name):
|
if dir_name and not os.path.exists(dir_name):
|
||||||
os.makedirs(dir_name, exist_ok=True)
|
try:
|
||||||
|
os.makedirs(dir_name, exist_ok=True)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"创建目录 {dir_name} 失败: {e}")
|
||||||
|
print(f"日志将会写入到temp目录下")
|
||||||
|
file_path = os.path.join("temp", os.path.basename(file_path))
|
||||||
# 写入文件
|
# 写入文件
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user