]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Revert "bos #18467 [CEA] Remove any addition to the environment at launch done by...
authorvsr <vsr@opencascade.com>
Wed, 22 Jan 2020 08:15:48 +0000 (11:15 +0300)
committervsr <vsr@opencascade.com>
Wed, 22 Jan 2020 08:15:48 +0000 (11:15 +0300)
This reverts commit 9f8c8f2b2fe9c5542d9221871bb40020fa9cac10.

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

index 6c51ecc93aa93ee4e99d6254ec1eefc7eed1d329..1a5984cd73b7e2f200edece1cd0e00d19db603cd 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, keepEnvironment=True):
+def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None):
     ###
     # Collect launch configuration files:
     # - The environment variable "<appname>Config" (SalomeAppConfig) which can
@@ -895,18 +895,19 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None, keepEnvi
         else:
             dirs += re.split('[;|:]', os.getenv(config_var))
 
-    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)
+    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)
 
     dirs.reverse() # reverse order, like in "path" variable - FILO-style processing
 
@@ -991,7 +992,7 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None, keepEnvi
     if cmd_opts.batch is not None:
         args[batch_nam] = True
 
-    if not os.getenv("GUI_ROOT_DIR") or not os.path.isdir(os.getenv("GUI_ROOT_DIR")):
+    if not gui_available:
         args[gui_nam] = False
 
     if args[gui_nam]:
@@ -1183,8 +1184,6 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None, keepEnvi
         args[lang_nam] = cmd_opts.language
 
     # return arguments
-    if not keepEnvironment:
-        os.environ[config_var] = os.pathsep.join(dirs)
-
+    os.environ[config_var] = os.pathsep.join(dirs)
     # print("Args: ", args)
     return args
index d1cdc6000bbc2d5ea69e20b2ee5e36ecdd004f5a..e51e08cb24bf837b1dae18eac4963099996b75eb 100755 (executable)
@@ -810,8 +810,7 @@ def main(exeName=None):
         sys.exit(1)
 
     from salome_utils import getHostName
-    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)
+    args, modules_list, modules_root_dir = setenv.get_config(exeName=exeName)
     print("runSalome running on %s" % getHostName())
 
     kill_salome(args)
@@ -829,7 +828,7 @@ def main(exeName=None):
         pass
     # --
     #setenv.main()
-    setenv.set_env(args, modules_list, modules_root_dir, keepEnvironment=keep_env)
+    setenv.set_env(args, modules_list, modules_root_dir)
     clt = useSalome(args, modules_list, modules_root_dir)
     return clt,args
 
index 4858eb4cef4832f26137aa89678a6d9941cc341d..5df8fe1af5b2faec19d1adc4cddde4e680490cb2 100755 (executable)
@@ -77,7 +77,7 @@ def get_lib_dir():
 
 # -----------------------------------------------------------------------------
 
-def get_config(silent=False, exeName=None, keepEnvironment=True):
+def get_config(silent=False, exeName=None):
     """
     Get list of modules, paths.
 
@@ -90,7 +90,7 @@ def get_config(silent=False, exeName=None, keepEnvironment=True):
 
 
     import launchConfigureParser
-    args = launchConfigureParser.get_env(exeName=exeName, keepEnvironment=keepEnvironment)
+    args = launchConfigureParser.get_env(exeName=exeName)
 
 
     # Check variables <module>_ROOT_DIR
@@ -140,7 +140,7 @@ def get_config(silent=False, exeName=None, keepEnvironment=True):
 
 # -----------------------------------------------------------------------------
 
-def set_env(args, modules_list, modules_root_dir, silent=False, keepEnvironment=True):
+def set_env(args, modules_list, modules_root_dir, silent=False):
     """Add to the PATH-variables modules specific paths"""
 
     import os
@@ -167,68 +167,66 @@ def set_env(args, modules_list, modules_root_dir, silent=False, keepEnvironment=
       os.putenv('SALOME_BATCH','0')
     if args["gui"] :
         modules_list = modules_list[:] + ["GUI"]
-    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")
-                # 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),
+    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")
-                add_path(os.path.join(module_root_dir,get_lib_dir(),
+                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",
                                       python_version,"site-packages",
                                       salome_subdir),
                          "PYTHONPATH")
-                import platform
-                if platform.machine() == "x86_64":
-                    add_path(os.path.join(module_root_dir,"lib64",
-                                          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)
                     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)
-                        pass
-                    except:
-                        pass
+                except:
                     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: