return _("The config command allows manipulation and operation on config files.")
-def run(args, runner):
+def run(args, runner, logger):
'''method that is called when salomeTools is called with config parameter.
'''
# Parse the options
if options.value == ".":
# if argument is ".", print all the config
for val in sorted(runner.cfg.keys()):
- print_value(runner.cfg, val, True, runner.logger)
+ print_value(runner.cfg, val, True, logger)
else:
- print_value(runner.cfg, options.value, True, runner.logger, level=0, show_full_path=False)
+ print_value(runner.cfg, options.value, True, logger, level=0, show_full_path=False)
# case : edit user pyconf file or application file
elif options.edit:
# perform the copy
shutil.copyfile(source_full_path, dest_file)
- runner.logger.write(_("%s has been created.\n") % dest_file)
+ logger.write(_("%s has been created.\n") % dest_file)
# case : display all the available pyconf applications
elif options.list:
# search in all directories that can have pyconf applications
for path in runner.cfg.SITE.config.configPath:
# print a header
- runner.logger.write("------ %s\n" % src.printcolors.printcHeader(path))
+ logger.write("------ %s\n" % src.printcolors.printcHeader(path))
if not os.path.exists(path):
- runner.logger.write(src.printcolors.printcError(_("Directory not found")) + "\n")
+ logger.write(src.printcolors.printcError(_("Directory not found")) + "\n")
else:
for f in sorted(os.listdir(path)):
# ignore file that does not ends with .pyconf
if appliname not in lproduct:
lproduct.append(appliname)
if path.startswith(runner.cfg.VARS.personalDir):
- runner.logger.write("%s*\n" % appliname)
+ logger.write("%s*\n" % appliname)
else:
- runner.logger.write("%s\n" % appliname)
+ logger.write("%s\n" % appliname)
- runner.logger.write("\n")
+ logger.write("\n")
\ No newline at end of file
def description():
return _("Gives access to logs of salomeTools.")
-def run(args, runner):
+def run(args, runner, logger):
(options, args) = parser.parse_args(args)
# get the log directory. If there is an application, it is in cfg.APPLICATION.out_dir, else in user directory
cmd = date_hour_cmd[2][:-len('.xml')]
num = src.printcolors.printcLabel("%2d" % (nb_logs - index))
- runner.logger.write("%s: %13s %s %s\n" % (num, cmd, date, hour), 1, False)
+ logger.write("%s: %13s %s %s\n" % (num, cmd, date, hour), 1, False)
index += 1
# ask the user
if x > 0:
index = len(lLogs) - int(x)
- show_log_command_in_terminal(os.path.join(logDir, lLogs[index]), runner.logger)
+ show_log_command_in_terminal(os.path.join(logDir, lLogs[index]), logger)
x = 0
return
return _("Test d'une commande supplémentaire.")
-def run(args, runner):
+def run(args, runner, logger):
(options, args) = parser.parse_args(args)
if options.unique:
- runner.logger.write('unique\n')
+ logger.write('unique\n')
elif options.value:
runner.cfg.VARS.user = 'TEST'
- runner.config('-v ' + options.value)
+ runner.config('-v ' + options.value, logger)
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 <salomeTools root>/data
- self.logger = None
# set the commands by calling the dedicated function
self.__setCommands__(cmdsdir)
(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
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
# Execute the run method of the command
- res = __module__.run(argv, self)
+ res = __module__.run(argv, self, logger_command)
# put final attributes in xml log file (end time, total time, ...) and write it
- self.logger.endWrite()
+ logger_command.endWrite()
return res