From: Serge Rehbinder Date: Mon, 2 Jan 2017 15:36:35 +0000 (+0100) Subject: Possibility to add multiple files as a list for the files containing the jobs X-Git-Tag: 5.0.0a1~38^2~34 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fbea3f73eb9188c95bc5d4001a093e139d19af8b;p=tools%2Fsat.git Possibility to add multiple files as a list for the files containing the jobs --- diff --git a/commands/jobs.py b/commands/jobs.py index 3462aa7..07be864 100644 --- a/commands/jobs.py +++ b/commands/jobs.py @@ -36,9 +36,9 @@ CSV_DELIMITER = ";" parser = src.options.Options() -parser.add_option('n', 'name', 'string', 'jobs_cfg', +parser.add_option('n', 'name', 'list2', 'jobs_cfg', _('Mandatory: The name of the config file that contains' - ' the jobs configuration')) + ' the jobs configuration. Can be a list.')) parser.add_option('o', 'only_jobs', 'list2', 'only_jobs', _('Optional: the list of jobs to launch, by their name. ')) parser.add_option('l', 'list', 'boolean', 'list', @@ -1612,6 +1612,24 @@ class Gui(object): for xml_file in self.d_xml_board_files.values(): self.write_xml_file(xml_file, STYLESHEET_BOARD) +def get_config_file_path(job_config_name, l_cfg_dir): + found = False + file_jobs_cfg = None + if os.path.exists(job_config_name): + found = True + file_jobs_cfg = job_config_name + else: + for cfg_dir in l_cfg_dir: + file_jobs_cfg = os.path.join(cfg_dir, job_config_name) + if not file_jobs_cfg.endswith('.pyconf'): + file_jobs_cfg += '.pyconf' + + if not os.path.exists(file_jobs_cfg): + continue + else: + found = True + break + return found, file_jobs_cfg ## # Describes the command @@ -1650,36 +1668,29 @@ def run(args, runner, logger): return 1 # Find the file in the directories, unless it is a full path - found = False - if os.path.exists(options.jobs_cfg): - found = True - file_jobs_cfg = options.jobs_cfg - else: - for cfg_dir in l_cfg_dir: - file_jobs_cfg = os.path.join(cfg_dir, options.jobs_cfg) - if not file_jobs_cfg.endswith('.pyconf'): - file_jobs_cfg += '.pyconf' - - if not os.path.exists(file_jobs_cfg): - continue - else: - found = True - break - - if not found: - msg = _("The file configuration %(name_file)s was not found." - "\nUse the --list option to get the possible files.") - src.printcolors.printcError(msg) - return 1 + # merge all in a config + merger = src.pyconf.ConfigMerger() + config_jobs = src.pyconf.Config() + l_conf_files_path = [] + for config_file in options.jobs_cfg: + found, file_jobs_cfg = get_config_file_path(config_file, l_cfg_dir) + if not found: + msg = _("The file configuration %(name_file)s was not found." + "\nUse the --list option to get the " + "possible files." % config_file) + src.printcolors.printcError(msg) + return 1 + l_conf_files_path.append(file_jobs_cfg) + # Read the config that is in the file + one_config_jobs = src.read_config_from_a_file(file_jobs_cfg) + merger.merge(config_jobs, one_config_jobs) info = [ (_("Platform"), runner.cfg.VARS.dist), - (_("File containing the jobs configuration"), file_jobs_cfg) + (_("Files containing the jobs configuration"), l_conf_files_path) ] src.print_info(logger, info) - # Read the config that is in the file - config_jobs = src.read_config_from_a_file(file_jobs_cfg) if options.only_jobs: l_jb = src.pyconf.Sequence() for jb in config_jobs.jobs: diff --git a/commands/log.py b/commands/log.py index 20f975b..3dbb0e3 100644 --- a/commands/log.py +++ b/commands/log.py @@ -145,7 +145,8 @@ def show_product_last_logs(logger, config, product_log_dir): my_stat = os.stat(os.path.join(product_log_dir, file_n)) l_time_file.append( (datetime.datetime.fromtimestamp(my_stat[stat.ST_MTIME]), file_n)) - + + # display the available logs for i, (__, file_name) in enumerate(sorted(l_time_file)): str_indice = src.printcolors.printcLabel("%2d" % (i+1)) opt = [] @@ -264,6 +265,7 @@ def run(args, runner, logger): # If the last option is invoked, just, show the last log file if options.last_terminal: + src.check_config_has_application(runner.cfg) log_dirs = os.listdir(os.path.join(runner.cfg.APPLICATION.workdir, 'LOGS')) show_last_logs(logger, runner.cfg, log_dirs)