Adjusted crash_gen tool to save old log files, instead of deleting them

This commit is contained in:
Steven Li 2020-07-26 23:32:04 +00:00
parent 032d93b59a
commit 7722eb55ea
1 changed files with 10 additions and 5 deletions

View File

@ -2455,11 +2455,16 @@ class TdeSubProcess:
# Delete the log files
logPath = self.getBuildPath() + "/test/log"
# ref: https://stackoverflow.com/questions/1995373/deleting-all-files-in-a-directory-with-python/1995397
filelist = [ f for f in os.listdir(logPath) ] # if f.endswith(".bak") ]
for f in filelist:
filePath = os.path.join(logPath, f)
print("Removing log file: {}".format(filePath))
os.remove(filePath)
# filelist = [ f for f in os.listdir(logPath) ] # if f.endswith(".bak") ]
# for f in filelist:
# filePath = os.path.join(logPath, f)
# print("Removing log file: {}".format(filePath))
# os.remove(filePath)
logPathSaved = logPath + "_" + time.strftime('%Y-%m-%d-%H-%M-%S')
logger.info("Saving old log files to: {}".format(logPathSaved))
os.rename(logPath, logPathSaved)
os.mkdir(logPath) # recreate
svcCmd = [taosdPath, '-c', cfgPath]
# svcCmd = ['vmstat', '1']