1、删除tsg-diagnose rpm包 的preinstall 2、修改unittest_self.py 为tsg_diagnose.py 3、变更tsg_diagnose 生成目录 4、增加定时删除tsg_diagnose结果的定时任务 5、新增安装CIUnitTest python 包

This commit is contained in:
fumingwei
2020-08-28 14:34:18 +08:00
parent 0a648267e2
commit 30f56b252b
6 changed files with 81 additions and 42 deletions

View File

@@ -0,0 +1,43 @@
import os
import sys
import time
import argparse
def get_suite_option():
parser = argparse.ArgumentParser(description="Tsg diagnose Tools - clear tsg diagnose result file", epilog = "Example:help")
parser.add_argument('-t','--timeout', type = int, default = 604800,help='Specify the time to delete files that are not accessed in seconds ,the default is 604800 (7 days)')
parser.add_argument('-d','--dictpath', type = str, default = '/root/result_tsg_diagnose/unittest', help='Specify the folder to delete files, the default is /root/result_tsg_diagnose/unittest')
args = parser.parse_args()
return args
def clear_dict_file(dictpath, timeout):
try:
files = os.listdir(dictpath)
if not files:
print("The directory not exist, the process will exit")
sys.exit(0)
for file in files:
filePath = dictpath + "/" + file
if os.path.isfile(filePath):
last = int(os.stat(filePath).st_mtime)
now = int(time.time())
if (now - last >= timeout):
os.remove(filePath)
print(filePath + " was removed!")
elif os.path.isdir(filePath):
clear_dict_file(filePath,timeout)
if not os.listdir(filePath):
os.rmdir(filePath)
except Exception as ex:
print("Process get an exception, will exit, Exception info: ", ex)
sys.stdout.write(str(ex))
sys.exit(1)
if __name__ == '__main__':
args = get_suite_option()
timeout = args.timeout
dictpath = args.dictpath
clear_dict_file(dictpath, timeout)