Salome HOME
Merge branch 'V7_5_BR'
[modules/kernel.git] / bin / appliskel / salome
1 #! /usr/bin/env python
2
3 # Copyright (C) 2013-2014  CEA/DEN, EDF R&D, OPEN CASCADE
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 #
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #
21
22 import os
23 import sys
24
25 def main(args):
26   # Identify application path then locate configuration files
27   currentPath = os.path.dirname( os.path.abspath( __file__ ) )
28   launcherFile = os.path.basename(__file__)
29   from salome_starter import initialize
30   initialize(currentPath, launcherFile)
31
32   if len(args) == 1 and args[0] in ['--help', 'help', '-h', '--h']:
33     from salomeContext import usage
34     usage()
35     sys.exit(0)
36
37   from salomeContextUtils import getConfigFileNames
38   configFileNames, args, unexisting = getConfigFileNames(args, checkExistence=True)
39   if len(unexisting) > 0:
40     print "ERROR: unexisting configuration file(s): " + ', '.join(unexisting)
41     sys.exit(1)
42
43   # Create a SalomeContext which parses configFileNames to initialize environment
44   from salomeContextUtils import SalomeContextException
45   try:
46     from salomeContext import SalomeContext
47     context = SalomeContext(configFileNames)
48
49     # Here set specific variables, if needed
50     # context.addToPath('mypath')
51     # context.addToLdLibraryPath('myldlibrarypath')
52     # context.addToPythonPath('mypythonpath')
53     # context.setVariable('myvarname', 'value')
54
55     # Start SALOME, parsing command line arguments
56     (out, err), returncode = context.runSalome(args)
57     if out:
58       sys.stdout.write(out)
59     if err:
60       sys.stderr.write(err)
61     #print 'Thank you for using SALOME!'
62     sys.exit(returncode)
63   except SalomeContextException, e:
64     import logging
65     logging.getLogger("salome").error(e)
66     sys.exit(1)
67 #
68
69 if __name__ == "__main__":
70   args = sys.argv[1:]
71   main(args)
72 #