From: Serge Rehbinder Date: Mon, 21 Nov 2016 14:34:03 +0000 (+0100) Subject: bug fix for sat log --clean X-Git-Tag: 5.0.0a1~38^2~62 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a3c8dc31dc92b4036e37caf684801dccebb4477c;p=tools%2Fsat.git bug fix for sat log --clean --- diff --git a/commands/log.py b/commands/log.py index cff2d67..514e5fa 100644 --- a/commands/log.py +++ b/commands/log.py @@ -52,7 +52,7 @@ def get_last_log_file(logDir, notShownCommands): last = (_, 0) for fileName in os.listdir(logDir): # YYYYMMDD_HHMMSS_namecmd.xml - sExpr = src.logger.logCommandFileExpression + sExpr = src.logger.log_macro_command_file_expression oExpr = re.compile(sExpr) if oExpr.search(fileName): # get date and hour and format it @@ -155,13 +155,14 @@ def run(args, runner, logger): nbClean = options.clean # get the list of files to remove lLogs = src.logger.list_log_file(logDir, - src.logger.logCommandFileExpression) + src.logger.log_all_command_file_expression) nbLogFiles = len(lLogs) # Delete all if the invoked number is bigger than the number of log files if nbClean > nbLogFiles: nbClean = nbLogFiles # Get the list to delete and do the removing lLogsToDelete = sorted(lLogs)[:nbClean] + import pdb;pdb.set_trace() for filePath, __, __, __, __, __, __ in lLogsToDelete: # remove the xml log file remove_log_file(filePath, logger) @@ -218,7 +219,7 @@ def run(args, runner, logger): # Parse the log directory in order to find # all the files corresponding to the commands lLogs = src.logger.list_log_file(logDir, - src.logger.logCommandFileExpression) + src.logger.log_macro_command_file_expression) lLogsFiltered = [] for filePath, __, date, __, hour, cmd in lLogs: showLog, cmdAppli = src.logger.show_command_log(filePath, cmd, diff --git a/src/logger.py b/src/logger.py index 9f85f00..bf5051e 100644 --- a/src/logger.py +++ b/src/logger.py @@ -27,7 +27,8 @@ import src from . import printcolors from . import xmlManager -logCommandFileExpression = "^[0-9]{8}_+[0-9]{6}_+.*\.xml$" +log_macro_command_file_expression = "^[0-9]{8}_+[0-9]{6}_+.*\.xml$" +log_all_command_file_expression = "^.*[0-9]{8}_+[0-9]{6}_+.*\.xml$" class Logger(object): '''Class to handle log mechanism. @@ -325,8 +326,11 @@ def list_log_file(dirPath, expression): sExpr = expression oExpr = re.compile(sExpr) if oExpr.search(fileName): + file_name = fileName + if fileName.startswith("micro_"): + file_name = fileName[len("micro_"):] # get date and hour and format it - date_hour_cmd_host = fileName.split('_') + date_hour_cmd_host = file_name.split('_') date_not_formated = date_hour_cmd_host[0] date = "%s/%s/%s" % (date_not_formated[6:8], date_not_formated[4:6], @@ -363,7 +367,7 @@ def update_hat_xml(logDir, application=None, notShownCommands = []): "LOGlist", {"application" : application}) # parse the log directory to find all the command logs, # then add it to the xml file - lLogFile = list_log_file(logDir, logCommandFileExpression) + lLogFile = list_log_file(logDir, log_macro_command_file_expression) for filePath, __, date, __, hour, cmd, __ in lLogFile: showLog, cmdAppli = show_command_log(filePath, cmd, application, notShownCommands)