2 # -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
5 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
22 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 #log files localization
26 import os, commands, sys, re, string, socket
27 from Utils_Identity import getShortHostName
29 if sys.platform == "win32":
30 # temporarily using home directory for Namning Service logs
31 # to be replaced with TEMP later...
32 os.environ["BaseDir"]=os.environ["HOME"]
34 os.environ["BaseDir"]="/tmp"
36 os.environ["Username"]=os.environ["USER"]
38 # kill OmniNames if exists
40 #killall -q -9 omniNames
46 os.mkdir(os.environ["BaseDir"] + "/logs")
47 os.chmod(os.environ["BaseDir"] + "/logs", 0777)
49 #print "Can't create " + os.environ["BaseDir"] + "/logs"
52 upath = os.environ["BaseDir"] + "/logs/" + os.environ["Username"]
57 #print "Can't create " + upath
60 #os.system("touch " + upath + "/dummy")
61 for fname in os.listdir(upath):
63 if not fname.startswith("."): os.remove(upath + "/" + fname)
66 #os.system("rm -f " + upath + "/omninames* " + upath + "/dummy " + upath + "/*.log")
68 print "Name Service... "
69 #hname=os.environ["HOST"] #commands.getoutput("hostname")
70 if sys.platform == "win32":
71 hname=getShortHostName()
73 hname=socket.gethostname()
77 f=open(os.environ["OMNIORB_CONFIG"])
78 ss=re.findall("NameService=corbaname::" + hname + ":\d+", f.read())
81 aPort=re.findall("\d+", ss[0])[0]
83 #aSedCommand="s/.*NameService=corbaname::" + hname + ":\([[:digit:]]*\)/\1/"
84 #print "sed command = ", aSedCommand
85 #aPort = commands.getoutput("sed -e\"" + aSedCommand + "\"" + os.environ["OMNIORB_CONFIG"])
88 if sys.platform == "win32":
90 #command = ['omniNames -start ' , aPort , ' -logdir ' , '\"' + upath + '\"']
91 #os.system("start omniNames -start " + aPort + " -logdir " + "\"" + upath + "\"" )
92 command = "start omniNames -start " + aPort + " -logdir " + "\"" + upath + "\""
94 pid = win32pm.spawnpid( string.join(command, " "), -nc )
95 process_id[pid]=command
97 os.system("omniNames -start " + aPort + " -logdir " + upath + " &")
100 print "to list contexts and objects bound into the context with the specified name : showNS "
102 # In LifeCycleCORBA, FactoryServer is started with rsh on the requested
103 # computer if this Container does not exist. Default is localhost.
104 # Others Containers are started with start_impl method of FactoryServer Container.
105 # For using rsh it is necessary to have in the ${HOME} directory a .rhosts file
106 # Warning : on RedHat the file /etc/hosts contains by default a line like :
107 # 127.0.0.1 bordolex bordolex.paris1.matra-dtv.fr localhost.localdomain localhost
108 # (bordolex is the station name). omniNames on bordolex will be accessible from other
109 # computers only if the computer name is removed on that line like :
110 # 127.0.0.1 bordolex.paris1.matra-dtv.fr localhost.localdomain localhost
112 # To start dynamically Containers on several computers you need to
113 # put in the ${OMNIORB_CONFIG} file a computer name instead of "localhost"
114 # example : ORBInitRef NameService=corbaname::dm2s0017
116 # If you need to use several omniNames running on the same computer, you have to :
117 #1. put in your ${OMNIORB_CONFIG} file a computer name and port number
118 # example : ORBInitRef NameService=corbaname::dm2s0017:1515
119 #2. start omninames with this port number in runNS.sh
120 # example : omniNames -start 1515 -logdir ${BaseDir}/logs/${Username} &