From 500cad7de59c39dca342b2764228483cb2ce9aaf Mon Sep 17 00:00:00 2001 From: Gilles DAVID Date: Wed, 7 Feb 2024 14:08:58 +0100 Subject: [PATCH] Prise en compte de la variable SALOME_OPTIONS --- bin/appliskel/salome_common.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/bin/appliskel/salome_common.py b/bin/appliskel/salome_common.py index 1cb1738e1..fdcbd6f5d 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) -- 2.39.2