]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Allow to pass path to study to subprocess launching script with : -t <path_study... agy/29134_4
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 1 Mar 2022 10:25:58 +0000 (11:25 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 1 Mar 2022 10:25:58 +0000 (11:25 +0100)
bin/runSalome.py
src/KERNEL_PY/__init__.py

index fc4c9afc7a70b9f7eb15edf165330ea1ef734632..f89d1be6642f8a9cff9cbec08144945a61ec0cae 100755 (executable)
@@ -182,13 +182,14 @@ def main(exeName=None):
     ior_fakens_filename = useSalome(args, modules_list, modules_root_dir)
     # Management of -t <script.py>
     toimport = []
+    env = os.environ
     if 'gui' in args and 'session_gui' in args:
         if not args['gui'] or not args['session_gui']:
             if 'study_hdf' in args:
                 toopen = args['study_hdf']
                 if toopen:
-                    import salome
-                    salome.salome_init(path=toopen)
+                    os.environ["PATH_TO_STUDY_FILE_TO_INITIATE"] = toopen
+                    logger.debug("An input Study has been specified {} -> pass it with PATH_TO_STUDY_FILE_TO_INITIATE env var".format(toopen))
             if 'pyscript' in args:
                 toimport = args['pyscript']
     from salomeContextUtils import formatScriptsAndArgs
@@ -196,7 +197,7 @@ def main(exeName=None):
     command = formatScriptsAndArgs(toimport, escapeSpaces=True)
     if command:
         logger.debug("Launching following shell command : {}".format(str(command)))
-        proc = subprocess.Popen(command, shell=True)
+        proc = subprocess.Popen(command, shell=True, env = env)
         addToKillList(proc.pid, command)
         res = proc.wait()
         if res: sys.exit(1) 
index d2be57dfc30154a84127bf78a2d12c67f7a4737a..aa27871762a8c4525efe337aca7f4ea03c3a26ae 100644 (file)
@@ -177,9 +177,14 @@ def salome_init(path=None, embedded=False, iorfakensfile=None):
     """
     :param iorfakensfile: filename inside which IOR of fake NS will be written
     """
+    PATH_TO_STUDY_FILE_TO_INITIATE = "PATH_TO_STUDY_FILE_TO_INITIATE"
     import KernelBasis
     if KernelBasis.getSSLMode():
         if KernelBasis.getIOROfEmbeddedNS() == "":
+            import os
+            # make runSalome.py -t study.hdf toto.py
+            if path is None and PATH_TO_STUDY_FILE_TO_INITIATE in os.environ:
+                path = os.environ[PATH_TO_STUDY_FILE_TO_INITIATE]
             salome_init_without_session(path, embedded, iorfakensfile)
         else:
             salome_init_without_session_attached(path, embedded)