Salome HOME
projects
/
tools
/
sat.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bug fix: sat generate
[tools/sat.git]
/
src
/
logger.py
diff --git
a/src/logger.py
b/src/logger.py
index 3e1e5a1ab3e9d36b1e8e8812712b8bb6f3ee6724..419b878642ab5215bd87aa3b7f313055d974bd80 100644
(file)
--- a/
src/logger.py
+++ b/
src/logger.py
@@
-32,7
+32,11
@@
logCommandFileExpression = "^[0-9]{8}_+[0-9]{6}_+.*\.xml$"
class Logger(object):
'''Class to handle log mechanism.
'''
class Logger(object):
'''Class to handle log mechanism.
'''
- def __init__(self, config, silent_sysstd=False, all_in_terminal=False):
+ def __init__(self,
+ config,
+ silent_sysstd=False,
+ all_in_terminal=False,
+ micro_command = False):
'''Initialization
:param config pyconf.Config: The global configuration.
'''Initialization
:param config pyconf.Config: The global configuration.
@@
-44,12
+48,16
@@
class Logger(object):
self.silentSysStd = silent_sysstd
# Construct xml log file location for sat prints.
self.silentSysStd = silent_sysstd
# Construct xml log file location for sat prints.
- logFileName = config.VARS.datehour + "_" + config.VARS.command + ".xml"
- logFilePath = os.path.join(config.SITE.log.log_dir, logFileName)
+ prefix = ""
+ if micro_command:
+ prefix = "micro_"
+ hour_command = config.VARS.datehour + "_" + config.VARS.command
+ logFileName = prefix + hour_command + ".xml"
+ logFilePath = os.path.join(config.USER.log_dir, logFileName)
# Construct txt file location in order to log
# the external commands calls (cmake, make, git clone, etc...)
# Construct txt file location in order to log
# the external commands calls (cmake, make, git clone, etc...)
- txtFileName =
config.VARS.datehour + "_" + config.VARS.
command + ".txt"
- txtFilePath = os.path.join(config.
SITE.log
.log_dir, "OUT", txtFileName)
+ txtFileName =
prefix + hour_
command + ".txt"
+ txtFilePath = os.path.join(config.
USER
.log_dir, "OUT", txtFileName)
src.ensure_path_exists(os.path.dirname(logFilePath))
src.ensure_path_exists(os.path.dirname(txtFilePath))
src.ensure_path_exists(os.path.dirname(logFilePath))
src.ensure_path_exists(os.path.dirname(txtFilePath))
@@
-164,6
+172,7
@@
class Logger(object):
else:
if self.default_level <= current_output_verbose_level and not self.silentSysStd:
sys.stdout.write(message)
else:
if self.default_level <= current_output_verbose_level and not self.silentSysStd:
sys.stdout.write(message)
+ self.flush()
def error(self, message):
'''Print an error.
def error(self, message):
'''Print an error.
@@
-218,7
+227,7
@@
class Logger(object):
self.xmlFile.write_tree(stylesheet = "command.xsl")
# Dump the config in a pyconf file in the log directory
self.xmlFile.write_tree(stylesheet = "command.xsl")
# Dump the config in a pyconf file in the log directory
- logDir = self.config.
SITE.log
.log_dir
+ logDir = self.config.
USER
.log_dir
dumpedPyconfFileName = (self.config.VARS.datehour
+ "_"
+ self.config.VARS.command
dumpedPyconfFileName = (self.config.VARS.datehour
+ "_"
+ self.config.VARS.command
@@
-278,7
+287,12
@@
def show_command_log(logFilePath, cmd, application, notShownCommands):
return False, None
# Get the application of the log file
return False, None
# Get the application of the log file
- logFileXml = src.xmlManager.ReadXmlFile(logFilePath)
+ try:
+ logFileXml = src.xmlManager.ReadXmlFile(logFilePath)
+ except Exception as e:
+ msg = _("WARNING: the log file %s cannot be read:" % logFilePath)
+ sys.stdout.write(printcolors.printcWarning("%s\n%s\n" % (msg, e)))
+ return False, None
if 'application' in logFileXml.xmlroot.keys():
appliLog = logFileXml.xmlroot.get('application')
if 'application' in logFileXml.xmlroot.keys():
appliLog = logFileXml.xmlroot.get('application')