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
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)
# 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,
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.
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],
"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)