Salome HOME
remove extra_env feature
authorCédric Aguerre <cedric.aguerre@edf.fr>
Fri, 28 Oct 2016 12:51:42 +0000 (14:51 +0200)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Fri, 28 Oct 2016 13:58:24 +0000 (15:58 +0200)
bin/appliskel/.salome-completion.sh
bin/appliskel/salome
bin/salomeContextUtils.py.in
doc/salome/salome_command.dox

index 68beb5af3ebe14558f11918ea4b7d91f580d2f2e..4ddf62cd3a7be8e74ae53cee44911ebaf7c26085 100644 (file)
@@ -71,10 +71,10 @@ _salome()
         if [[ "$cur" == -* ]]; then
             case $command in
                 start)
-                    options='-t --terminal -g --gui -d --show-desktop= -o --hide-desktop -b --batch -l --logger -f --log-file= -r --resources= -x --xterm -m --modules= -e --embedded= -s --standalone= -p --portkill -k --killall -i --interp= -z --splash= -c --catch-exceptions= --print-port --nosave-config --pinter --ns-port-log= --test= --play= --gdb-session --ddd-session --valgrind-session -w --shutdown-servers= --foreground= --wake-up-session --server-launch-mode= --port= --version -h --help --with-mpi-module= --config= --extra_env='
+                    options='-t --terminal -g --gui -d --show-desktop= -o --hide-desktop -b --batch -l --logger -f --log-file= -r --resources= -x --xterm -m --modules= -e --embedded= -s --standalone= -p --portkill -k --killall -i --interp= -z --splash= -c --catch-exceptions= --print-port --nosave-config --pinter --ns-port-log= --test= --play= --gdb-session --ddd-session --valgrind-session -w --shutdown-servers= --foreground= --wake-up-session --server-launch-mode= --port= --version -h --help --with-mpi-module= --config='
                     ;;
                 shell)
-                    options='-h --help -p --port= -m --machine= -d --directory= -u --user= --with-mpi-module= --config= --extra_env='
+                    options='-h --help -p --port= -m --machine= -d --directory= -u --user= --with-mpi-module= --config='
                     ;;
                 info)
                     options='-h --help -p --ports -s --softwares -v --version'
index 90d5e1028a1ad5c8a8222d2aa086dac4406aadb2..171036b0e1e041a36aa0069af4c5490c113e907a 100755 (executable)
@@ -35,7 +35,7 @@ def main(args):
     sys.exit(0)
 
   from salomeContextUtils import getConfigFileNames
-  configFileNames, extraEnv, args, unexisting = getConfigFileNames(args, checkExistence=True)
+  configFileNames, args, unexisting = getConfigFileNames(args, checkExistence=True)
 
   if len(unexisting) > 0:
     print "ERROR: unexisting configuration/environment file(s): " + ', '.join(unexisting)
@@ -53,10 +53,6 @@ def main(args):
     # context.addToPythonPath('mypythonpath')
     # context.setVariable('myvarname', 'value')
 
-    if extraEnv:
-      for key,val in extraEnv.items():
-        context.addToVariable(key,val)
-
     # Start SALOME, parsing command line arguments
     out, err, returncode = context.runSalome(args)
     if out:
index 661f2ad904cefad9915ca63e33d20efa7c22a509..94ea4de5d42fd4c89d99f6822323fee399c95bb9 100644 (file)
@@ -87,103 +87,16 @@ def __getEnvironmentFileNames(args, optionPrefix, checkExistence):
   return configFileNames, args, unexisting
 #
 
-def __validate_pair(ob):
-  try:
-    if not (len(ob) == 2):
-      #print "Unexpected result:", ob
-      raise ValueError
-  except:
-    return False
-  return True
-#
-def __get_environment_from_batch_command(env_cmd, initial=None):
-  """
-  Take a command (either a single command or list of arguments)
-  and return the environment created after running that command.
-  Note that if the command must be a batch file or .cmd file, or the
-  changes to the environment will not be captured.
-
-  If initial is supplied, it is used as the initial environment passed
-  to the child process.
-  """
-  #if not isinstance(env_cmd, (list, tuple)):
-  #    env_cmd = [env_cmd]
-  # construct the command that will alter the environment
-  #env_cmd = subprocess.list2cmdline(env_cmd)
-  # create a tag so we can tell in the output when the proc is done
-  tag = 'Done running command'
-  # construct a command to do accomplish this
-  cmd = '{env_cmd} && echo "{tag}"'.format(**vars())
-
-  # launch the process
-  proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=initial, shell=True)
-  # parse the output sent to stdout
-  lines = proc.stdout
-  # consume whatever output occurs until the tag is reached
-  #consume(itertools.takewhile(lambda l: tag not in l, lines))
-  # define a way to handle each KEY=VALUE line
-  handle_line = lambda l: l.rstrip().split('=',1)
-  # parse key/values into pairs
-  #pairs = map(handle_line, lines)
-  pairs = []
-  cpt = 0
-  while True:
-    line = lines.readline()
-    cpt = cpt+1
-    if tag in line or cpt > 1000:
-      break
-    if line:
-      pairs.append(line.rstrip().split('=',1))
-  # make sure the pairs are valid
-  valid_pairs = filter(__validate_pair, pairs)
-  # construct a dictionary of the pairs
-  result = dict(valid_pairs)
-  # let the process finish
-  proc.communicate()
-  return result
-#
-def __subtract(ref, dic):
-  result = {}
-  for key,val in ref.items():
-    if not dic.has_key(key):
-      result[key] = val
-    else:
-      # compare values types
-      if (type(dic[key]) != type(val)):
-        result[key] = val
-      else:
-        # compare values
-        if isinstance(val, basestring):
-          tolist1 = dic[key].split(os.pathsep)
-          tolist2 = val.split(os.pathsep)
-          diff = list(set(tolist2)-set(tolist1))
-          if diff:
-            result[key] = os.pathsep.join(diff)
-        else:
-          result[key] = val
-
-  return result
-#
-
 def getConfigFileNames(args, checkExistence=False):
   configOptionPrefix = "--config="
   configArgs = [ str(x) for x in args if str(x).startswith(configOptionPrefix) ]
   if len(configArgs) == 0:
-    configFileNames, unexist1 = __getConfigFileNamesDefault(), []
+    configFileNames, unexist = __getConfigFileNamesDefault(), []
   else:
     # get configuration filenames
-    configFileNames, args, unexist1 = __getEnvironmentFileNames(args, configOptionPrefix, checkExistence)
-
-  # get extra environment
-  extraEnvFileNames, args, unexist2 = __getEnvironmentFileNames(args, "--extra_env=", checkExistence)
-  before = __get_environment_from_batch_command("env")
-  after = {}
-  for filename in extraEnvFileNames:
-    after.update(__get_environment_from_batch_command(filename))
-    pass
+    configFileNames, args, unexist = __getEnvironmentFileNames(args, configOptionPrefix, checkExistence)
 
-  extraEnv = __subtract(after,before)
-  return configFileNames, extraEnv, args, unexist1+unexist2
+  return configFileNames, args, unexist
 #
 
 def __getScriptPath(scriptName, searchPathList):
index 1bb3a45e8a79d63fb52e83929538816b4f24fc6b..7e868587b76c33ed1ebf50295bc77e23ac525b2b 100644 (file)
@@ -13,7 +13,7 @@ A launcher is a Python script that creates an execution context then starts SALO
 \section salome_launcher The salome command
 Usage of \c salome command is:
 \code
-   salome [command] [options] [--config=<file,folder,...>] [--extra_env=<file,folder,...>]
+   salome [command] [options] [--config=<file,folder,...>]
 \endcode
 
 Commands are:
@@ -46,10 +46,6 @@ This command is equivalent to runSession. It accepts the same options that can b
 To connect a Python console, use \code salome connect \endcode
 There is no options to this command. It asks user which SALOME instance to connect to.
 
-
-\section batch_files Batch files that set extra environment
-The <tt>--extra_env</tt> option is used to identify a list of batch files (or directories containing such files) that must be considered to create the SALOME execution context. Typically on linux these files are shell scripts that modify the global environment. The salome command determines environment changes implied by running these files to initialize SALOME context. Note that this functionality is not the recommanded way to set SALOME context ; it is provided for backward compatibility and convenience ; prefer \ref context_files solution.
-
 \section context_files Context files management
 The <tt>--config</tt> option is used to identify the list of configuration files or directories to be used for SALOME context creation. When this option is given, only files provided by user are considered. If user does not specify any context file SALOME will rely on context files detected in the env.d application folder. Two file formats can coexist, with a .cfg or .sh extension that are associated with the new and the former start mechanism, respectively.
 
@@ -121,9 +117,8 @@ initialize(currentPath, launcherFile)
 - Identify configuration (context) files
 \code
 from salomeContextUtils import getConfigFileNames
-configFileNames, extraEnv, args, unexisting = getConfigFileNames(args, checkExistence=True)
+configFileNames, args, unexisting = getConfigFileNames(args, checkExistence=True)
 \endcode
-extraEnv variable
 - Create a context
 \code
 context = SalomeContext(configFileNames)
@@ -135,12 +130,6 @@ The execution context can be set or overloaded using \ref salome_api, for exampl
 # context.addToPythonPath('mypythonpath')
 # context.setVariable('myvarname', 'value')
 \endcode
-- Initializing extra environment variables parsed from batch files:
-\code
-if extraEnv:
-  for key,val in extraEnv.items():
-    context.addToVariable(key,val)
-\endcode
 - Run SALOME
 \code
 (out, err), returncode = context.runSalome(args)