]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
bug fix for sat log --clean
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Mon, 21 Nov 2016 14:34:03 +0000 (15:34 +0100)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Mon, 21 Nov 2016 14:34:03 +0000 (15:34 +0100)
commands/log.py
src/logger.py

index cff2d677e6a6aba952af9d5d4074e1d010f51eab..514e5fa9d7fec6f1afe5273bfe99d96c90511f81 100644 (file)
@@ -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, 
index 9f85f0072944e473c1bbeefb1e503d84723b694e..bf5051ebaaca6f1a15b621280c845d3ffd3f86f3 100644 (file)
@@ -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)