]> SALOME platform Git repositories - modules/yacs.git/blob - bin/appliskel/salome
Salome HOME
Management of scripts+args in SALOME shell and TUI (not yet in GUI)
[modules/yacs.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   from salomeLauncherUtils import getConfigFileNames
34   configFileNames, args = getConfigFileNames(args)
35
36   # WHY? Incorrect/Inexisting files are supposed to be ignored by SalomeRunner.
37   # Might simply need bug fix; please provide test case.
38   error=False
39   for aFile in configFileNames:
40     if not os.path.isfile(aFile):
41       print "ERROR: inexisting file: "+aFile
42       error=True
43   if error:
44     sys.exit(1)
45
46
47   # Create a SalomeRunner which parses configFileNames to initialize environment
48   try:
49     from salomeRunner import SalomeRunner, SalomeRunnerException
50     runner = SalomeRunner(configFileNames)
51
52     # Here set specific variables, if needed
53     # runner.addToPath('mypath')
54     # runner.addToLdLibraryPath('myldlibrarypath')
55     # runner.addToPythonPath('mypythonpath')
56     # runner.setEnviron('myvarname', 'value')
57
58     kernel_root_dir = os.getenv("KERNEL_ROOT_DIR")
59     if kernel_root_dir:
60       runner.addToLdLibraryPath(os.path.join(kernel_root_dir, "lib/salome"))
61
62     gui_root_dir = os.getenv("GUI_ROOT_DIR")
63     if gui_root_dir:
64       runner.addToLdLibraryPath(os.path.join(gui_root_dir, "lib/salome"))
65
66     paravis_root_dir = os.getenv("PARAVIS_ROOT_DIR")
67     if paravis_root_dir:
68       runner.addToLdLibraryPath(os.path.join(paravis_root_dir, "lib/salome"))
69
70
71     # Start SALOME, parsing command line arguments
72     runner.go(args)
73     print 'Thank you for using SALOME!'
74
75   except SalomeRunnerException, e:
76     import logging
77     logging.getLogger("salome").error(e)
78     sys.exit(1)
79 #
80
81 if __name__ == "__main__":
82   args = sys.argv[1:]
83   main(args)
84 #