Salome HOME
begin fix sat test
[tools/sat.git] / commands / config.py
index 52d4fb6ec3229a19ab90cd0ae7dc78e5dea00bef..21f861eaff430a9143e05a6d3489188b431ad55e 100644 (file)
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 
 import os
+import sys
 import platform
 import datetime
 import shutil
 import gettext
-import sys
+import pprint as PP
 
 import src
+import src.debug as DBG
 
 # internationalization
-satdir  = os.path.dirname(os.path.realpath(__file__))
+satdir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
 gettext.install('salomeTools', os.path.join(satdir, 'src', 'i18n'))
 
 # Define all possible option for config command :  sat config <options>
 parser = src.options.Options()
 parser.add_option('v', 'value', 'string', 'value',
-    _("print the value of CONFIG_VARIABLE."))
+    _("Optional: print the value of CONFIG_VARIABLE."))
+parser.add_option('g', 'debug', 'string', 'debug',
+    _("Optional: print the debugging mode value of CONFIG_VARIABLE."))
 parser.add_option('e', 'edit', 'boolean', 'edit',
-    _("edit the product configuration file."))
+    _("Optional: edit the product configuration file."))
+parser.add_option('i', 'info', 'list2', 'info',
+    _("Optional: get information on product(s). This option accepts a comma separated list."))
+parser.add_option('p', 'products', 'list2', 'products',
+    _("Optional: same as --info, for convenience."))
 parser.add_option('l', 'list', 'boolean', 'list',
-    _("list all available applications."))
+    _("Optional: list all available applications."))
+parser.add_option('', 'show_patchs', 'boolean', 'show_patchs',
+    _("Optional: synthetic list of all patches used in the application"))
+parser.add_option('', 'show_properties', 'boolean', 'show_properties',
+    _("Optional: synthetic list of all properties used in the application"))
 parser.add_option('c', 'copy', 'boolean', 'copy',
-    _("""copy a config file to the personnal config files directory.
+    _("""Optional: copy a config file to the personal config files directory.
 \tWARNING the included files are not copied.
 \tIf a name is given the new config file takes the given name."""))
 parser.add_option('n', 'no_label', 'boolean', 'no_label',
-    _("do not print labels, Works only with --value and --list."))
+    _("Internal use: do not print labels, Works only with --value and --list."))
+parser.add_option('', 'completion', 'boolean', 'completion',
+    _("Internal use: print only keys, works only with --value."))
 parser.add_option('s', 'schema', 'boolean', 'schema',
     _("Internal use."))
 
@@ -53,7 +67,7 @@ class ConfigOpener:
     def __init__(self, pathList):
         '''Initialization
         
-        :param pathList list: The list of paths where to serach a pyconf.
+        :param pathList list: The list of paths where to search a pyconf.
         '''
         self.pathList = pathList
 
@@ -77,16 +91,16 @@ class ConfigOpener:
 class ConfigManager:
     '''Class that manages the read of all the configuration files of salomeTools
     '''
-    def __init__(self, dataDir=None):
+    def __init__(self, datadir=None):
         pass
 
-    def _create_vars(self, application=None, command=None, dataDir=None):
+    def _create_vars(self, application=None, command=None, datadir=None):
         '''Create a dictionary that stores all information about machine,
            user, date, repositories, etc...
         
         :param application str: The application for which salomeTools is called.
         :param command str: The command that is called.
-        :param dataDir str: The repository that contain external data 
+        :param datadir str: The repository that contain external data 
                             for salomeTools.
         :return: The dictionary that stores all information.
         :rtype: dict
@@ -96,15 +110,37 @@ class ConfigManager:
         var['salometoolsway'] = os.path.dirname(
                                     os.path.dirname(os.path.abspath(__file__)))
         var['srcDir'] = os.path.join(var['salometoolsway'], 'src')
+        var['internal_dir'] = os.path.join(var['srcDir'], 'internal_config')
         var['sep']= os.path.sep
         
-        # dataDir has a default location
-        var['dataDir'] = os.path.join(var['salometoolsway'], 'data')
-        if dataDir is not None:
-            var['dataDir'] = dataDir
+        # datadir has a default location
+        var['datadir'] = os.path.join(var['salometoolsway'], 'data')
+        if datadir is not None:
+            var['datadir'] = datadir
 
         var['personalDir'] = os.path.join(os.path.expanduser('~'),
                                            '.salomeTools')
+        src.ensure_path_exists(var['personalDir'])
+
+        var['personal_applications_dir'] = os.path.join(var['personalDir'],
+                                                        "Applications")
+        src.ensure_path_exists(var['personal_applications_dir'])
+        
+        var['personal_products_dir'] = os.path.join(var['personalDir'],
+                                                    "products")
+        src.ensure_path_exists(var['personal_products_dir'])
+        
+        var['personal_archives_dir'] = os.path.join(var['personalDir'],
+                                                    "Archives")
+        src.ensure_path_exists(var['personal_archives_dir'])
+
+        var['personal_jobs_dir'] = os.path.join(var['personalDir'],
+                                                "Jobs")
+        src.ensure_path_exists(var['personal_jobs_dir'])
+
+        var['personal_machines_dir'] = os.path.join(var['personalDir'],
+                                                    "Machines")
+        src.ensure_path_exists(var['personal_machines_dir'])
 
         # read linux distributions dictionary
         distrib_cfg = src.pyconf.Config(os.path.join(var['srcDir'],
@@ -167,14 +203,14 @@ class ConfigManager:
         return over
 
     def get_config(self, application=None, options=None, command=None,
-                    dataDir=None):
+                    datadir=None):
         '''get the config from all the configuration files.
         
         :param application str: The application for which salomeTools is called.
         :param options class Options: The general salomeToos
                                       options (--overwrite or -l5, for example)
         :param command str: The command that is called.
-        :param dataDir str: The repository that contain 
+        :param datadir str: The repository that contain 
                             external data for salomeTools.
         :return: The final config.
         :rtype: class 'src.pyconf.Config'
@@ -188,8 +224,9 @@ class ConfigManager:
         
         # =====================================================================
         # create VARS section
-        var = self._create_vars(application=application, command=command, 
-                                dataDir=dataDir)
+        var = self._create_vars(application=application, command=command, datadir=datadir)
+        print("create_vars:\n%s" % PP.pformat(var))
+
         # add VARS to config
         cfg.VARS = src.pyconf.Mapping(cfg)
         for variable in var:
@@ -217,93 +254,226 @@ class ConfigManager:
         # apply overwrite from command line if needed
         for rule in self.get_command_line_overrides(options, ["INTERNAL"]):
             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])
+        src.pyconf.streamOpener = ConfigOpener([cfg.VARS.datadir])
         try:
-            site_cfg = src.pyconf.Config(open(os.path.join(cfg.VARS.dataDir, 
-                                                           'site.pyconf')))
+            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, local_cfg)
+
+        # When the key is "default", put the default value
+        if cfg.LOCAL.base == "default":
+            cfg.LOCAL.base = os.path.abspath(
+                                        os.path.join(cfg.VARS.salometoolsway,
+                                                     "..",
+                                                     "BASE"))
+        if cfg.LOCAL.workdir == "default":
+            cfg.LOCAL.workdir = os.path.abspath(
+                                        os.path.join(cfg.VARS.salometoolsway,
+                                                     ".."))
+        if cfg.LOCAL.log_dir == "default":
+            cfg.LOCAL.log_dir = os.path.abspath(
+                                        os.path.join(cfg.VARS.salometoolsway,
+                                                     "..",
+                                                     "LOGS"))
+
+        if cfg.LOCAL.archive_dir == "default":
+            cfg.LOCAL.archive_dir = os.path.abspath(
+                                        os.path.join(cfg.VARS.salometoolsway,
+                                                     "..",
+                                                     "ARCHIVES"))
+
+        # apply overwrite from command line if needed
+        for rule in self.get_command_line_overrides(options, ["LOCAL"]):
+            exec('cfg.' + rule) # this cannot be factorized because of the exec
         
-        # add user local path for configPath
-        site_cfg.SITE.config.config_path.append(
-                        os.path.join(cfg.VARS.personalDir, 'Applications'), 
-                        "User applications path")
+        # =====================================================================
+        # Load the PROJECTS
+        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")
         
-        merger.merge(cfg, site_cfg)
+        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(msg)
+                continue
+            project_name = os.path.basename(
+                                    project_pyconf_path)[:-len(".pyconf")]
+            try:
+                project_pyconf_dir = os.path.dirname(project_pyconf_path)
+                project_cfg = src.pyconf.Config(open(project_pyconf_path),
+                                                PWD=("", project_pyconf_dir))
+            except Exception as e:
+                msg = _("ERROR: Error in configuration file: "
+                                 "%(file_path)s\n  %(error)s\n") % \
+                            {'file_path' : project_pyconf_path, 'error': str(e) }
+                sys.stdout.write(msg)
+                continue
+            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, ["SITE"]):
+        for rule in self.get_command_line_overrides(options, ["PROJECTS"]):
             exec('cfg.' + rule) # this cannot be factorized because of the exec
-  
         
+        # =====================================================================
+        # Create the paths where to search the application configurations, 
+        # the product configurations, the products archives, 
+        # the jobs configurations and the machines configurations
+        cfg.addMapping("PATHS", src.pyconf.Mapping(cfg), "The paths\n")
+        cfg.PATHS["APPLICATIONPATH"] = src.pyconf.Sequence(cfg.PATHS)
+        cfg.PATHS.APPLICATIONPATH.append(cfg.VARS.personal_applications_dir, "")
+
+        
+        cfg.PATHS["PRODUCTPATH"] = src.pyconf.Sequence(cfg.PATHS)
+        cfg.PATHS.PRODUCTPATH.append(cfg.VARS.personal_products_dir, "")
+        cfg.PATHS["ARCHIVEPATH"] = src.pyconf.Sequence(cfg.PATHS)
+        cfg.PATHS.ARCHIVEPATH.append(cfg.VARS.personal_archives_dir, "")
+        cfg.PATHS["JOBPATH"] = src.pyconf.Sequence(cfg.PATHS)
+        cfg.PATHS.JOBPATH.append(cfg.VARS.personal_jobs_dir, "")
+        cfg.PATHS["MACHINEPATH"] = src.pyconf.Sequence(cfg.PATHS)
+        cfg.PATHS.MACHINEPATH.append(cfg.VARS.personal_machines_dir, "")
+
+        # initialise the path with local directory
+        cfg.PATHS["ARCHIVEPATH"].append(cfg.LOCAL.archive_dir, "")
+
+        # Loop over the projects in order to complete the PATHS variables
+        # as /data/tmpsalome/salome/prerequis/archives for example ARCHIVEPATH
+        for project in cfg.PROJECTS.projects:
+            for PATH in ["APPLICATIONPATH",
+                         "PRODUCTPATH",
+                         "ARCHIVEPATH", #comment this for default archive      #8646
+                         "JOBPATH",
+                         "MACHINEPATH"]:
+                if PATH not in cfg.PROJECTS.projects[project]:
+                    continue
+                cfg.PATHS[PATH].append(cfg.PROJECTS.projects[project][PATH], "")
+        
+        # apply overwrite from command line if needed
+        for rule in self.get_command_line_overrides(options, ["PATHS"]):
+            exec('cfg.' + rule) # this cannot be factorized because of the exec
+
+        # AT END append APPLI_TEST directory in APPLICATIONPATH, for unittest
+        appli_test_dir = os.path.join(satdir, "test", "APPLI_TEST")
+        if appli_test_dir not in cfg.PATHS.APPLICATIONPATH:
+          cfg.PATHS.APPLICATIONPATH.append(appli_test_dir, "unittest APPLI_TEST path")
+
         # =====================================================================
         # Load APPLICATION config file
         if application is not None:
             # search APPLICATION file in all directories in configPath
-            cp = cfg.SITE.config.config_path
+            cp = cfg.PATHS.APPLICATIONPATH
             src.pyconf.streamOpener = ConfigOpener(cp)
+            do_merge = True
             try:
                 application_cfg = src.pyconf.Config(application + '.pyconf')
             except IOError as e:
-                raise src.SatException(_("%s, use 'config --list' to get the"
-                                         " list of available applications.") %e)
+                raise src.SatException(
+                   _("%s, use 'config --list' to get the list of available applications.") % e)
             except src.pyconf.ConfigError as e:
-                raise src.SatException(_("Error in configuration file:"
-                                " %(application)s.pyconf\n  %(error)s") % \
-                    { 'application': application, 'error': str(e) } )
-
-            merger.merge(cfg, application_cfg)
-
-            # apply overwrite from command line if needed
-            for rule in self.get_command_line_overrides(options,
-                                                         ["APPLICATION"]):
-                # this cannot be factorized because of the exec
-                exec('cfg.' + rule) 
+                if (not ('-e' in parser.parse_args()[1]) 
+                                         or ('--edit' in parser.parse_args()[1]) 
+                                         and command == 'config'):
+                    raise src.SatException(_("Error in configuration file: "
+                                             "%(application)s.pyconf\n "
+                                             " %(error)s") % \
+                        { 'application': application, 'error': str(e) } )
+                else:
+                    sys.stdout.write(src.printcolors.printcWarning(
+                                        "There is an error in the file"
+                                        " %s.pyconf.\n" % cfg.VARS.application))
+                    do_merge = False
+            except Exception as e:
+                if (not ('-e' in parser.parse_args()[1]) 
+                                        or ('--edit' in parser.parse_args()[1]) 
+                                        and command == 'config'):
+                    sys.stdout.write(src.printcolors.printcWarning("%s\n" % str(e)))
+                    raise src.SatException(_("Error in configuration file:"
+                                             " %(application)s.pyconf\n") % \
+                        { 'application': application} )
+                else:
+                    sys.stdout.write(src.printcolors.printcWarning(
+                                "There is an error in the file"
+                                " %s.pyconf. Opening the file with the"
+                                " default viewer\n" % cfg.VARS.application))
+                    sys.stdout.write("The error:"
+                                 " %s\n" % src.printcolors.printcWarning(
+                                                                      str(e)))
+                    do_merge = False
         
+            else:
+                cfg['open_application'] = 'yes'
+
         # =====================================================================
-        # Load softwares config files in SOFTWARE section
-       
-        # The directory containing the softwares definition
-        softsDir = os.path.join(cfg.VARS.dataDir, 'softwares')
-        
-        # Loop on all files that are in softsDir directory 
-        # and read their config
-        for fName in os.listdir(softsDir):
-            if fName.endswith(".pyconf"):
-                src.pyconf.streamOpener = ConfigOpener([softsDir])
-                try:
-                    soft_cfg = src.pyconf.Config(open(
-                                                os.path.join(softsDir, fName)))
-                except src.pyconf.ConfigError as e:
-                    raise src.SatException(_(
-                        "Error in configuration file: %(soft)s\n  %(error)s") % \
-                        {'soft' :  fName, 'error': str(e) })
-                except IOError as error:
-                    e = str(error)
-                    raise src.SatException( e );
-                
-                merger.merge(cfg, soft_cfg)
+        # Load product config files in PRODUCTS section
+        products_cfg = src.pyconf.Config()
+        products_cfg.addMapping("PRODUCTS",
+                                src.pyconf.Mapping(products_cfg),
+                                "The products\n")
+        if application is not None:
+            src.pyconf.streamOpener = ConfigOpener(cfg.PATHS.PRODUCTPATH)
+            for product_name in application_cfg.APPLICATION.products.keys():
+                # Loop on all files that are in softsDir directory
+                # and read their config
+                product_file_name = product_name + ".pyconf"
+                product_file_path = src.find_file_in_lpath(product_file_name, cfg.PATHS.PRODUCTPATH)
+                if product_file_path:
+                    products_dir = os.path.dirname(product_file_path)
+                    try:
+                        prod_cfg = src.pyconf.Config(open(product_file_path),
+                                                     PWD=("", products_dir))
+                        prod_cfg.from_file = product_file_path
+                        products_cfg.PRODUCTS[product_name] = prod_cfg
+                    except Exception as e:
+                        msg = _(
+                            "WARNING: Error in configuration file"
+                            ": %(prod)s\n  %(error)s" % \
+                            {'prod' :  product_name, 'error': str(e) })
+                        sys.stdout.write(msg)
+            
+            merger.merge(cfg, products_cfg)
+            
+            # apply overwrite from command line if needed
+            for rule in self.get_command_line_overrides(options, ["PRODUCTS"]):
+                exec('cfg.' + rule) # this cannot be factorized because of the exec
+            
+            if do_merge:
+                merger.merge(cfg, application_cfg)
 
-        # apply overwrite from command line if needed
-        for rule in self.get_command_line_overrides(options, ["SOFTWARE"]):
-            exec('cfg.' + rule) # this cannot be factorized because of the exec
+                # default launcher name ('salome')
+                if ('profile' in cfg.APPLICATION and 
+                    'launcher_name' not in cfg.APPLICATION.profile):
+                    cfg.APPLICATION.profile.launcher_name = 'salome'
 
-        
+                # apply overwrite from command line if needed
+                for rule in self.get_command_line_overrides(options,
+                                                             ["APPLICATION"]):
+                    # this cannot be factorized because of the exec
+                    exec('cfg.' + rule)
+            
         # =====================================================================
         # load USER config
         self.set_user_config_file(cfg)
@@ -314,7 +484,7 @@ class ConfigManager:
         # apply overwrite from command line if needed
         for rule in self.get_command_line_overrides(options, ["USER"]):
             exec('cfg.' + rule) # this cannot be factorize because of the exec
-
+        
         return cfg
 
     def set_user_config_file(self, config):
@@ -325,7 +495,7 @@ class ConfigManager:
                                                  (containing all pyconf).
         '''
         # get the expected name and path of the file
-        self.config_file_name = 'salomeTools.pyconf'
+        self.config_file_name = 'SAT.pyconf'
         self.user_config_file_path = os.path.join(config.VARS.personalDir,
                                                    self.config_file_name)
         
@@ -348,16 +518,12 @@ 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,
             "This is the user name used to access salome svn base.\n")
-        user_cfg.USER.addMapping('output_level', 3,
-            "This is the default output_level you want."
+        user_cfg.USER.addMapping('output_verbose_level', 3,
+            "This is the default output_verbose_level you want."
             " 0=>no output, 5=>debug.\n")
         user_cfg.USER.addMapping('publish_dir', 
                                  os.path.join(os.path.expanduser('~'),
@@ -376,6 +542,16 @@ class ConfigManager:
                                  'evince', 
                                  "This is the pdf_viewer used "
                                  "to read pdf documentation\n")
+# CNC 25/10/17 : plus nĂ©cessaire a priori
+#        user_cfg.USER.addMapping("base",
+#                                 src.pyconf.Reference(
+#                                            user_cfg,
+#                                            src.pyconf.DOLLAR,
+#                                            'workdir  + $VARS.sep + "BASE"'),
+#                                 "The products installation base (could be "
+#                                 "ignored if this key exists in the local.pyconf"
+#                                 " file of salomTools).\n")
+               
         # 
         src.ensure_path_exists(config.VARS.personalDir)
         src.ensure_path_exists(os.path.join(config.VARS.personalDir, 
@@ -384,8 +560,6 @@ class ConfigManager:
         f = open(cfg_name, 'w')
         user_cfg.__save__(f)
         f.close()
-        print(_("You can edit it to configure salomeTools "
-                "(use: sat config --edit).\n"))
 
         return user_cfg   
 
@@ -398,8 +572,219 @@ class ConfigManager:
             raise src.SatException(_("Error in get_user_config_file: "
                                      "missing user config file path"))
         return self.user_config_file_path     
+
+def check_path(path, ext=[]):
+    '''Construct a text with the input path and "not found" if it does not
+       exist.
+    
+    :param path Str: the path to check.
+    :param ext List: An extension. Verify that the path extension 
+                     is in the list
+    :return: The string of the path with information
+    :rtype: Str
+    '''
+    # check if file exists
+    if not os.path.exists(path):
+        return "'%s'" % path + " " + src.printcolors.printcError(_(
+                                                            "** not found"))
+
+    # check extension
+    if len(ext) > 0:
+        fe = os.path.splitext(path)[1].lower()
+        if fe not in ext:
+            return "'%s'" % path + " " + src.printcolors.printcError(_(
+                                                        "** bad extension"))
+
+    return path
+
+def show_product_info(config, name, logger):
+    '''Display on the terminal and logger information about a product.
+    
+    :param config Config: the global configuration.
+    :param name Str: The name of the product
+    :param logger Logger: The logger instance to use for the display
+    '''
+    
+    logger.write(_("%s is a product\n") % src.printcolors.printcLabel(name), 2)
+    pinfo = src.product.get_product_config(config, name)
+    
+    if "depend" in pinfo:
+        src.printcolors.print_value(logger, 
+                                    "depends on", 
+                                    ', '.join(pinfo.depend), 2)
+
+    if "opt_depend" in pinfo:
+        src.printcolors.print_value(logger, 
+                                    "optional", 
+                                    ', '.join(pinfo.opt_depend), 2)
+
+    # information on pyconf
+    logger.write("\n", 2)
+    logger.write(src.printcolors.printcLabel("configuration:") + "\n", 2)
+    if "from_file" in pinfo:
+        src.printcolors.print_value(logger, 
+                                    "pyconf file path", 
+                                    pinfo.from_file, 
+                                    2)
+    if "section" in pinfo:
+        src.printcolors.print_value(logger, 
+                                    "section", 
+                                    pinfo.section, 
+                                    2)
+
+    # information on prepare
+    logger.write("\n", 2)
+    logger.write(src.printcolors.printcLabel("prepare:") + "\n", 2)
+
+    is_dev = src.product.product_is_dev(pinfo)
+    method = pinfo.get_source
+    if is_dev:
+        method += " (dev)"
+    src.printcolors.print_value(logger, "get method", method, 2)
+
+    if method == 'cvs':
+        src.printcolors.print_value(logger, "server", pinfo.cvs_info.server, 2)
+        src.printcolors.print_value(logger, "base module",
+                                    pinfo.cvs_info.module_base, 2)
+        src.printcolors.print_value(logger, "source", pinfo.cvs_info.source, 2)
+        src.printcolors.print_value(logger, "tag", pinfo.cvs_info.tag, 2)
+
+    elif method == 'svn':
+        src.printcolors.print_value(logger, "repo", pinfo.svn_info.repo, 2)
+
+    elif method == 'git':
+        src.printcolors.print_value(logger, "repo", pinfo.git_info.repo, 2)
+        src.printcolors.print_value(logger, "tag", pinfo.git_info.tag, 2)
+
+    elif method == 'archive':
+        src.printcolors.print_value(logger, 
+                                    "get from", 
+                                    check_path(pinfo.archive_info.archive_name), 
+                                    2)
+
+    if 'patches' in pinfo:
+        for patch in pinfo.patches:
+            src.printcolors.print_value(logger, "patch", check_path(patch), 2)
+
+    if src.product.product_is_fixed(pinfo):
+        src.printcolors.print_value(logger, "install_dir", 
+                                    check_path(pinfo.install_dir), 2)
+
+    if src.product.product_is_native(pinfo) or src.product.product_is_fixed(pinfo):
+        return
+    
+    # information on compilation
+    if src.product.product_compiles(pinfo):
+        logger.write("\n", 2)
+        logger.write(src.printcolors.printcLabel("compile:") + "\n", 2)
+        src.printcolors.print_value(logger, 
+                                    "compilation method", 
+                                    pinfo.build_source, 
+                                    2)
         
+        if pinfo.build_source == "script" and "compil_script" in pinfo:
+            src.printcolors.print_value(logger, 
+                                        "Compilation script", 
+                                        pinfo.compil_script, 
+                                        2)
+        
+        if 'nb_proc' in pinfo:
+            src.printcolors.print_value(logger, "make -j", pinfo.nb_proc, 2)
     
+        src.printcolors.print_value(logger, 
+                                    "source dir", 
+                                    check_path(pinfo.source_dir), 
+                                    2)
+        if 'install_dir' in pinfo:
+            src.printcolors.print_value(logger, 
+                                        "build dir", 
+                                        check_path(pinfo.build_dir), 
+                                        2)
+            src.printcolors.print_value(logger, 
+                                        "install dir", 
+                                        check_path(pinfo.install_dir), 
+                                        2)
+        else:
+            logger.write("  " + 
+                         src.printcolors.printcWarning(_("no install dir")) + 
+                         "\n", 2)
+    else:
+        logger.write("\n", 2)
+        msg = _("This product does not compile")
+        logger.write("%s\n" % msg, 2)
+
+    # information on environment
+    logger.write("\n", 2)
+    logger.write(src.printcolors.printcLabel("environ :") + "\n", 2)
+    if "environ" in pinfo and "env_script" in pinfo.environ:
+        src.printcolors.print_value(logger, 
+                                    "script", 
+                                    check_path(pinfo.environ.env_script), 
+                                    2)
+
+    zz = src.environment.SalomeEnviron(config, 
+                                       src.fileEnviron.ScreenEnviron(logger), 
+                                       False)
+    zz.set_python_libdirs()
+    zz.set_a_product(name, logger)
+    logger.write("\n", 2)
+
+
+def show_patchs(config, logger):
+  '''Prints all the used patchs in the application.
+
+  :param config Config: the global configuration.
+  :param logger Logger: The logger instance to use for the display
+  '''
+  oneOrMore = False
+  for product in sorted(config.APPLICATION.products):
+    try:
+      product_info = src.product.get_product_config(config, product)
+      if src.product.product_has_patches(product_info):
+        oneOrMore = True
+        logger.write("%s:\n" % product, 1)
+        for i in product_info.patches:
+          logger.write(src.printcolors.printcInfo("    %s\n" % i), 1)
+    except Exception as e:
+      msg = "problem on product %s\n%s\n" % (product, str(e))
+      logger.error(msg)
+
+  if oneOrMore:
+    logger.write("\n", 1)
+  else:
+    logger.write("No patchs found\n", 1)
+
+
+def show_properties(config, logger):
+  '''Prints all the used properties in the application.
+
+  :param config Config: the global configuration.
+  :param logger Logger: The logger instance to use for the display
+  '''
+  oneOrMore = False
+  for product in sorted(config.APPLICATION.products):
+    try:
+      product_info = src.product.get_product_config(config, product)
+      done = False
+      try:
+        for i in product_info.properties:
+          if not done:
+            logger.write("%s:\n" % product, 1)
+            done = True
+          oneOrMore = True
+          logger.write(src.printcolors.printcInfo("    %s\n" % i), 1)
+      except Exception as e:
+        pass
+    except Exception as e:
+      # logger.write(src.printcolors.printcInfo("    %s\n" % "no properties"), 1)
+      msg = "problem on product %s\n%s\n" % (product, e)
+      logger.error(msg)
+
+  if oneOrMore:
+    logger.write("\n", 1)
+  else:
+    logger.write("No properties found\n", 1)
+
 def print_value(config, path, show_label, logger, level=0, show_full_path=False):
     '''Prints a value from the configuration. Prints recursively the values 
        under the initial path.
@@ -460,6 +845,7 @@ def print_value(config, path, show_label, logger, level=0, show_full_path=False)
 
 def get_config_children(config, args):
     '''Gets the names of the children of the given parameter.
+       Useful only for completion mechanism
     
     :param config Config: The configuration where to read the values
     :param args: The path in the config from which get the keys
@@ -485,7 +871,8 @@ def get_config_children(config, args):
             try:
                 a = config.getByPath(head)
                 if dir(a).__contains__('keys'):
-                    vals = map(lambda x: head + '.' + x, [m for m in a.keys() if m.startswith(tail)])
+                    vals = map(lambda x: head + '.' + x,
+                               [m for m in a.keys() if m.startswith(tail)])
             except:
                 pass
 
@@ -499,12 +886,16 @@ def description():
     :rtype: str
     '''
     return _("The config command allows manipulation "
-             "and operation on config files.")
+             "and operation on config files.\n\nexample:\nsat config "
+             "SALOME-master --info ParaView")
     
 
 def run(args, runner, logger):
     '''method that is called when salomeTools is called with config parameter.
     '''
+    import src.architecture as ARCH
+    print("get_infosys %s " % PP.pformat(ARCH.get_infosys()))
+
     # Parse the options
     (options, args) = parser.parse_args(args)
 
@@ -512,7 +903,7 @@ def run(args, runner, logger):
     if options.schema:
         get_config_children(runner.cfg, args)
         return
-    
+
     # case : print a value of the config
     if options.value:
         if options.value == ".":
@@ -523,32 +914,78 @@ def run(args, runner, logger):
             print_value(runner.cfg, options.value, not options.no_label, logger, 
                         level=0, show_full_path=False)
     
+    # case : print a debug value of the config
+    if options.debug:
+        if options.debug == ".":
+            # if argument is ".", print all the config
+            res = DBG.indent(DBG.getStrConfigDbg(runner.cfg))
+            logger.write("\nConfig of application %s:\n\n%s\n" % (runner.cfg.VARS.application, res))
+        else:
+            if options.debug[0] == ".": # accept ".PRODUCT.etc" as "PRODUCT.etc"
+              od = options.debug[1:]
+            else:
+              od = options.debug
+            exec("a = runner.cfg.%s" % od)
+            res = DBG.indent(DBG.getStrConfigDbg(a))
+            logger.write("\nConfig.%s of application %s:\n\n%s\n" % (od, runner.cfg.VARS.application, res))
+
+    
     # case : edit user pyconf file or application file
-    elif options.edit:
+    if options.edit:
         editor = runner.cfg.USER.editor
-        if 'APPLICATION' not in runner.cfg: # edit user pyconf
+        if ('APPLICATION' not in runner.cfg and
+                       'open_application' not in runner.cfg): # edit user pyconf
             usercfg = os.path.join(runner.cfg.VARS.personalDir, 
-                                   'salomeTools.pyconf')
+                                   'SAT.pyconf')
+            logger.write(_("Opening %s\n" % usercfg), 3)
             src.system.show_in_editor(editor, usercfg, logger)
         else:
             # search for file <application>.pyconf and open it
-            for path in runner.cfg.SITE.config.config_path:
+            for path in runner.cfg.PATHS.APPLICATIONPATH:
                 pyconf_path = os.path.join(path, 
                                     runner.cfg.VARS.application + ".pyconf")
                 if os.path.exists(pyconf_path):
+                    logger.write(_("Opening %s\n" % pyconf_path), 3)
                     src.system.show_in_editor(editor, pyconf_path, logger)
                     break
     
+    # case : give information about the product(s) in parameter
+    if options.products:
+      if options.info is not None:
+        logger.warning('options.products %s overrides options.info %s' % (options.products, options.info))
+      options.info = options.products
+
+    if options.info:
+      # DBG.write("products", sorted(runner.cfg.APPLICATION.products.keys()), True)
+      src.check_config_has_application(runner.cfg)
+      taggedProducts = src.getProductNames(runner.cfg, options.info, logger)
+      DBG.write("tagged products", sorted(taggedProducts))
+      for prod in sorted(taggedProducts):
+        if prod in runner.cfg.APPLICATION.products:
+          try:
+            if len(taggedProducts) > 1:
+              logger.write("#################### ", 2)
+            show_product_info(runner.cfg, prod, logger)
+          except Exception as e:
+            msg = "problem on product %s\n%s\n" % (prod, str(e))
+            logger.error(msg)
+          # return
+        else:
+          msg = _("%s is not a product of %s.\n") % \
+                (prod, runner.cfg.VARS.application)
+          logger.warning(msg)
+          #raise Exception(msg)
+    
     # case : copy an existing <application>.pyconf 
     # to ~/.salomeTools/Applications/LOCAL_<application>.pyconf
-    elif options.copy:
+    if options.copy:
         # product is required
         src.check_config_has_application( runner.cfg )
 
         # get application file path 
         source = runner.cfg.VARS.application + '.pyconf'
         source_full_path = ""
-        for path in runner.cfg.SITE.config.config_path:
+        for path in runner.cfg.PATHS.APPLICATIONPATH:
             # ignore personal directory
             if path == runner.cfg.VARS.personalDir:
                 continue
@@ -565,9 +1002,9 @@ def run(args, runner, logger):
             if len(args) > 0:
                 # a name is given as parameter, use it
                 dest = args[0]
-            elif 'copy_prefix' in runner.cfg.SITE.config:
+            elif 'copy_prefix' in runner.cfg.INTERNAL.config:
                 # use prefix
-                dest = (runner.cfg.SITE.config.copy_prefix 
+                dest = (runner.cfg.INTERNAL.config.copy_prefix 
                         + runner.cfg.VARS.application)
             else:
                 # use same name as source
@@ -585,10 +1022,10 @@ def run(args, runner, logger):
             logger.write(_("%s has been created.\n") % dest_file)
     
     # case : display all the available pyconf applications
-    elif options.list:
+    if options.list:
         lproduct = list()
         # search in all directories that can have pyconf applications
-        for path in runner.cfg.SITE.config.config_path:
+        for path in runner.cfg.PATHS.APPLICATIONPATH:
             # print a header
             if not options.no_label:
                 logger.write("------ %s\n" % src.printcolors.printcHeader(path))
@@ -612,5 +1049,27 @@ def run(args, runner, logger):
                             logger.write("%s\n" % appliname)
                             
             logger.write("\n")
-    
-    
\ No newline at end of file
+
+    # case: print all the products name of the application (internal use for completion)
+    if options.completion:
+        for product_name in runner.cfg.APPLICATION.products.keys():
+            logger.write("%s\n" % product_name)
+        
+    # case : give a synthetic view of all patches used in the application
+    if options.show_patchs:
+        src.check_config_has_application(runner.cfg)
+        # Print some informations
+        logger.write(_('Patchs of application %s\n') %
+                    src.printcolors.printcLabel(runner.cfg.VARS.application), 3)
+        logger.write("\n", 2, False)
+        show_patchs(runner.cfg, logger)
+
+    # case : give a synthetic view of all patches used in the application
+    if options.show_properties:
+        src.check_config_has_application(runner.cfg)
+        # Print some informations
+        logger.write(_('Properties of application %s\n') %
+                    src.printcolors.printcLabel(runner.cfg.VARS.application), 3)
+        logger.write("\n", 2, False)
+        show_properties(runner.cfg, logger)
+