Commit 6cac0f7d1f7c1c145f1c6148e3dcbe7e36b6ceb0

Authored by liujiqiang
1 parent 6b798ce0

更新

Showing 1 changed file with 6 additions and 4 deletions
commons/scripts/delReport.py
@@ -18,15 +18,17 @@ def path_route(path): @@ -18,15 +18,17 @@ def path_route(path):
18 return path 18 return path
19 19
20 def delReport(path,delNum=5): 20 def delReport(path,delNum=5):
21 - project_path = path_route(path)  
22 - file_list = os.listdir(project_path + "/report/") 21 + report_path = path_route(path) + "/report/"
  22 + file_list = os.listdir(report_path)
23 print("delReport file_lis --- ", file_list) 23 print("delReport file_lis --- ", file_list)
24 if len(file_list) > delNum: 24 if len(file_list) > delNum:
  25 + file_list.sort(key=lambda file_name: os.path.getmtime(report_path + "\\" + file_name))
  26 + print(file_list)
25 file_list = file_list[:0-delNum] 27 file_list = file_list[:0-delNum]
26 # print("if file_lis --- ",file_list) 28 # print("if file_lis --- ",file_list)
27 for i in file_list: 29 for i in file_list:
28 - if os.path.isfile(project_path + "/report/" + i) and ".html" in i:  
29 - os.remove(project_path + "/report/" + i) 30 + if os.path.isfile(report_path + i) and ".html" in i:
  31 + os.remove(report_path + i)
30 print(f"删除报告 {i} 成功") 32 print(f"删除报告 {i} 成功")
31 # 文件已删除 33 # 文件已删除
32 print("多余的报告文件已删除") 34 print("多余的报告文件已删除")