- # Identify application path then locate configuration files
- __initialize()
-
- if args == ['--help']:
- 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 file(s): " + ', '.join(unexisting)
- sys.exit(1)
-
- # Create a SalomeContext which parses configFileNames to initialize environment
- try:
- from salomeContext import SalomeContext, SalomeContextException
- 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
- context.runSalome(args)
- #print 'Thank you for using SALOME!'
-
- except SalomeContextException, e:
- import logging
- logging.getLogger("salome").error(e)
- sys.exit(1)
-#
+ ''' 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)
+
+ appliPath = os.path.dirname(os.path.realpath(__file__))
+ proc = subprocess.Popen([os.path.join(appliPath, '.salome_run')] + args, close_fds=True)
+ out, err = proc.communicate()
+ sys.exit(proc.returncode)