#! /usr/bin/env python3
-# Copyright (C) 2013-2022 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
from salomeContextUtils import SalomeContextException
-def usage():
+def usage(appended_cmd_doc = "", appended_opt_doc = ""):
+ add_in_help = {"appended_cmd_doc":appended_cmd_doc,"appended_opt_doc":appended_opt_doc}
msg = '''\
-Usage: salome [command] [options] [--config=<file,folder,...>]
+Usage: salome [command] [options] [--config=<file,folder,...>] [--with-env-modules=<env_module1,env_module2,...>]
Commands:
=========
Port numbers must be separated by blank characters.
killall Terminate *all* SALOME running SWS instances for current user.
Do not start a new one.
-
+%(appended_cmd_doc)s
If no command is given, default is start.
Command options:
Initialize SALOME context from a list of context files and/or a list
of folders containing context files. The list is comma-separated, without
any blank characters.
+
+--with-env-modules=<env_module1,env_module2,...>
+================================================
+ Initialize SALOME context with the provided additional environment modules.
+ The list is comma-separated, without any blank characters.
+%(appended_opt_doc)s
'''
- print(msg)
+ print(msg%add_in_help)
#
"""
os.environ[name] = env + separator + value
return
+ """Remove value from environment variable"""
+ def removeFromVariable(self, name, value, separator=os.pathsep):
+ if value == '':
+ return
+
+ value = os.path.expandvars(value) # expand environment variables
+ self.getLogger().debug("Remove from %s: %s", name, value)
+ env = os.getenv(name, None)
+ if env == value:
+ env = ''
+ else:
+ # env = env.removeprefix(value + separator) (Python >= 3.9)
+ str = value + separator
+ if env.startswith(str):
+ env = env[len(str):]
+ # env = env.removesuffix(separator + value) (Python >= 3.9)
+ str = separator + value
+ if env.endswith(str):
+ env = env[:-len(str)]
+ env = env.replace(separator + value + separator, ':')
+
+ os.environ[name] = env
+ #
+
###################################
# This begins the private section #
###################################
def _runRemote(self, args=None):
if args is None:
args = []
-# complete salome environment
+# complete salome environment
sys.argv = ['runRemote']
import setenv
setenv.main(True)