]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
Merge branch 'BR_8_3' of https://codev-tuleap.cea.fr/plugins/git/spns/SAT into BR_8_3
authorcrouzet <nicolas.crouzet@cea.fr>
Tue, 6 Jun 2017 12:04:01 +0000 (14:04 +0200)
committercrouzet <nicolas.crouzet@cea.fr>
Tue, 6 Jun 2017 12:04:01 +0000 (14:04 +0200)
15 files changed:
commands/base.py [deleted file]
commands/config.py
commands/init.py [new file with mode: 0644]
commands/jobs.py
commands/log.py
commands/package.py
commands/test.py
complete_sat.sh
data/local.pyconf [new file with mode: 0644]
data/site.pyconf [deleted file]
data/templates/PythonComponent/template.info
src/__init__.py
src/fileEnviron.py
src/logger.py
src/test_module.py

diff --git a/commands/base.py b/commands/base.py
deleted file mode 100644 (file)
index 6df87b8..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/usr/bin/env python
-#-*- coding:utf-8 -*-
-#  Copyright (C) 2010-2012  CEA/DEN
-#
-#  This library is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU Lesser General Public
-#  License as published by the Free Software Foundation; either
-#  version 2.1 of the License.
-#
-#  This library is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#  Lesser General Public License for more details.
-#
-#  You should have received a copy of the GNU Lesser General Public
-#  License along with this library; if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-
-import os
-
-import src
-
-# Define all possible option for the shell command :  sat base <options>
-parser = src.options.Options()
-parser.add_option('s', 'set', 'string', 'base_path',
-    _('Optional: The path directory to use as base.'), None)
-
-def set_base(config, path, site_file_path, logger):
-    """ Edit the site.pyconf file and change the base path
-
-    :param config Config: The global configuration.    
-    :param path src.Path: The path to put in the site.pyconf file.
-    :param site_file_path Str: The path to the site.pyconf file.
-    :param logger Logger: The logger instance.
-    :return: 0 if all is OK, else 1
-    :rtype: int
-    """
-    # Update the site.pyconf file
-    try:
-        site_pyconf_cfg = src.pyconf.Config(site_file_path)
-        site_pyconf_cfg.SITE.base = str(path)
-        ff = open(site_file_path, 'w')
-        site_pyconf_cfg.__save__(ff, 1)
-        ff.close()
-        config.SITE.base = str(path)
-    except Exception as e:
-        err = str(e)
-        msg = _("Unable to update the site.pyconf file: %s\n" % err)
-        logger.write(msg, 1)
-        return 1
-    
-    display_base_path(config, logger)
-    
-    return 0
-
-
-def display_base_path(config, logger):
-    """ Display the base path
-
-    :param config Config: The global configuration.    
-    :param logger Logger: The logger instance.
-    """
-    info = [(_("Base path"), config.SITE.base)]
-    src.print_info(logger, info)
-
-def description():
-    '''method that is called when salomeTools is called with --help option.
-    
-    :return: The text to display for the base command description.
-    :rtype: str
-    '''
-    return _("Display or set the base where to put installations of base "
-             "products\n\nexample\nsat base --set /tmp/BASE")
-  
-def run(args, runner, logger):
-    '''method that is called when salomeTools is called with base parameter.
-    '''
-    
-    # Parse the options
-    (options, args) = parser.parse_args(args)
-    
-    # Get the path to the site.pyconf file that contain the base path
-    site_file_path = os.path.join(runner.cfg.VARS.salometoolsway,
-                                  "data",
-                                  "site.pyconf")
-    
-    # If the option set is passed
-    if options.base_path:
-        # Get the path
-        path = src.Path(options.base_path)
-        
-        # If it is a file, do nothing and return error
-        if path.isfile():
-            msg = _("Error: The given path is a file. Please provide a path to "
-                    "a directory")
-            logger.write(src.printcolors.printcError(msg), 1)
-            return 1
-        
-        # If it is an existing directory, set the base to it
-        if path.exists() and path.isdir():
-            # Set the base in the site.pyconf file
-            res = set_base(runner.cfg, path, site_file_path, logger)
-            return res
-        
-        # Try to create the given path
-        try:
-            src.ensure_path_exists(str(path))
-        except Exception as e:
-            err = src.printcolors.printcError(str(e))
-            msg = _("Unable to create the directory %s: %s\n" % (str(path),
-                                                                 err))
-            logger.write(msg, 1)
-            return 1
-        
-        # Set the base in the site.pyconf file
-        res = set_base(runner.cfg, path, site_file_path, logger)
-        return res
-    
-    # Display the base that is in the site.pyconf file
-    display_base_path(runner.cfg, logger)
-    if not options.base_path:
-        logger.write(_("To change the value of the base path, use the --set"
-                       " option.\n"), 2)
-    
-    return
\ No newline at end of file
index deef6618120d2cd31c738efbc0415ad012bdf511..084df54a450abc29a9b71e0450c827384bc90dc4 100644 (file)
@@ -247,30 +247,40 @@ class ConfigManager:
             exec('cfg.' + rule) # this cannot be factorized because of the exec        
                
         # =====================================================================
-        # Load SITE config file
+        # Load LOCAL config file
         # search only in the data directory
         src.pyconf.streamOpener = ConfigOpener([cfg.VARS.datadir])
         try:
-            site_cfg = src.pyconf.Config(open(os.path.join(cfg.VARS.datadir, 
-                                                           'site.pyconf')),
-                                         PWD = ('SITE', cfg.VARS.datadir) )
+            local_cfg = src.pyconf.Config(open(os.path.join(cfg.VARS.datadir, 
+                                                           'local.pyconf')),
+                                         PWD = ('LOCAL', cfg.VARS.datadir) )
         except src.pyconf.ConfigError as e:
             raise src.SatException(_("Error in configuration file: "
-                                     "site.pyconf\n  %(error)s") % \
+                                     "local.pyconf\n  %(error)s") % \
                 {'error': str(e) })
         except IOError as error:
             e = str(error)
-            if "site.pyconf" in e :
-                e += ("\nYou can copy data"
-                  + cfg.VARS.sep
-                  + "site.template.pyconf to data"
-                  + cfg.VARS.sep 
-                  + "site.pyconf and edit the file")
             raise src.SatException( e );
-        merger.merge(cfg, site_cfg)
+        merger.merge(cfg, local_cfg)
+
+        # When the key is "unknown", put the default value
+        if cfg.LOCAL.base == "unknown":
+            cfg.LOCAL.base = os.path.abspath(
+                                        os.path.join(cfg.VARS.salometoolsway,
+                                                     "..",
+                                                     "BASE"))
+        if cfg.LOCAL.workdir == "unknown":
+            cfg.LOCAL.workdir = os.path.abspath(
+                                        os.path.join(cfg.VARS.salometoolsway,
+                                                     ".."))
+        if cfg.LOCAL.log_dir == "unknown":
+            cfg.LOCAL.log_dir = os.path.abspath(
+                                        os.path.join(cfg.VARS.salometoolsway,
+                                                     "..",
+                                                     "LOGS"))
 
         # apply overwrite from command line if needed
-        for rule in self.get_command_line_overrides(options, ["SITE"]):
+        for rule in self.get_command_line_overrides(options, ["LOCAL"]):
             exec('cfg.' + rule) # this cannot be factorized because of the exec
         
         # =====================================================================
@@ -482,10 +492,6 @@ class ConfigManager:
         #
         user_cfg.addMapping('USER', src.pyconf.Mapping(user_cfg), "")
 
-        #
-        user_cfg.USER.addMapping('workdir', os.path.expanduser('~'),
-            "This is where salomeTools will work. "
-            "You may (and probably do) change it.\n")
         user_cfg.USER.addMapping('cvs_user', config.VARS.user,
             "This is the user name used to access salome cvs base.\n")
         user_cfg.USER.addMapping('svn_user', config.VARS.user,
@@ -516,16 +522,9 @@ class ConfigManager:
                                             src.pyconf.DOLLAR,
                                             'workdir  + $VARS.sep + "BASE"'),
                                  "The products installation base (could be "
-                                 "ignored if this key exists in the site.pyconf"
+                                 "ignored if this key exists in the local.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 repository\n")
-        
+               
         # 
         src.ensure_path_exists(config.VARS.personalDir)
         src.ensure_path_exists(os.path.join(config.VARS.personalDir, 
diff --git a/commands/init.py b/commands/init.py
new file mode 100644 (file)
index 0000000..0a0103a
--- /dev/null
@@ -0,0 +1,154 @@
+#!/usr/bin/env python
+#-*- coding:utf-8 -*-
+#  Copyright (C) 2010-2012  CEA/DEN
+#
+#  This library is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU Lesser General Public
+#  License as published by the Free Software Foundation; either
+#  version 2.1 of the License.
+#
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  Lesser General Public License for more details.
+#
+#  You should have received a copy of the GNU Lesser General Public
+#  License along with this library; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+
+import os
+
+import src
+
+# Define all possible option for the init command :  sat init <options>
+parser = src.options.Options()
+parser.add_option('b', 'base', 'string', 'base', 
+                  _('Optional: The path to the products base'))
+parser.add_option('w', 'workdir', 'string', 'workdir', 
+                  _('Optional: The path to the working directory '
+                    '(where to install the applications'))
+parser.add_option('v', 'VCS', 'string', 'VCS', 
+                  _('Optional: The address of the repository of SAT '
+                    '(only informative)'))
+parser.add_option('t', 'tag', 'string', 'tag', 
+                  _('Optional: The tag of SAT (only informative)'))
+parser.add_option('l', 'log_dir', 'string', 'log_dir', 
+                  _('Optional: The directory where to put all the logs of SAT'))
+
+def set_local_value(config, key, value, logger):
+    """ Edit the site.pyconf file and change a value.
+
+    :param config Config: The global configuration.    
+    :param key Str: The key from which to change the value.
+    :param value Str: The path to change.
+    :param logger Logger: The logger instance.
+    :return: 0 if all is OK, else 1
+    :rtype: int
+    """
+    local_file_path = os.path.join(config.VARS.datadir, "local.pyconf")
+    # Update the local.pyconf file
+    try:
+        local_cfg = src.pyconf.Config(local_file_path)
+        local_cfg.LOCAL[key] = value
+        ff = open(local_file_path, 'w')
+        local_cfg.__save__(ff, 1)
+        ff.close()
+        if key != "log_dir":
+            config.LOCAL[key] = value
+    except Exception as e:
+        err = str(e)
+        msg = _("Unable to update the local.pyconf file: %s\n" % err)
+        logger.write(msg, 1)
+        return 1
+    
+    return 0
+    
+def display_local_values(config, logger):
+    """ Display the base path
+
+    :param config Config: The global configuration.
+    :param key Str: The key from which to change the value.
+    :param logger Logger: The logger instance.
+    """
+    info = [("base", config.LOCAL.base),
+            ("workdir", config.LOCAL.workdir),
+            ("log_dir", config.LOCAL.log_dir),
+            ("VCS", config.LOCAL.VCS),
+            ("tag", config.LOCAL.tag)]
+    src.print_info(logger, info)
+
+    return 0
+
+def check_path(path_to_check, logger):
+    """ Verify that the given path is not a file and can be created.
+    
+    :param path_to_check Str: The path to check.
+    :param logger Logger: The logger instance.
+    """
+    if path_to_check == "unknown":
+        return 0
+    
+    # Get the path
+    path = src.Path(path_to_check)
+    
+    # If it is a file, do nothing and return error
+    if path.isfile():
+        msg = _("Error: The given path is a file. Please provide a path to "
+                "a directory")
+        logger.write(src.printcolors.printcError(msg), 1)
+        return 1
+      
+    # Try to create the given path
+    try:
+        src.ensure_path_exists(str(path))
+    except Exception as e:
+        err = src.printcolors.printcError(str(e))
+        msg = _("Unable to create the directory %s: %s\n" % (str(path),
+                                                             err))
+        logger.write(msg, 1)
+        return 1
+    
+    return 0
+
+def description():
+    '''method that is called when salomeTools is called with --help option.
+    
+    :return: The text to display for the init command description.
+    :rtype: str
+    '''
+    return _("Changes the local settings of SAT.")
+  
+def run(args, runner, logger):
+    '''method that is called when salomeTools is called with init parameter.
+    '''
+    
+    # Parse the options
+    (options, args) = parser.parse_args(args)
+    
+    # Print some informations
+    logger.write(_('Local Settings of SAT %s\n\n') % 
+                src.printcolors.printcLabel(runner.cfg.VARS.salometoolsway), 1)
+
+    res = 0
+    
+    # Set the options corresponding to a directory
+    for opt in [("base" , options.base),
+                ("workdir", options.workdir),
+                ("log_dir", options.log_dir)]:
+        key, value = opt
+        if value:
+            res_check = check_path(value, logger)
+            res += res_check
+            if res_check == 0:
+                res_set = set_local_value(runner.cfg, key, value, logger)
+                res += res_set
+
+    # Set the options corresponding to an informative value            
+    for opt in [("VCS", options.VCS), ("tag", options.tag)]:
+        key, value = opt
+        res_set = set_local_value(runner.cfg, key, value, logger)
+        res += res_set
+    
+    display_local_values(runner.cfg, logger)
+    
+    return res
\ No newline at end of file
index 3c0e17a5e4ebb6eae82a4d080264e850cd93f970..56f19d78d3229da8c01f7371f460b99235718bf0 100644 (file)
@@ -512,7 +512,7 @@ class Job(object):
             self._has_finished = True
             self._has_timouted = True
             self._Tf = time.time()
-            (out_kill, _) = self.kill_remote_process()
+            (out_kill, __) = self.kill_remote_process()
             self.out += "TIMEOUT \n" + out_kill
             self.err += "TIMEOUT : %s seconds elapsed\n" % str(self.timeout)
             try:
@@ -832,6 +832,15 @@ class Jobs(object):
                 self.logger.flush()
                 res_copy = machine.copy_sat(self.runner.cfg.VARS.salometoolsway,
                                             self.job_file_path)
+
+                # set the local settings of sat on the remote machine using
+                # the init command
+                (__, __, __) = machine.exec_command(
+                                os.path.join(machine.sat_path,
+                                    "sat init --base unknown --workdir unknown"
+                                    " --log_dir unknown"),
+                                self.logger)
+                
                 # get the remote machine distribution using a sat command
                 (__, out_dist, __) = machine.exec_command(
                                 os.path.join(machine.sat_path,
@@ -839,6 +848,7 @@ class Jobs(object):
                                 self.logger)
                 machine.distribution = out_dist.read().decode().replace("\n",
                                                                         "")
+                
                 # Print the status of the copy
                 if res_copy == 0:
                     self.logger.write('\r%s' % 
@@ -1731,7 +1741,8 @@ def run(args, runner, logger):
     config_jobs.__save__(f)
     
     # log the paramiko problems
-    paramiko_log_dir_path = os.path.join(runner.cfg.USER.log_dir, "JOBS")
+    log_dir = src.get_log_path(runner.cfg)
+    paramiko_log_dir_path = os.path.join(log_dir, "JOBS")
     src.ensure_path_exists(paramiko_log_dir_path)
     paramiko.util.log_to_file(os.path.join(paramiko_log_dir_path,
                                            logger.txtFileName))
@@ -1753,7 +1764,7 @@ def run(args, runner, logger):
         logger.flush()
         
         # Copy the stylesheets in the log directory 
-        log_dir = runner.cfg.USER.log_dir
+        log_dir = 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))
@@ -1764,7 +1775,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.USER.log_dir,
+        gui = Gui(log_dir,
                   today_jobs.ljobs,
                   today_jobs.ljobs_not_today,
                   runner.cfg.VARS.datehour,
index ed7439eece700fe01d3cd01fcdd3f35cf047995a..08e5f23915a38908f8edde5a9f32aa72881dbb35 100644 (file)
@@ -203,7 +203,7 @@ def run(args, runner, logger):
     (options, args) = parser.parse_args(args)
 
     # get the log directory. 
-    logDir = runner.cfg.USER.log_dir
+    logDir = src.get_log_path(runner.cfg)
     
     # Print a header
     nb_files_log_dir = len(glob.glob(os.path.join(logDir, "*")))
@@ -322,7 +322,7 @@ def run(args, runner, logger):
     # Create or update the hat xml that gives access to all the commands log files
     logger.write(_("Generating the hat log file (can be long) ... "), 3)
     xmlHatFilePath = os.path.join(logDir, 'hat.xml')
-    src.logger.update_hat_xml(runner.cfg.USER.log_dir, 
+    src.logger.update_hat_xml(logDir, 
                               application = runner.cfg.VARS.application, 
                               notShownCommands = notShownCommands)
     logger.write(src.printcolors.printc("OK"), 3)
index ddb5309d2b34441f51cf25717dc5e120c0c518f1..ad10ab0a878ef975c50352e590078ab0327f9f5b 100644 (file)
@@ -59,22 +59,17 @@ JOBPATH : $project_path + "jobs/"
 MACHINEPATH : $project_path + "machines/"
 """
 
-SITE_TEMPLATE = ("""#!/usr/bin/env python
+LOCAL_TEMPLATE = ("""#!/usr/bin/env python
 #-*- coding:utf-8 -*-
 
-SITE :
-{   
-    log :
-    {
-        log_dir : $USER.workdir + "/LOGS"
-    }
-    test :{
-           tmp_dir_with_application : '/tmp' + $VARS.sep + $VARS.user + """
-"""$VARS.sep + $APPLICATION.name + $VARS.sep + 'test'
-           tmp_dir : '/tmp' + $VARS.sep + $VARS.user + $VARS.sep + 'test'
-           timeout : 150
-           }
-}
+  LOCAL :
+  {
+    base : 'unknown'
+    workdir : 'unknown'
+    log_dir : 'unknown'
+    VCS : None
+    tag : None
+  }
 
 PROJECTS :
 {
@@ -219,6 +214,10 @@ def produce_relative_launcher(config,
     # Little hack to put out_dir_Path outside the strings
     src.replace_in_file(filepath, 'r"out_dir_Path', 'out_dir_Path + r"' )
     
+    # A hack to put a call to a file for distene licence.
+    # It does nothing to an application that has no distene product
+    hack_for_distene_licence(filepath)
+       
     # change the rights in order to make the file executable for everybody
     os.chmod(filepath,
              stat.S_IRUSR |
@@ -231,6 +230,43 @@ def produce_relative_launcher(config,
 
     return filepath
 
+def hack_for_distene_licence(filepath):
+    '''Replace the distene licence env variable by a call to a file.
+    
+    :param filepath Str: The path to the launcher to modify.
+    '''  
+    shutil.move(filepath, filepath + "_old")
+    fileout= filepath
+    filein = filepath + "_old"
+    fin = open(filein, "r")
+    fout = open(fileout, "w")
+    text = fin.readlines()
+    # Find the Distene section
+    num_line = -1
+    for i,line in enumerate(text):
+        if "# Set DISTENE License" in line:
+            num_line = i
+            break
+    if num_line == -1:
+        # No distene product, there is nothing to do
+        fin.close()
+        fout.close()
+        return
+    del text[num_line +1]
+    del text[num_line +1]
+    text_to_insert ="""    import imp
+    try:
+        distene = imp.load_source('distene_licence', '/data/tmpsalome/salome/prerequis/install/LICENSE/dlim8.var.py')
+        distene.set_distene_variables(context)
+    except:
+        pass\n"""
+    text.insert(num_line + 1, text_to_insert)
+    for line in text:
+        fout.write(line)
+    fin.close()    
+    fout.close()
+    return
+    
 def produce_relative_env_files(config,
                               logger,
                               file_dir,
@@ -627,7 +663,7 @@ def get_archives(config, logger):
     return d_archives, l_pinfo_vcs
 
 def add_salomeTools(config, tmp_working_dir):
-    '''Prepare a version of salomeTools that has a specific site.pyconf file 
+    '''Prepare a version of salomeTools that has a specific local.pyconf file 
        configured for a source package.
 
     :param config Config: The global configuration.
@@ -642,12 +678,12 @@ def add_salomeTools(config, tmp_working_dir):
     sat_running_path = src.Path(config.VARS.salometoolsway)
     sat_running_path.copy(sat_tmp_path)
     
-    # Update the site.pyconf file that contains the path to the project
-    site_pyconf_name = "site.pyconf"
-    site_pyconf_dir = os.path.join(tmp_working_dir, "salomeTools", "data")
-    site_pyconf_file = os.path.join(site_pyconf_dir, site_pyconf_name)
-    ff = open(site_pyconf_file, "w")
-    ff.write(SITE_TEMPLATE)
+    # Update the local.pyconf file that contains the path to the project
+    local_pyconf_name = "local.pyconf"
+    local_pyconf_dir = os.path.join(tmp_working_dir, "salomeTools", "data")
+    local_pyconf_file = os.path.join(local_pyconf_dir, local_pyconf_name)
+    ff = open(local_pyconf_file, "w")
+    ff.write(LOCAL_TEMPLATE)
     ff.close()
     
     return sat_tmp_path.path
@@ -1102,12 +1138,12 @@ def run(args, runner, logger):
     if options.project:
         # check that the project is visible by SAT
         if options.project not in runner.cfg.PROJECTS.project_file_paths:
-            site_path = os.path.join(runner.cfg.VARS.salometoolsway,
+            local_path = os.path.join(runner.cfg.VARS.salometoolsway,
                                      "data",
-                                     "site.pyconf")
+                                     "local.pyconf")
             msg = _("ERROR: the project %(proj)s is not visible by salomeTools."
-                    "\nPlease add it in the %(site)s file." % {
-                                  "proj" : options.project, "site" : site_path})
+                    "\nPlease add it in the %(local)s file." % {
+                                  "proj" : options.project, "local" : local_path})
             logger.write(src.printcolors.printcError(msg), 1)
             logger.write("\n", 1)
             return 1
index b0df42ed86a19fc729e22137e5ac6e87691b3bcd..bf89e549c5cdd1936c760e6632f728d7d98405b4 100644 (file)
@@ -536,7 +536,8 @@ def generate_history_xml_path(config, test_base):
         test_base_name = os.path.basename(test_base)
     history_xml_name += test_base_name
     history_xml_name += ".xml"
-    return os.path.join(config.USER.log_dir, "TEST", history_xml_name)
+    log_dir = src.get_log_path(config)
+    return os.path.join(log_dir, "TEST", history_xml_name)
 
 def run(args, runner, logger):
     '''method that is called when salomeTools is called with test parameter.
@@ -580,19 +581,23 @@ def run(args, runner, logger):
         os.environ['DISPLAY'] = options.display
     elif 'DISPLAY' not in os.environ:
         # if no display set
-        if ('display' in runner.cfg.SITE.test and 
-                                        len(runner.cfg.SITE.test.display) > 0):
+        if ('test' in runner.cfg.LOCAL and
+                'display' in runner.cfg.LOCAL.test and 
+                len(runner.cfg.LOCAL.test.display) > 0):
             # use default value for test tool
-            os.environ['DISPLAY'] = runner.cfg.SITE.test.display
+            os.environ['DISPLAY'] = runner.cfg.LOCAL.test.display
         else:
             os.environ['DISPLAY'] = "localhost:0.0"
 
     # initialization
     #################
     if with_application:
-        tmp_dir = runner.cfg.SITE.test.tmp_dir_with_application
+        tmp_dir = os.path.join(runner.cfg.VARS.tmp_root,
+                               runner.cfg.APPLICATION.name,
+                               "test")
     else:
-        tmp_dir = runner.cfg.SITE.test.tmp_dir
+        tmp_dir = os.path.join(runner.cfg.VARS.tmp_root,
+                               "test")
 
     # remove previous tmp dir
     if os.access(tmp_dir, os.F_OK):
@@ -653,7 +658,7 @@ def run(args, runner, logger):
 
     src.printcolors.print_value(logger, _('Display'), os.environ['DISPLAY'], 2)
     src.printcolors.print_value(logger, _('Timeout'),
-                                runner.cfg.SITE.test.timeout, 2)
+                                src.test_module.DEFAULT_TIMEOUT, 2)
     src.printcolors.print_value(logger, _("Working dir"), base_dir, 3)
 
     # create the test object
@@ -679,7 +684,8 @@ 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.USER.log_dir, "TEST")
+    log_dir = src.get_log_path(runner.cfg)
+    out_dir = os.path.join(log_dir, "TEST")
     src.ensure_path_exists(out_dir)
     name_xml_board = logger.logFileName.split(".")[0] + "board" + ".xml"
     historic_xml_path = generate_history_xml_path(runner.cfg, test_base)
index ec85d50d676de00bd803f912995bf397199c205c..6873137681a4ec83541aa1c2ea496516ec157611 100755 (executable)
@@ -58,6 +58,9 @@ _show_applications()
         base)
             opts2=$(echo --set $opts2)
             ;;
+        init)
+            opts2=$(echo --base --workdir --VCS --tag --log_dir $opts2)
+            ;;
     esac
 
     COMPREPLY=( $(compgen -W "${opts2}" -- ${cur}) )
@@ -104,7 +107,7 @@ _salomeTools_complete()
     # first argument => show available commands
     if [[ ${argc} == 1 ]]
     then
-        opts="config log source patch prepare environ clean configure make makeinstall compile launcher run jobs job shell test package generate find_duplicates application template base check profile script --help --overwrite --debug --verbose --batch --all_in_terminal --logs_paths_in_file"
+        opts="config log source patch prepare environ clean configure make makeinstall compile launcher run jobs job shell test package generate find_duplicates application template base check profile script init --help --overwrite --debug --verbose --batch --all_in_terminal --logs_paths_in_file"
         COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
         return 0
     fi
@@ -278,6 +281,11 @@ _salomeTools_complete()
             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
             return 0
             ;;
+        init)
+            opts="--base --workdir --VCS --tag --log_dir"
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+            return 0
+            ;;
         *) return 0 ;;
     esac
     
diff --git a/data/local.pyconf b/data/local.pyconf
new file mode 100644 (file)
index 0000000..baf2b8c
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+#-*- coding:utf-8 -*-
+  LOCAL :
+  {
+    base : 'unknown'
+    workdir : 'unknown'
+    log_dir : 'unknown'
+    VCS : None
+    tag : None
+  }
+  PROJECTS :
+  {
+    project_file_paths :
+    [
+    ]
+  }
diff --git a/data/site.pyconf b/data/site.pyconf
deleted file mode 100644 (file)
index 33a9050..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env python
-#-*- coding:utf-8 -*-
-
-SITE :
-{   
-    base : $USER.workdir + $VARS.sep + "BASE"
-    test :{
-           tmp_dir_with_application : '/tmp' + $VARS.sep + $VARS.user + $VARS.sep + $APPLICATION.name + $VARS.sep + 'test'
-           tmp_dir : '/tmp' + $VARS.sep + $VARS.user + $VARS.sep + 'test'
-           timeout : 150
-           }
-}
-
-PROJECTS :
-{
-project_file_paths : 
-[
-]
-}
index 818452deaf0488b949a5d015a5422d30a87e8999..9d7e86a5fa9031764a42a08fce15cc80273eccc2 100644 (file)
@@ -36,13 +36,12 @@ parameters = [
 
 # configuration to use this component with sat
 pyconf = """
-TOOLS : { common : { module_info : {
-    '%(NAME)s':
+    'default':
     {
         name : "%(NAME)s"
         has_gui : "yes"
-        get_sources : '%(get_method)s'
-        build_sources : 'autotools'
+        get_source : '%(get_method)s'
+        build_source : 'autotools'
         git_info:
         {
             repo : 'to be filled'
@@ -50,13 +49,19 @@ TOOLS : { common : { module_info : {
         }
         archive_info:
         {
-            archive_name : '%(target)s.tar.gz'
+            archive_name : '%(NAME)s.tar.gz'
         }
         nb_proc : 1
-        source_dir : $TOOLS.common.source_root + '/' + $name
-        build_dir : $TOOLS.common.build_root + '/' + $name
+        source_dir : $APPLICATION.workdir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
+        build_dir : $APPLICATION.workdir + $VARS.sep + 'BUILD' + $VARS.sep + $name
         depend : [ 'Python', 'KERNEL', 'GUI' ]
         opt_depend : []
+        type : "salome"
+        properties :
+        {
+            is_SALOME_module : 'yes'
+            has_unit_tests : True
+            has_salome_gui : 'yes'
+        }
     }
-}}}
 """
index abf59b0e463e74f5a765fc751b5ff0ea1fe154d7..fd750797985b57209eb9dc4513b042c3560c0c3d 100644 (file)
@@ -119,20 +119,40 @@ def print_info(logger, info):
     logger.write("\n", 2)
 
 def get_base_path(config):
-    '''Returns the path of the product base.
+    '''Returns the path of the products base.
     
     :param config Config: The global Config instance.
-    :return: The path of the product base.
+    :return: The path of the products base.
     :rtype: str
     '''
-    if "base" not in config.SITE:
-        site_file_path = os.path.join(config.VARS.salometoolsway,
+    if "base" not in config.LOCAL:
+        local_file_path = os.path.join(config.VARS.salometoolsway,
                                       "data",
-                                      "site.pyconf")
-        msg = _("Please define a base path in the file %s" % site_file_path)
+                                      "local.pyconf")
+        msg = _("Please define a base path in the file %s" % local_file_path)
         raise SatException(msg)
+        
+    base_path = os.path.abspath(config.LOCAL.base)
+    
+    return base_path
 
-    return config.SITE.base
+def get_log_path(config):
+    '''Returns the path of the logs.
+    
+    :param config Config: The global Config instance.
+    :return: The path of the logs.
+    :rtype: str
+    '''
+    if "log_dir" not in config.LOCAL:
+        local_file_path = os.path.join(config.VARS.salometoolsway,
+                                      "data",
+                                      "local.pyconf")
+        msg = _("Please define a log_dir in the file %s" % local_file_path)
+        raise SatException(msg)
+      
+    log_dir_path = os.path.abspath(config.LOCAL.log_dir)
+    
+    return log_dir_path
 
 def get_salome_version(config):
     if hasattr(config.APPLICATION, 'version_salome'):
index 27071d0be384cb81a79dc4356d38a78cf30fca78..ab43f3cbc42af9019b9add3f48af26b683d3bad5 100644 (file)
@@ -539,17 +539,9 @@ class LauncherFileEnviron:
                               self.prefix+
                               self.setVarEnv+
                               '(r"%s", r"%s", overwrite=True)\n' % 
-                              ('DISTENE_LICENCE_FILE_FOR_MGCLEANER', 
+                              ('DLIM8VAR', 
                                self.change_to_launcher(
-                                                '<path to your license>')))
-            self.output.write(self.indent+
-                              "#"+
-                              self.prefix+
-                              self.setVarEnv+
-                              '(r"%s", r"%s", overwrite=True)\n' % 
-                              ('DISTENE_LICENCE_FILE_FOR_YAMS', 
-                               self.change_to_launcher(
-                                                    '<path to your license>')))
+                                                '<your licence>')))
             return
         if "setting environ for" in comment:
             self.output.write(self.indent+"#[%s]\n" % 
index eb2ee58b283a4b3e5e3a227e301ce1822f23f586..843f7b7a6ab5a69f0f7cd29c97d3f4b8ffc13261 100644 (file)
@@ -56,11 +56,12 @@ class Logger(object):
                              config.VARS.command + "_" + 
                              config.VARS.hostname)
         logFileName = prefix + hour_command_host + ".xml"
-        logFilePath = os.path.join(config.USER.log_dir, logFileName)
+        log_dir = src.get_log_path(config)
+        logFilePath = os.path.join(log_dir, logFileName)
         # Construct txt file location in order to log 
         # the external commands calls (cmake, make, git clone, etc...)
         txtFileName = prefix + hour_command_host + ".txt"
-        txtFilePath = os.path.join(config.USER.log_dir, "OUT", txtFileName)
+        txtFilePath = os.path.join(log_dir, "OUT", txtFileName)
         
         src.ensure_path_exists(os.path.dirname(logFilePath))
         src.ensure_path_exists(os.path.dirname(txtFilePath))
@@ -230,7 +231,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.USER.log_dir
+        logDir = src.get_log_path(self.config)
         dumpedPyconfFileName = (self.config.VARS.datehour 
                                 + "_" 
                                 + self.config.VARS.command 
index fe9d7d704b4f9db8dfdac510a4aaba11b7384272..9ad20dd0dce6b7a1722bef40f1c7a065f69a83f4 100644 (file)
@@ -40,6 +40,8 @@ import src
 # directories not considered as test grids
 C_IGNORE_GRIDS = ['.git', '.svn', 'RESSOURCES']
 
+DEFAULT_TIMEOUT = 150
+
 # Get directory to be used for the temporary files.
 #
 def getTmpDirDEFAULT():
@@ -429,8 +431,8 @@ class Test:
             launcherDir = os.path.dirname(self.launcher)
             if launcherName == 'runAppli':
                 # Old application
-                cmd = "for i in " + launcherDir + "/env.d/*.sh; do source ${i};"
-                " done ; echo $KERNEL_ROOT_DIR"
+                cmd = ("for i in " + launcherDir + "/env.d/*.sh; do source ${i};"
+                       " done ; echo $KERNEL_ROOT_DIR")
             else:
                 # New application
                 cmd = ("echo -e 'import os\nprint os.environ[\"KERNEL_" + 
@@ -560,11 +562,9 @@ class Test:
                                 self.currentsession)
         sessionname = "%s/%s" % (self.currentgrid, self.currentsession)
         time_out = self.get_test_timeout(sessionname,
-                                         self.config.SITE.test.timeout)
+                                         DEFAULT_TIMEOUT)
 
-        time_out_salome = src.get_cfg_param(self.config.SITE.test,
-                                            "timeout_app",
-                                            self.config.SITE.test.timeout)
+        time_out_salome = DEFAULT_TIMEOUT
 
         # generate wrapper script
         script_path = os.path.join(out_path, 'wrapperScript.py')
@@ -782,7 +782,7 @@ class Test:
             self.settings.clear()
 
         # read known failures pyconf
-        if "testerror" in self.config.SITE:
+        if "testerror" in self.config.LOCAL:
             #import testerror
             #self.known_errors = testerror.read_test_failures(
             #                            self.config.TOOLS.testerror.file_path,