Commit f6039234ff19f8b0f2c0056184842d0cc40fc8d3
1 parent
d00a57b2
增加执行环境判断
Showing
1 changed file
with
7 additions
and
3 deletions
commons/scripts/delReport.py
... | ... | @@ -13,14 +13,18 @@ import os,sys |
13 | 13 | |
14 | 14 | def delReport(path,delNum=5): |
15 | 15 | print("path",path) |
16 | - file_list = os.listdir(os.path.abspath(os.path.join(path, "../")) + "/report/") | |
16 | + if os.name == "nt": | |
17 | + report_route = os.path.abspath(os.path.join(path, "../")) | |
18 | + else: | |
19 | + report_route = os.path.abspath(os.path.join(path)) | |
20 | + file_list = os.listdir(report_route + "/report/") | |
17 | 21 | print("delReport file_lis --- ", file_list) |
18 | 22 | if len(file_list) > delNum: |
19 | 23 | file_list = file_list[:0-delNum] |
20 | 24 | print("if file_lis --- ",file_list) |
21 | 25 | for i in file_list: |
22 | - if os.path.isfile(os.path.abspath(os.path.join(path, "../")) + "/report/" + i) and ".log" not in i: | |
23 | - os.remove(os.path.abspath(os.path.join(path, "../")) + "/report/" + i) | |
26 | + if os.path.isfile(report_route + "/report/" + i) and ".log" not in i: | |
27 | + os.remove(report_route + "/report/" + i) | |
24 | 28 | print(f"删除报告 {i} 成功") |
25 | 29 | # 文件已删除 |
26 | 30 | print("多余的报告文件已删除") | ... | ... |