From: Anthony Geay Date: Tue, 1 Mar 2022 10:25:58 +0000 (+0100) Subject: Allow to pass path to study to subprocess launching script with : -t --- diff --git a/bin/runSalome.py b/bin/runSalome.py index fc4c9afc7..f89d1be66 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -182,13 +182,14 @@ def main(exeName=None): ior_fakens_filename = useSalome(args, modules_list, modules_root_dir) # Management of -t 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) diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py index d2be57dfc..aa2787176 100644 --- a/src/KERNEL_PY/__init__.py +++ b/src/KERNEL_PY/__init__.py @@ -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)