From: Serge Rehbinder Date: Tue, 30 Aug 2016 14:03:46 +0000 (+0200) Subject: changing SITE.log.log_dir by USER.log_dir X-Git-Tag: 5.0.0a1~153 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=96a30f04db36f25045837aec05fb7ae1b663d694;p=tools%2Fsat.git changing SITE.log.log_dir by USER.log_dir --- diff --git a/commands/config.py b/commands/config.py index 7ee957d..ef7b2a5 100644 --- a/commands/config.py +++ b/commands/config.py @@ -270,31 +270,36 @@ class ConfigManager: # ===================================================================== # Load the PROJECTS - if "PROJECTS" in cfg: - cfg.PROJECTS.addMapping("projects", - src.pyconf.Mapping(cfg.PROJECTS), - "The projects definition\n") - for project_pyconf_path in cfg.PROJECTS.project_file_paths: - if not os.path.exists(project_pyconf_path): - #msg = _("WARNING: The project file %s cannot be found. " - # "It will be ignored\n" % project_pyconf_path) - #sys.stdout.write(src.printcolors.printcWarning(msg)) - continue - project_name = os.path.basename( - project_pyconf_path)[:-len(".pyconf")] - try: - project_cfg = src.pyconf.Config(open(project_pyconf_path)) - except Exception as e: - raise src.SatException(_("Error in configuration file: " - "%(file_path)s\n %(error)s") % \ - {'file_path' : project_cfg, 'error': str(e) }) - cfg.PROJECTS.projects.addMapping(project_name, - src.pyconf.Mapping(cfg.PROJECTS.projects), - "The %s project\n" % project_name) - cfg.PROJECTS.projects[project_name]=project_cfg - cfg.PROJECTS.projects[project_name]["file_path"] = \ - project_pyconf_path - + projects_cfg = src.pyconf.Config() + projects_cfg.addMapping("PROJECTS", + src.pyconf.Mapping(projects_cfg), + "The projects\n") + projects_cfg.PROJECTS.addMapping("projects", + src.pyconf.Mapping(cfg.PROJECTS), + "The projects definition\n") + + for project_pyconf_path in cfg.PROJECTS.project_file_paths: + if not os.path.exists(project_pyconf_path): + msg = _("WARNING: The project file %s cannot be found. " + "It will be ignored\n" % project_pyconf_path) + sys.stdout.write(src.printcolors.printcWarning(msg)) + continue + project_name = os.path.basename( + project_pyconf_path)[:-len(".pyconf")] + try: + project_cfg = src.pyconf.Config(open(project_pyconf_path)) + except Exception as e: + raise src.SatException(_("Error in configuration file: " + "%(file_path)s\n %(error)s") % \ + {'file_path' : project_pyconf_path, 'error': str(e) }) + projects_cfg.PROJECTS.projects.addMapping(project_name, + src.pyconf.Mapping(projects_cfg.PROJECTS.projects), + "The %s project\n" % project_name) + projects_cfg.PROJECTS.projects[project_name]=project_cfg + projects_cfg.PROJECTS.projects[project_name]["file_path"] = \ + project_pyconf_path + + merger.merge(cfg, projects_cfg) # apply overwrite from command line if needed for rule in self.get_command_line_overrides(options, ["PROJECTS"]): @@ -480,6 +485,13 @@ class ConfigManager: "ignored if this key exists in the site.pyconf" " file of salomTools).\n") + user_cfg.USER.addMapping("log_dir", + src.pyconf.Reference( + user_cfg, + src.pyconf.DOLLAR, + 'workdir + $VARS.sep + "LOGS"'), + "The log reposotory\n") + # src.ensure_path_exists(config.VARS.personalDir) src.ensure_path_exists(os.path.join(config.VARS.personalDir, diff --git a/commands/jobs.py b/commands/jobs.py index ed7cb70..b6504e5 100644 --- a/commands/jobs.py +++ b/commands/jobs.py @@ -1475,7 +1475,7 @@ def run(args, runner, logger): gui = None if options.publish: # Copy the stylesheets in the log directory - log_dir = runner.cfg.SITE.log.log_dir + log_dir = runner.cfg.USER.log_dir xsl_dir = os.path.join(runner.cfg.VARS.srcDir, 'xsl') files_to_copy = [] files_to_copy.append(os.path.join(xsl_dir, STYLESHEET_GLOBAL)) @@ -1486,7 +1486,7 @@ def run(args, runner, logger): # Instanciate the Gui in order to produce the xml files that contain all # the boards - gui = Gui(runner.cfg.SITE.log.log_dir, + gui = Gui(runner.cfg.USER.log_dir, today_jobs.ljobs, today_jobs.ljobs_not_today, file_boards = options.input_boards) diff --git a/commands/log.py b/commands/log.py index 12a87ee..28d5f35 100644 --- a/commands/log.py +++ b/commands/log.py @@ -139,7 +139,7 @@ def run(args, runner, logger): (options, args) = parser.parse_args(args) # get the log directory. - logDir = runner.cfg.SITE.log.log_dir + logDir = runner.cfg.USER.log_dir # Print a header nb_files_log_dir = len(glob.glob(os.path.join(logDir, "*"))) @@ -248,7 +248,7 @@ def run(args, runner, logger): # Create or update the hat xml that gives access to all the commands log files xmlHatFilePath = os.path.join(logDir, 'hat.xml') - src.logger.update_hat_xml(runner.cfg.SITE.log.log_dir, + src.logger.update_hat_xml(runner.cfg.USER.log_dir, application = runner.cfg.VARS.application, notShownCommands = notShownCommands) diff --git a/commands/test.py b/commands/test.py index 7cb9fbc..3b17e55 100644 --- a/commands/test.py +++ b/commands/test.py @@ -524,7 +524,7 @@ def run(args, runner, logger): logger.write("\n", 2, False) logger.write(_("\nGenerate the specific test log\n"), 5) - out_dir = os.path.join(runner.cfg.SITE.log.log_dir, "TEST") + out_dir = os.path.join(runner.cfg.USER.log_dir, "TEST") src.ensure_path_exists(out_dir) name_xml_board = logger.logFileName.split(".")[0] + "board" + ".xml" create_test_report(runner.cfg, diff --git a/data/site.pyconf b/data/site.pyconf index 6652e7d..d721713 100644 --- a/data/site.pyconf +++ b/data/site.pyconf @@ -3,10 +3,6 @@ SITE : { - log : - { - log_dir : $USER.workdir + "/LOGS" - } #base : $USER.workdir + $VARS.sep + "BASE-FROM-SITE" test :{ tmp_dir_with_application : '/tmp' + $VARS.sep + $VARS.user + $VARS.sep + $APPLICATION.name + $VARS.sep + 'test' diff --git a/src/logger.py b/src/logger.py index 6aeb94b..297cba0 100644 --- a/src/logger.py +++ b/src/logger.py @@ -45,11 +45,11 @@ class Logger(object): # 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) + 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...) txtFileName = config.VARS.datehour + "_" + config.VARS.command + ".txt" - txtFilePath = os.path.join(config.SITE.log.log_dir, "OUT", txtFileName) + 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)) @@ -219,7 +219,7 @@ class Logger(object): 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 diff --git a/src/pyconf.py b/src/pyconf.py index fa0b259..944826c 100644 --- a/src/pyconf.py +++ b/src/pyconf.py @@ -621,6 +621,8 @@ class Mapping(Container): skey = repr(key) if comment: stream.write('%s#%s' % (indstr, comment)) + if skey.startswith("u'"): + skey = skey[1:] stream.write('%s%-*s :' % (indstr, maxlen, skey)) value = data[key] if isinstance(value, Container): diff --git a/test/log/launch_browser.py b/test/log/launch_browser.py index 4d2988b..3b1677b 100644 --- a/test/log/launch_browser.py +++ b/test/log/launch_browser.py @@ -51,7 +51,7 @@ class TestLog(unittest.TestCase): sat.config('appli-test -v USER.browser') # get log file path - logDir = sat.cfg.SITE.log.log_dir + logDir = sat.cfg.USER.log_dir logPath = os.path.join(logDir, sat.cfg.VARS.datehour + "_" + sat.cfg.VARS.command + ".xml") if os.path.exists(logPath): @@ -141,7 +141,7 @@ class TestLog(unittest.TestCase): sat.config('appli-test -v VARS.python') - nb_logs = len(os.listdir(sat.cfg.SITE.log.log_dir)) + nb_logs = len(os.listdir(sat.cfg.USER.log_dir)) nb_logs_u = unicode(str(nb_logs) + "\n1") sys.stdin = io.StringIO(nb_logs_u) @@ -257,11 +257,11 @@ class TestLog(unittest.TestCase): sat.config('-v VARS.user') - nb_logs_t0 = len(os.listdir(sat.cfg.SITE.log.log_dir)) + nb_logs_t0 = len(os.listdir(sat.cfg.USER.log_dir)) sat.log('--clean 1') - nb_logs_t1 = len(os.listdir(sat.cfg.SITE.log.log_dir)) + nb_logs_t1 = len(os.listdir(sat.cfg.USER.log_dir)) if nb_logs_t1-nb_logs_t0 == 0: OK = "OK" @@ -280,18 +280,18 @@ class TestLog(unittest.TestCase): sat.config('-v VARS.user') - nb_logs_t0 = len(os.listdir(sat.cfg.SITE.log.log_dir)) + nb_logs_t0 = len(os.listdir(sat.cfg.USER.log_dir)) - if os.path.exists(sat.cfg.SITE.log.log_dir + "_save"): - shutil.rmtree(sat.cfg.SITE.log.log_dir + "_save") - shutil.copytree(sat.cfg.SITE.log.log_dir,sat.cfg.SITE.log.log_dir + "_save") + if os.path.exists(sat.cfg.USER.log_dir + "_save"): + shutil.rmtree(sat.cfg.USER.log_dir + "_save") + shutil.copytree(sat.cfg.USER.log_dir,sat.cfg.USER.log_dir + "_save") sat.log('--clean ' + str(nb_logs_t0)) - nb_logs_t1 = len(os.listdir(sat.cfg.SITE.log.log_dir)) + nb_logs_t1 = len(os.listdir(sat.cfg.USER.log_dir)) - shutil.rmtree(sat.cfg.SITE.log.log_dir) - shutil.move(sat.cfg.SITE.log.log_dir + "_save", sat.cfg.SITE.log.log_dir) + shutil.rmtree(sat.cfg.USER.log_dir) + shutil.move(sat.cfg.USER.log_dir + "_save", sat.cfg.USER.log_dir) if nb_logs_t0-nb_logs_t1 > 10: OK = "OK" @@ -317,7 +317,7 @@ class TestLog(unittest.TestCase): check_proc_existence_and_kill_multi(browser + ".*" + "hat\.xml", 10) # Read and check the hat.xml file contains at least one log file corresponding to log - hatFilePath = os.path.join(sat.cfg.SITE.log.log_dir, "hat.xml") + hatFilePath = os.path.join(sat.cfg.USER.log_dir, "hat.xml") xmlHatFile = src.xmlManager.ReadXmlFile(hatFilePath) for field in xmlHatFile.xmlroot: if field.attrib[b'cmd'] == b'log':