Salome HOME
EDF bug 17743, salome.sg regressions in DEV (missing getAllSelected method)
[modules/kernel.git] / bin / appliskel / .salome_run
1 #! /usr/bin/env python3
2
3 # Copyright (C) 2013-2016  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.realpath(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     
40     if len(unexisting) > 0:
41         print("ERROR: unexisting configuration/environment file(s): " + ', '.join(unexisting))
42         sys.exit(1)
43     
44     # Create a SalomeContext which parses configFileNames to initialize environment
45     from salomeContextUtils import SalomeContextException
46     try:
47         from salomeContext import SalomeContext
48         context = SalomeContext(configFileNames)
49         
50         # Here set specific variables, if needed
51         # context.addToPath('mypath')
52         # context.addToLdLibraryPath('myldlibrarypath')
53         # context.addToPythonPath('mypythonpath')
54         # context.setVariable('myvarname', 'value')
55         
56         # Start SALOME, parsing command line arguments
57         out, err, returncode = context.runSalome(args)
58         if out:
59           sys.stdout.write(out)
60         if err:
61           sys.stderr.write(err)
62         #print('Thank you for using SALOME!')
63         sys.exit(returncode)
64     except SalomeContextException as e:
65         import logging
66         logging.getLogger("salome").error(e)
67         sys.exit(1)
68 #
69
70 if __name__ == "__main__":
71     args = sys.argv[1:]
72     main(args)