- # Create an instance of xmlLogFile class to create hat.xml file
- xmlHatFilePath = os.path.join(logDir, 'hat.xml')
- xmlHat = xmlLogFile(xmlHatFilePath, "LOGlist", {"application" : application})
- # parse the log directory to find all the command logs, then add it to the xml file
- for fileName in os.listdir(logDir):
- # YYYYMMDD_HHMMSS_namecmd.xml
- sExpr = "^[0-9]{8}_+[0-9]{6}_+.*\.xml$"
- oExpr = re.compile(sExpr)
- if oExpr.search(fileName):
- # get date and hour and format it
- date_hour_cmd = fileName.split('_')
- date_not_formated = date_hour_cmd[0]
- date = "%s/%s/%s" % (date_not_formated[6:8], date_not_formated[4:6], date_not_formated[0:4] )
- hour_not_formated = date_hour_cmd[1]
- hour = "%s:%s:%s" % (hour_not_formated[0:2], hour_not_formated[2:4], hour_not_formated[4:6])
- cmd = date_hour_cmd[2][:-len('.xml')]
- showLog, cmdAppli = showcommandLog(os.path.join(logDir, fileName), cmd, application, notShownCommands)
- #if cmd not in notShownCommands:
- if showLog:
- # add a node to the hat.xml file
- xmlHat.add_simple_node("LogCommand", text=fileName, attrib = {"date" : date, "hour" : hour, "cmd" : cmd, "application" : cmdAppli})