2 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 import sys, os, re, socket
26 from Utils_Identity import getShortHostName
27 from launchConfigureParser import verbose
29 # -----------------------------------------------------------------------------
31 class NamingServer(Server):
33 USER=os.getenv('USER')
36 #os.system("mkdir -m 777 -p /tmp/logs")
37 LOGDIR="/tmp/logs/" + USER
40 if sys.platform == "win32":
41 # temporarily using home directory for Namning Service logs
42 # to be replaced with TEMP later...
43 os.environ["BaseDir"]=os.environ["HOME"]
45 os.environ["BaseDir"]="/tmp"
48 os.mkdir(os.environ["BaseDir"] + "/logs")
49 os.chmod(os.environ["BaseDir"] + "/logs", 0777)
51 #print "Can't create " + os.environ["BaseDir"] + "/logs"
54 upath = os.environ["BaseDir"] + "/logs/";
55 if sys.platform == "win32":
56 upath += os.environ["Username"];
58 upath += os.environ["USER"];
63 #print "Can't create " + upath
66 if verbose(): print "Name Service... ",
67 #hname=os.environ["HOST"] #commands.getoutput("hostname")
68 if sys.platform == "win32":
69 hname=getShortHostName();
71 hname = socket.gethostname();
74 f=open(os.environ["OMNIORB_CONFIG"])
75 ss=re.findall("NameService=corbaname::" + hname + ":\d+", f.read())
76 if verbose(): print "ss = ", ss,
81 #aPort=(ss.join().split(':'))[2];
82 #aPort=re.findall("\d+", ss[0])[0]
85 # put the log files of omniNames in different directory with port reference,
86 # it is cleaner on linux and it is a fix for salome since it is impossible to
87 # remove the log files if the corresponding omniNames has not been killed.
90 upath += "/omniNames_%s"%(aPort)
94 #print "Can't create " + upath
97 #os.system("touch " + upath + "/dummy")
98 for fname in os.listdir(upath):
100 os.remove(upath + "/" + fname)
103 #os.system("rm -f " + upath + "/omninames* " + upath + "/dummy " + upath + "/*.log")
105 #aSedCommand="s/.*NameService=corbaname::" + hname + ":\([[:digit:]]*\)/\1/"
106 #print "sed command = ", aSedCommand
107 #aPort = commands.getoutput("sed -e\"" + aSedCommand + "\"" + os.environ["OMNIORB_CONFIG"])
108 #print "port=", aPort
109 if sys.platform == "win32":
110 #print "start omniNames -start " + aPort + " -logdir " + upath
111 self.CMD=['omniNames -start ' , aPort , ' -nohostname ', ' -logdir ' , '\"' + upath + '\"', ' -errlog', '\"' + upath+'/omniNameErrors.log' + '\"']
112 #os.system("start omniNames -start " + aPort + " -logdir " + upath)
114 #self.CMD=['omniNames -start ' , aPort , ' -logdir ' , upath , ' &']
115 self.CMD=['omniNames','-start' , aPort, '-logdir' , upath, '-errlog', upath+'/omniNameErrors.log']
116 #os.system("omniNames -start " + aPort + " -logdir " + upath + " &")
118 if verbose(): print "... ok"
119 if verbose(): print "to list contexts and objects bound into the context with the specified name : showNS "
123 Server.initArgs(self)
124 if sys.platform == "win32":
125 env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + os.getenv("PATH")]
127 env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + os.getenv("LD_LIBRARY_PATH")]
128 self.CMD=['xterm', '-e']+ env_ld_library_path + ['python']
131 # In LifeCycleCORBA, FactoryServer is started with rsh on the requested
132 # computer if this Container does not exist. Default is localhost.
133 # Others Containers are started with start_impl method of FactoryServer Container.
134 # For using rsh it is necessary to have in the ${HOME} directory a .rhosts file
135 # Warning : on RedHat the file /etc/hosts contains by default a line like :
136 # 127.0.0.1 bordolex bordolex.paris1.matra-dtv.fr localhost.localdomain localhost
137 # (bordolex is the station name). omniNames on bordolex will be accessible from other
138 # computers only if the computer name is removed on that line like :
139 # 127.0.0.1 bordolex.paris1.matra-dtv.fr localhost.localdomain localhost
141 # To start dynamically Containers on several computers you need to
142 # put in the ${OMNIORB_CONFIG} file a computer name instead of "localhost"
143 # example : ORBInitRef NameService=corbaname::dm2s0017
145 # If you need to use several omniNames running on the same computer, you have to :
146 #1. put in your ${OMNIORB_CONFIG} file a computer name and port number
147 # example : ORBInitRef NameService=corbaname::dm2s0017:1515
148 #2. start omninames with this port number like in orbmodile.py
149 # example : omniNames -start 1515 -logdir ${BaseDir}/logs/${Username} &