6 # Preliminary work to initialize path to SALOME Python modules
8 currentPath = os.path.dirname(__file__)
9 homePath = os.path.realpath(os.environ['HOME'])
10 appliPath = os.path.relpath(currentPath, homePath)
11 absoluteAppliPath = homePath+os.sep+appliPath
12 os.environ['APPLI'] = appliPath # needed to convert .sh environment files
13 os.environ['ABSOLUTE_APPLI_PATH'] = absoluteAppliPath
15 sys.path[:0] = [absoluteAppliPath+'/bin/salome']
16 # End of preliminary work
18 def __getConfigFileNamesDefault():
21 absoluteAppliPath = os.environ['ABSOLUTE_APPLI_PATH']
22 envdDir = absoluteAppliPath + '/env.d'
23 if os.path.isdir(envdDir):
24 configFileNames = glob.glob(envdDir+os.sep+'*.cfg') + glob.glob(envdDir+os.sep+'*.sh')
25 configFileNames = [os.path.basename(x) for x in configFileNames]
29 configFileNames = [envdDir+'/'+x for x in configFileNames]
30 return configFileNames
33 def __getConfigFileNames(args):
34 # special case: configuration files are provided by user
35 # Search for command-line argument(s) --config=file1,file2,..., filen
36 configOptionPrefix = "--config="
37 configArgs = [ str(x) for x in args if str(x).startswith(configOptionPrefix) ]
39 if len(configArgs) == 0:
40 return __getConfigFileNamesDefault(), args
42 args = [ x for x in args if not x.startswith(configOptionPrefix) ]
43 files = [ x.replace(configOptionPrefix, '') for x in configArgs ]
46 configFileNames += x.split(',')
48 return configFileNames, args
51 if __name__ == "__main__":
54 # Identify application path then locate configuration files
56 configFileNames, args = __getConfigFileNames(args)
58 # Create a SalomeRunner which parses configFileNames to initialize environment
59 from salomeRunner import SalomeRunner
60 runner = SalomeRunner(configFileNames)
63 # Here set specific variables, if needed
64 # runner.addToPath('mypath')
65 # runner.addToLdLibraryPath('myldlibrarypath')
66 # runner.addToPythonPath('mypythonpath')
67 # runner.setEnviron('myvarname', 'value')
70 # Start SALOME, parsing command line arguments
73 print 'Thank you for using SALOME!'