]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
Be able to open the application.pyconf file using 'sat config <appli> -e' even if...
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Wed, 16 Nov 2016 14:18:49 +0000 (15:18 +0100)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Wed, 16 Nov 2016 14:18:49 +0000 (15:18 +0100)
commands/config.py
commands/test.py

index 5fd9efc2a1b77981b34141b224aab49cc10a94aa..af657c9071beaa4be41864a3162aa49046bd4833 100644 (file)
@@ -387,29 +387,57 @@ class ConfigManager:
             # search APPLICATION file in all directories in configPath
             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)
             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)
-                
-            # default launcher name ('salome')
-            if ('profile' in cfg.APPLICATION and 
-                'launcher_name' not in cfg.APPLICATION.profile):
-                cfg.APPLICATION.profile.launcher_name = 'salome'
+                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:
+                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") % \
+                        { '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))
+                    do_merge = False
+
+            if do_merge:
+                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)
+                    
+                # default launcher name ('salome')
+                if ('profile' in cfg.APPLICATION and 
+                    'launcher_name' not in cfg.APPLICATION.profile):
+                    cfg.APPLICATION.profile.launcher_name = 'salome'
         
+            else:
+                cfg['open_application'] = 'yes'
+                
+            
         # =====================================================================
         # load USER config
         self.set_user_config_file(cfg)
@@ -813,7 +841,8 @@ def run(args, runner, logger):
     # case : edit user pyconf file or application file
     elif 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')
             logger.write(_("Openning %s\n" % usercfg), 3)
index 61e8207261cef0e534ab4a266fd10cd939310bb3..55c748b0304b5d7a152825951bda282e7433959c 100644 (file)
@@ -48,7 +48,7 @@ parser.add_option('s', 'session', 'list', 'sessions',
     _('Optional: indicate which session(s) to test (subdirectory of the '
       'grid).'))
 parser.add_option('', 'display', 'string', 'display',
-    _("Optional: set the display where to launch SALOME."
+    _("Optional: set the display where to launch SALOME.\n"
 "\tIf value is NO then option --show-desktop=0 will be used to launch SALOME."))
 
 def description():