extra_tests_tag = "extra_tests"
extra_test_tag = "extra_test"
resources_tag = "resources"
+env_modules_tag = "env_modules"
+env_module_tag = "env_module"
# --- names of attributes in XML configuration file
nam_att = "name"
self.config["modules"] = []
self.config["guimodules"] = []
self.config["extra_tests"] = []
+ self.config["env_modules"] = []
parser = xml.sax.make_parser()
parser.setContentHandler(self)
parser.parse(fileName)
self.config["guimodules"].append(nam)
pass
pass
+ # --- if we are analyzing "env_module" element then store its "name" attribute
+ elif self.space == [appli_tag, env_modules_tag, env_module_tag] and \
+ nam_att in attrs.getNames():
+ nam = attrs.getValue( nam_att )
+ self.config["env_modules"].append(nam)
+ pass
# --- if we are analyzing "extra_test" element then store its "name" and "path" attributes
elif self.space == [appli_tag,extra_tests_tag,extra_test_tag] and \
nam_att in attrs.getNames() and \
print inst.args
print "Configure parser: error in configuration file %s" % filename
pass
- except:
+ except Exception as e:
print "Configure parser: Error : can not read configuration file %s, check existence and rights" % filename
+ print(e)
pass
if verbose:
'getAppliPath.py',
'kill_remote_containers.py',
'runRemote.sh',
- 'salome',
+ '.salome_run',
'update_catalogs.py',
'.bashrc',
):
pass
+ # Copy salome script
+ salome_script = open(os.path.join(appliskel_dir, "salome")).read()
+ salome_file = os.path.join(home_dir, "salome")
+ try:
+ os.remove(salome_file)
+ except:
+ pass
+ env_modules = [m.encode('utf8') for m in _config.get('env_modules', [])]
+ with open(salome_file, 'w') as fd:
+ fd.write(salome_script.replace('MODULES = []', 'MODULES = {}'.format(env_modules)))
+ os.chmod(salome_file, 0o755)
+
+
# Add .salome-completion.sh file
shutil.copyfile(os.path.join(appliskel_dir, ".salome-completion.sh"),
os.path.join(home_dir, ".salome-completion.sh"))
--- /dev/null
+#! /usr/bin/env python
+
+# Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import os
+import sys
+
+def main(args):
+ # Identify application path then locate configuration files
+ currentPath = os.path.realpath(os.path.dirname(os.path.abspath(__file__)))
+ launcherFile = os.path.basename(__file__)
+ from salome_starter import initialize
+ initialize(currentPath, launcherFile)
+
+ if len(args) == 1 and args[0] in ['--help', 'help', '-h', '--h']:
+ from salomeContext import usage
+ usage()
+ sys.exit(0)
+
+ from salomeContextUtils import getConfigFileNames
+ configFileNames, args, unexisting = getConfigFileNames(args, checkExistence=True)
+
+ if len(unexisting) > 0:
+ print "ERROR: unexisting configuration/environment file(s): " + ', '.join(unexisting)
+ sys.exit(1)
+
+ # Create a SalomeContext which parses configFileNames to initialize environment
+ from salomeContextUtils import SalomeContextException
+ try:
+ from salomeContext import SalomeContext
+ context = SalomeContext(configFileNames)
+
+ # Here set specific variables, if needed
+ # context.addToPath('mypath')
+ # context.addToLdLibraryPath('myldlibrarypath')
+ # context.addToPythonPath('mypythonpath')
+ # context.setVariable('myvarname', 'value')
+
+ # Start SALOME, parsing command line arguments
+ out, err, returncode = context.runSalome(args)
+ if out:
+ sys.stdout.write(out)
+ if err:
+ sys.stderr.write(err)
+ #print 'Thank you for using SALOME!'
+ sys.exit(returncode)
+ except SalomeContextException, e:
+ import logging
+ logging.getLogger("salome").error(e)
+ sys.exit(1)
+#
+
+if __name__ == "__main__":
+ args = sys.argv[1:]
+ main(args)
+#
#! /usr/bin/env python
-# Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
import os
+import subprocess
import sys
-def main(args):
- # Identify application path then locate configuration files
- currentPath = os.path.realpath(os.path.dirname(os.path.abspath(__file__)))
- launcherFile = os.path.basename(__file__)
- from salome_starter import initialize
- initialize(currentPath, launcherFile)
-
- if len(args) == 1 and args[0] in ['--help', 'help', '-h', '--h']:
- from salomeContext import usage
- usage()
- sys.exit(0)
-
- from salomeContextUtils import getConfigFileNames
- configFileNames, args, unexisting = getConfigFileNames(args, checkExistence=True)
-
- if len(unexisting) > 0:
- print "ERROR: unexisting configuration/environment file(s): " + ', '.join(unexisting)
- sys.exit(1)
-
- # Create a SalomeContext which parses configFileNames to initialize environment
- from salomeContextUtils import SalomeContextException
- try:
- from salomeContext import SalomeContext
- context = SalomeContext(configFileNames)
+MODULES = []
- # Here set specific variables, if needed
- # context.addToPath('mypath')
- # context.addToLdLibraryPath('myldlibrarypath')
- # context.addToPythonPath('mypythonpath')
- # context.setVariable('myvarname', 'value')
- # Start SALOME, parsing command line arguments
- out, err, returncode = context.runSalome(args)
- if out:
- sys.stdout.write(out)
- if err:
- sys.stderr.write(err)
- #print 'Thank you for using SALOME!'
- sys.exit(returncode)
- except SalomeContextException, e:
- import logging
- logging.getLogger("salome").error(e)
- sys.exit(1)
-#
+def main(args):
+ ''' Load modules then launch salome
+ '''
+ if MODULES:
+ env_modules = 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:
+ env_modules += env_modules_l[-1][len(env_modules_option):].split(',')
+ 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)
+
+ currentPath = os.path.realpath(os.path.dirname(os.path.abspath(__file__)))
+ proc = subprocess.Popen(['./.salome_run'] + args,
+ close_fds=True, cwd=currentPath)
+ out, err = proc.communicate()
+ return out, err, proc.returncode
if __name__ == "__main__":
- args = sys.argv[1:]
- main(args)
+ main(sys.argv[1:])
#
+