Salome HOME
Merge branch 'rbe/evol-job-newparams'
[modules/kernel.git] / bin / ORBConfigFile.py
1 #!/usr/bin/env python
2 #  -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
4 #
5 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 #
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
12 #
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 # Lesser General Public License for more details.
17 #
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21 #
22 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #
24
25 # IMPORTANT NOTE: do not add any print call (cf. note at the bottom of the file)
26 def writeORBConfigFile(path, host, port, kwargs={}):
27
28   from salome_utils import generateFileName
29   omniorb_config = generateFileName(path, prefix="omniORB",
30                                     extension="cfg",
31                                     hidden=True,
32                                     with_hostname=True,
33                                     with_port=port,
34                                     **kwargs)
35   import os
36   os.environ['OMNIORB_CONFIG'] = omniorb_config
37   os.environ['NSPORT'] = "%s"%(port)
38   os.environ['NSHOST'] = "%s"%(host)
39
40   from omniORB import CORBA
41   prefix = "" if CORBA.ORB_ID == "omniORB4" else "ORB"
42
43   GIOP_MaxMsgSize=2097152000  # 2 GBytes
44
45   orbdata = []
46   orbdata.append("%sInitRef = NameService=corbaname::%s:%s"%(prefix,host,port))
47   orbdata.append("%sgiopMaxMsgSize = %s # 2 GBytes"%(prefix,GIOP_MaxMsgSize))
48   orbdata.append("%straceLevel = 0 # critical errors only"%(prefix))
49   orbdata.append("%smaxGIOPConnectionPerServer = 50 # to allow containers parallel launch"%(prefix))
50   orbdata.append("")
51
52   f = open(omniorb_config, "w")
53   f.write("\n".join(orbdata))
54   f.close()
55
56   return [ omniorb_config, GIOP_MaxMsgSize ]
57
58 # -----------------------------------------------------------------------------
59
60 if __name__ == "__main__":
61   import sys, getopt
62
63   path = sys.argv[1]
64   host = sys.argv[2]
65   port = sys.argv[3]
66   argv = sys.argv[4:]
67
68   kwargs = {}
69   for a in argv:
70     alist = str(a).split("=", 1)
71     opt = str(alist[0])
72     arg = alist[1]
73     kwargs[opt] = arg
74     pass
75
76   [ filename, msgSize ] = writeORBConfigFile(path, host, port, kwargs)
77
78   # :TRICKY: print values so they can be read from caller bash script
79   # Example of bash script:
80   # RETURN_VALUES=$(python ORBConfigFile.py path host port)
81   # RETURN_VALUE_1=$(echo ${RETURN_VALUES} | cut -d' ' -f1)
82   # RETURN_VALUE_2=$(echo ${RETURN_VALUES} | cut -d' ' -f2)
83   # ...
84   # IMPORTANT NOTE: this print call MUST BE the first one!!
85   print filename, msgSize