]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Revert "Revert "bos #18467 [CEA] Remove any addition to the environment at launch...
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 30 Jan 2020 09:22:13 +0000 (10:22 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 30 Jan 2020 09:22:13 +0000 (10:22 +0100)
This reverts commit b89278d39d8754cfd07cb3e7960eaf1d7a992239.

bin/launchConfigureParser.py
bin/runSalome.py
bin/setenv.py

index 1a5984cd73b7e2f200edece1cd0e00d19db603cd..6c51ecc93aa93ee4e99d6254ec1eefc7eed1d329 100644 (file)
@@ -832,7 +832,7 @@ Python file arguments, if any, must be comma-separated (without blank characters
 args = {}
 #def get_env():
 #args = []
-def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None):
+def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None, keepEnvironment=True):
     ###
     # Collect launch configuration files:
     # - The environment variable "<appname>Config" (SalomeAppConfig) which can
@@ -895,19 +895,18 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None):
         else:
             dirs += re.split('[;|:]', os.getenv(config_var))
 
-    gui_available = False
-    if os.getenv("GUI_ROOT_DIR"):
-        gui_resources_dir = os.path.join(os.getenv("GUI_ROOT_DIR"),'share','salome','resources','gui')
-        if os.path.isdir(gui_resources_dir):
-            gui_available = True
-            dirs.append(gui_resources_dir)
-        pass
-    if not gui_available:
-        kernel_resources_dir = os.path.join(os.getenv("KERNEL_ROOT_DIR"),'bin','salome','appliskel')
-        if os.getenv("KERNEL_ROOT_DIR") and os.path.isdir( kernel_resources_dir ):
-          dirs.append(kernel_resources_dir)
-        pass
-    os.environ[config_var] = os.pathsep.join(dirs)
+    if not keepEnvironment:
+        if os.getenv("GUI_ROOT_DIR") and os.path.isdir(os.getenv("GUI_ROOT_DIR")):
+            gui_resources_dir = os.path.join(os.getenv("GUI_ROOT_DIR"),'share','salome','resources','gui')
+            if os.path.isdir(gui_resources_dir):
+                dirs.append(gui_resources_dir)
+            pass
+        else:
+            kernel_resources_dir = os.path.join(os.getenv("KERNEL_ROOT_DIR"),'bin','salome','appliskel')
+            if os.getenv("KERNEL_ROOT_DIR") and os.path.isdir( kernel_resources_dir ):
+              dirs.append(kernel_resources_dir)
+            pass
+        os.environ[config_var] = os.pathsep.join(dirs)
 
     dirs.reverse() # reverse order, like in "path" variable - FILO-style processing
 
@@ -992,7 +991,7 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None):
     if cmd_opts.batch is not None:
         args[batch_nam] = True
 
-    if not gui_available:
+    if not os.getenv("GUI_ROOT_DIR") or not os.path.isdir(os.getenv("GUI_ROOT_DIR")):
         args[gui_nam] = False
 
     if args[gui_nam]:
@@ -1184,6 +1183,8 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None):
         args[lang_nam] = cmd_opts.language
 
     # return arguments
-    os.environ[config_var] = os.pathsep.join(dirs)
+    if not keepEnvironment:
+        os.environ[config_var] = os.pathsep.join(dirs)
+
     # print("Args: ", args)
     return args
index e51e08cb24bf837b1dae18eac4963099996b75eb..d1cdc6000bbc2d5ea69e20b2ee5e36ecdd004f5a 100755 (executable)
@@ -810,7 +810,8 @@ def main(exeName=None):
         sys.exit(1)
 
     from salome_utils import getHostName
-    args, modules_list, modules_root_dir = setenv.get_config(exeName=exeName)
+    keep_env = not os.getenv('SALOME_PLEASE_SETUP_ENVIRONMENT_AS_BEFORE')
+    args, modules_list, modules_root_dir = setenv.get_config(exeName=exeName, keepEnvironment=keep_env)
     print("runSalome running on %s" % getHostName())
 
     kill_salome(args)
@@ -828,7 +829,7 @@ def main(exeName=None):
         pass
     # --
     #setenv.main()
-    setenv.set_env(args, modules_list, modules_root_dir)
+    setenv.set_env(args, modules_list, modules_root_dir, keepEnvironment=keep_env)
     clt = useSalome(args, modules_list, modules_root_dir)
     return clt,args
 
index ec968d5e3963d8fe6902e93af37238435dbad597..7ad4a8fb873e1a50167df72b236cdc9c8e5e2e6f 100755 (executable)
@@ -77,7 +77,7 @@ def get_lib_dir():
 
 # -----------------------------------------------------------------------------
 
-def get_config(silent=False, exeName=None):
+def get_config(silent=False, exeName=None, keepEnvironment=True):
     """
     Get list of modules, paths.
 
@@ -90,7 +90,7 @@ def get_config(silent=False, exeName=None):
 
 
     import launchConfigureParser
-    args = launchConfigureParser.get_env(exeName=exeName)
+    args = launchConfigureParser.get_env(exeName=exeName, keepEnvironment=keepEnvironment)
 
 
     # Check variables <module>_ROOT_DIR
@@ -140,7 +140,7 @@ def get_config(silent=False, exeName=None):
 
 # -----------------------------------------------------------------------------
 
-def set_env(args, modules_list, modules_root_dir, silent=False):
+def set_env(args, modules_list, modules_root_dir, silent=False, keepEnvironment=True):
     """Add to the PATH-variables modules specific paths"""
 
     import os
@@ -167,66 +167,68 @@ def set_env(args, modules_list, modules_root_dir, silent=False):
       os.putenv('SALOME_BATCH','0')
     if args["gui"] :
         modules_list = modules_list[:] + ["GUI"]
-    modules_list = modules_list[:] + ["KERNEL"]
-    for module in modules_list :
-        if module in modules_root_dir:
-            module_root_dir = modules_root_dir[module]
-            if module_root_dir not in modules_root_dir_list:
-              modules_root_dir_list[:0] = [module_root_dir]
-            if sys.platform == "win32":
-              add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir),
-                     "PATH")
-            elif sys.platform == "darwin":
-              add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir),
-                     "DYLD_LIBRARY_PATH")
-            else:
-              add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir),
-                     "LD_LIBRARY_PATH")
-            add_path(os.path.join(module_root_dir,"bin",salome_subdir),
-                     "PATH")
-            if os.path.exists(os.path.join(module_root_dir, "examples")):
-                add_path(os.path.join(module_root_dir,"examples"),
+    if not keepEnvironment:
+        modules_list = modules_list[:] + ["KERNEL"]
+        for module in modules_list :
+            if module in modules_root_dir:
+                module_root_dir = modules_root_dir[module]
+                if module_root_dir not in modules_root_dir_list:
+                  modules_root_dir_list[:0] = [module_root_dir]
+                if sys.platform == "win32":
+                  add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir),
+                         "PATH")
+                elif sys.platform == "darwin":
+                  add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir),
+                         "DYLD_LIBRARY_PATH")
+                else:
+                  add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir),
+                         "LD_LIBRARY_PATH")
+                add_path(os.path.join(module_root_dir,"bin",salome_subdir),
+                         "PATH")
+                if os.path.exists(os.path.join(module_root_dir, "examples")):
+                    add_path(os.path.join(module_root_dir,"examples"),
+                             "PYTHONPATH")
+                    pass
+                add_path(os.path.join(module_root_dir,"bin",salome_subdir),
                          "PYTHONPATH")
-                pass
-            add_path(os.path.join(module_root_dir,"bin",salome_subdir),
-                     "PYTHONPATH")
-            # add lib before site-packages to load script instead of dll if any (win32 platform)
-            add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir),
-                     "PYTHONPATH")
-            add_path(os.path.join(module_root_dir,get_lib_dir(),
-                                  python_version,"site-packages",
-                                  salome_subdir),
-                     "PYTHONPATH")
-            import platform
-            if platform.machine() == "x86_64":
-                add_path(os.path.join(module_root_dir,"lib64",
+                # add lib before site-packages to load script instead of dll if any (win32 platform)
+                add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir),
+                         "PYTHONPATH")
+                add_path(os.path.join(module_root_dir,get_lib_dir(),
                                       python_version,"site-packages",
                                       salome_subdir),
                          "PYTHONPATH")
-                pass
-            add_path(os.path.join(module_root_dir,get_lib_dir(),
-                                  python_version,"site-packages",
-                                  salome_subdir,
-                                  "shared_modules"),
-                     "PYTHONPATH")
-
-            # set environment by modules from the list
-            if port:
-                try:
-                    mod=__import__(module.lower()+"_setenv")
-                    mod.set_env(args)
+                import platform
+                if platform.machine() == "x86_64":
+                    add_path(os.path.join(module_root_dir,"lib64",
+                                          python_version,"site-packages",
+                                          salome_subdir),
+                             "PYTHONPATH")
                     pass
-                except:
+                add_path(os.path.join(module_root_dir,get_lib_dir(),
+                                      python_version,"site-packages",
+                                      salome_subdir,
+                                      "shared_modules"),
+                         "PYTHONPATH")
+
+                # set environment by modules from the list
+                if port:
+                    try:
+                        mod=__import__(module.lower()+"_setenv")
+                        mod.set_env(args)
+                        pass
+                    except:
+                        pass
                     pass
                 pass
             pass
-        pass
 
-    if sys.platform == 'win32':
-        os.environ["SALOMEPATH"]=";".join(modules_root_dir_list)
-    else:
-        os.environ["SALOMEPATH"]=":".join(modules_root_dir_list)
+        if sys.platform == 'win32':
+            os.environ["SALOMEPATH"]=";".join(modules_root_dir_list)
+        else:
+            os.environ["SALOMEPATH"]=":".join(modules_root_dir_list)
 
+        pass
     # set trace environment variable
 
     if "SALOME_trace" not in os.environ: