X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=salomeTools.py;h=30a3697146d487234b7305c021d25b05f12b5a2c;hb=f937509b54c4d8bfdf530733f8bda4a61c773727;hp=742bc70bf919f63be8f0049a3a9c92bad063fac2;hpb=67bd1be88056438fb6200460003680dbf65e21d2;p=tools%2Fsat.git diff --git a/salomeTools.py b/salomeTools.py index 742bc70..30a3697 100755 --- a/salomeTools.py +++ b/salomeTools.py @@ -90,7 +90,6 @@ class Sat(object): self.cfg = None # the config that will be read using pyconf module self.options = options # the options passed to salomeTools self.dataDir = dataDir # default value will be /data - self.logger = None # set the commands by calling the dedicated function self.__setCommands__(cmdsdir) @@ -124,7 +123,7 @@ class Sat(object): (file_, pathname, description) = imp.find_module(nameCmd, [dirPath]) module = imp.load_module(nameCmd, file_, pathname, description) - def run_command(args=''): + def run_command(args='', logger=None): '''The function that will load the configuration (all pyconf) and return the function run of the command corresponding to module @@ -138,22 +137,28 @@ class Sat(object): appliToLoad = argv[0].rstrip('*') argv = argv[1:] - # Read the config if it is not already done - if not self.cfg: - # read the configuration from all the pyconf files - cfgManager = config.ConfigManager() - self.cfg = cfgManager.getConfig(dataDir=self.dataDir, application=appliToLoad, options=self.options, command=__nameCmd__) + # read the configuration from all the pyconf files + cfgManager = config.ConfigManager() + self.cfg = cfgManager.getConfig(dataDir=self.dataDir, application=appliToLoad, options=self.options, command=__nameCmd__) - # set output level - if self.options.output_level: - self.cfg.USER.output_level = self.options.output_level - if self.cfg.USER.output_level < 1: - self.cfg.USER.output_level = 1 + # set output level + if self.options.output_level: + self.cfg.USER.output_level = self.options.output_level + if self.cfg.USER.output_level < 1: + self.cfg.USER.output_level = 1 - # create log file - self.logger = src.logger.Logger(self.cfg, silent_sysstd=self.options.silent) + # create log file, unless the command is called with a logger as parameter + logger_command = src.logger.Logger(self.cfg, silent_sysstd=self.options.silent) + if logger: + logger_command = logger - return __module__.run(argv, self) + # Execute the run method of the command + res = __module__.run(argv, self, logger_command) + + # put final attributes in xml log file (end time, total time, ...) and write it + logger_command.endWrite() + + return res # Make sure that run_command will be redefined at each iteration of the loop globals_up = {}