X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Flogger.py;h=260b2ff456cba79674c005be97544e8cdb8a740b;hb=606f9b6618e0e0659d4029c607eaa04d9b3501cc;hp=49a8502c6ba735612736dfb811c7737c4a996013;hpb=e1f36d3ebfb86f289ea0f44542c43db1b752f883;p=tools%2Fsat.git diff --git a/src/logger.py b/src/logger.py index 49a8502..260b2ff 100755 --- a/src/logger.py +++ b/src/logger.py @@ -37,6 +37,8 @@ import src.debug as DBG log_macro_command_file_expression = "^[0-9]{8}_+[0-9]{6}_+.*\.xml$" log_all_command_file_expression = "^.*[0-9]{8}_+[0-9]{6}_+.*\.xml$" +verbose = True # cvw TODO + class Logger(object): """\ Class to handle log mechanism. @@ -144,7 +146,7 @@ class Logger(object): self.config.VARS.user}) # The time when command was launched Y, m, dd, H, M, S = date_to_datetime(self.config.VARS.datehour) - date_hour = "%2s/%2s/%4s %2sh%2sm%2ss" % (dd, m, Y, H, M, S) + date_hour = "%4s/%2s/%2s %2sh%2sm%2ss" % (Y, m, dd, H, M, S) self.xmlFile.append_node_attrib("Site", attrib={"beginTime" : date_hour}) # The application if any @@ -176,7 +178,7 @@ class Logger(object): """ xmlLinks = self.xmlFile.xmlroot.find("Links") flc = src.xmlManager.escapeSequence(full_launched_command) - att = {"command" : command_name, "passed" : command_res, "launchedCommand" : flc} + att = {"command" : command_name, "passed" : str(command_res), "launchedCommand" : flc} src.xmlManager.add_simple_node(xmlLinks, "link", text = log_file_name, attrib = att) def write(self, message, level=None, screenOnly=False): @@ -397,17 +399,22 @@ def show_command_log(logFilePath, cmd, application, notShownCommands): sys.stdout.write(printcolors.printcWarning("%s\n%s\n" % (msg, e))) return False, None, None - if 'application' in logFileXml.xmlroot.keys(): - appliLog = logFileXml.xmlroot.get('application') - launched_cmd = logFileXml.xmlroot.find('Site').attrib['launchedCommand'] - # if it corresponds, then the log has to be shown - if appliLog == application: - return True, appliLog, launched_cmd - elif application != 'None': - return False, appliLog, launched_cmd - - return True, appliLog, launched_cmd - + try: + if 'application' in logFileXml.xmlroot.keys(): + appliLog = logFileXml.xmlroot.get('application') + launched_cmd = logFileXml.xmlroot.find('Site').attrib['launchedCommand'] + # if it corresponds, then the log has to be shown + if appliLog == application: + return True, appliLog, launched_cmd + elif application != 'None': + return False, appliLog, launched_cmd + + return True, appliLog, launched_cmd + except Exception as e: + msg = _("WARNING: the log file %s cannot be parsed:" % logFilePath) + sys.stdout.write(printcolors.printcWarning("%s\n%s\n" % (msg, e))) + return False, None, None + if application == 'None': return True, None, None