]> SALOME platform Git repositories - modules/kernel.git/blob - bin/appliskel/salome
Salome HOME
41e0883dc28270418112226f9eea35db12b1d856
[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     kernel_root_dir = os.getenv("KERNEL_ROOT_DIR")
66     if kernel_root_dir:
67       runner.addToLdLibraryPath(os.path.join(kernel_root_dir, "lib/salome"))
68
69     gui_root_dir = os.getenv("GUI_ROOT_DIR")
70     if gui_root_dir:
71       runner.addToLdLibraryPath(os.path.join(gui_root_dir, "lib/salome"))
72
73     paravis_root_dir = os.getenv("PARAVIS_ROOT_DIR")
74     if paravis_root_dir:
75       runner.addToLdLibraryPath(os.path.join(paravis_root_dir, "lib/salome"))
76
77
78     # Start SALOME, parsing command line arguments
79     runner.go(args)
80     print 'Thank you for using SALOME!'
81
82   except SalomeRunnerException, e:
83     import logging
84     logging.getLogger("salome").error(e)
85     sys.exit(1)
86 #
87
88 if __name__ == "__main__":
89   args = sys.argv[1:]
90   main(args)
91 #