]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
changing SITE.log.log_dir by USER.log_dir
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Tue, 30 Aug 2016 14:03:46 +0000 (16:03 +0200)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Tue, 30 Aug 2016 14:03:46 +0000 (16:03 +0200)
commands/config.py
commands/jobs.py
commands/log.py
commands/test.py
data/site.pyconf
src/logger.py
src/pyconf.py
test/log/launch_browser.py

index 7ee957d084cbc236d2fa8844564924011eb95f89..ef7b2a5fa1b8a6b9420389f54381c969c6c95e53 100644 (file)
@@ -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, 
index ed7cb70f5eea6bb469ae295ad2e15a3e3f4d9717..b6504e591ecf1b5a910c54076aa90f29a22940ae 100644 (file)
@@ -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)
index 12a87ee34bb71c6eb2f079d76c95c38c950c9c08..28d5f35b885a104f372884468a48a5ec18f47613 100644 (file)
@@ -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)
     
index 7cb9fbce0b59862c2a70db780b593919a05f5f4a..3b17e55ac31b88cf543351ac4eadc74f6ca5b817 100644 (file)
@@ -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,
index 6652e7df57e009317d4a0ddeb22add3a0a593953..d721713a3da5d041c09eecd9e6220cf05062f894 100644 (file)
@@ -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'
index 6aeb94b5f45779dc98e384eb4d09c5ab6a2c4c55..297cba019ab41cafcc0c6addadc5e43c3877869c 100644 (file)
@@ -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 
index fa0b259b6ed711d63bb9a41ec95e0313b4d15a77..944826cdb32b8875fd92374122cdad98998d5dd0 100644 (file)
@@ -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):
index 4d2988b7576c1f586db19ca990d00bc0c4ce5fbe..3b1677b0e99ad3b28349b221f9726b00f5d5c405 100644 (file)
@@ -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':