refactor:修改unittest_python的目录名字为client

This commit is contained in:
fumingwei
2021-09-01 16:57:28 +08:00
parent d98faf54b3
commit 94c93bf498
10 changed files with 5 additions and 5 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)