From: Gilles DAVID Date: Wed, 7 Feb 2024 13:08:58 +0000 (+0100) Subject: [EDF29322] Take into account SALOME_APPLI_OPTIONS as a second way to pilot argument... X-Git-Tag: emc2p_1.4.0-rc1_oam X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=753e52bf8d2d73598d9ad681223cac20761f8d46;p=modules%2Fkernel.git [EDF29322] Take into account SALOME_APPLI_OPTIONS as a second way to pilot argument transmission to salome application. --- diff --git a/bin/appliskel/salome_common.py b/bin/appliskel/salome_common.py index 51cecf85f..792c24df6 100644 --- a/bin/appliskel/salome_common.py +++ b/bin/appliskel/salome_common.py @@ -19,18 +19,23 @@ # import json +import logging import os import subprocess import sys +from pathlib import Path + +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) def main(args): ''' Load modules then launch salome ''' - appliPath = os.path.realpath(os.path.dirname(os.path.abspath(__file__))) - MODULES_FILE = os.path.join(appliPath, "env_modules.json") - if os.path.isfile(MODULES_FILE): - env_modules = json.loads(open(MODULES_FILE).read()).get('env_modules') + appliPath = Path(__file__).parent.resolve() + modules_file = appliPath / "env_modules.json" + if modules_file.is_file(): + env_modules = json.loads(open(modules_file).read()).get('env_modules', []) env_modules_option = "--with-env-modules=" env_modules_l = [x for x in args if x.startswith(env_modules_option)] if env_modules_l: @@ -38,8 +43,23 @@ def main(args): args = [x for x in args if not x.startswith(env_modules_option)] env_modules_option += "%s" % ','.join(env_modules) args.append(env_modules_option) + + salome_appli_options = os.environ.get("SALOME_APPLI_OPTIONS") + if salome_appli_options: + command = "" + options = [] + if args: + command = args[0] + options = args[1:] if len(args) > 1 else [] + args = [] + if command: + args.append(command) + args = args + salome_appli_options.split() + options + + logger.debug(f"args: {args}") - os.environ["ROOT_SALOME_INSTALL"] = appliPath - proc = subprocess.Popen([os.path.join(appliPath, '.salome_run')] + args, close_fds=True) + os.environ["ROOT_SALOME_INSTALL"] = f"{appliPath}" + salome_run_script = appliPath / '.salome_run' + proc = subprocess.Popen([f"{salome_run_script}"] + args, close_fds=True) out, err = proc.communicate() sys.exit(proc.returncode)