]> SALOME platform Git repositories - modules/kernel.git/blob - bin/appliskel/salome
Salome HOME
0f402bf7d6aa7482486b2e11e1dbee0151270fc2
[modules/kernel.git] / bin / appliskel / salome
1 #! /usr/bin/env python
2
3 import os
4 import sys
5
6 # Preliminary work to initialize path to SALOME Python modules
7 def __initialize():
8   currentPath = os.path.dirname(__file__)
9   homePath = os.path.realpath(os.path.expanduser('~'))
10   appliPath = os.path.relpath(currentPath, homePath)
11
12   pattern = "/bin/salome/appliskel"
13   if appliPath.endswith(pattern):
14     appliPath = appliPath[:-len(pattern)]
15
16   absoluteAppliPath = os.path.join(homePath, appliPath)
17   os.environ['APPLI'] = appliPath # needed to convert .sh environment files
18   os.environ['ABSOLUTE_APPLI_PATH'] = absoluteAppliPath
19
20   # define folder to store omniorb config (initially in virtual application folder)
21   #omniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS")
22   omniorbUserPath = os.path.join(homePath, appliPath, "USERS")
23   os.environ['OMNIORB_USER_PATH'] = omniorbUserPath
24   if not os.path.exists(omniorbUserPath):
25     os.makedirs(omniorbUserPath)
26
27   sys.path[:0] = [absoluteAppliPath+'/bin/salome']
28 # End of preliminary work
29
30 def main(args):
31   # Identify application path then locate configuration files
32   __initialize()
33
34   if args == ['--help']:
35     from salomeRunner import usage
36     usage()
37     sys.exit(0)
38
39
40   from salomeLauncherUtils import getConfigFileNames
41   configFileNames, args = getConfigFileNames(args)
42
43   # WHY? Incorrect/Inexisting files are supposed to be ignored by SalomeRunner.
44   # Might simply need bug fix; please provide test case.
45   error=False
46   for aFile in configFileNames:
47     if not os.path.isfile(aFile):
48       print "ERROR: inexisting file: "+aFile
49       error=True
50   if error:
51     sys.exit(1)
52
53
54   # Create a SalomeRunner which parses configFileNames to initialize environment
55   try:
56     from salomeRunner import SalomeRunner, SalomeRunnerException
57     runner = SalomeRunner(configFileNames)
58
59     # Here set specific variables, if needed
60     # runner.addToPath('mypath')
61     # runner.addToLdLibraryPath('myldlibrarypath')
62     # runner.addToPythonPath('mypythonpath')
63     # runner.setEnviron('myvarname', 'value')
64
65     # Start SALOME, parsing command line arguments
66     runner.go(args)
67     print 'Thank you for using SALOME!'
68
69   except SalomeRunnerException, e:
70     import logging
71     logging.getLogger("salome").error(e)
72     sys.exit(1)
73 #
74
75 if __name__ == "__main__":
76   args = sys.argv[1:]
77   main(args)
78 #