]> SALOME platform Git repositories - modules/kernel.git/blob - bin/nameserver.py
Salome HOME
Updare for path with space
[modules/kernel.git] / bin / nameserver.py
1 #!/usr/bin/env python
2
3 import sys, os, re
4 #import commands
5 from server import *
6 from Utils_Identity import getShortHostName
7
8 # -----------------------------------------------------------------------------
9
10 class NamingServer(Server):
11    XTERM=""
12    USER=os.getenv('USER')
13    if USER is None:
14       USER='anonymous'
15    #os.system("mkdir -m 777 -p /tmp/logs")
16    LOGDIR="/tmp/logs/" + USER
17
18    def initNSArgs(self):
19         if sys.platform == "win32":
20           # temporarily using home directory for Namning Service logs
21           # to be replaced with TEMP later...
22           os.environ["BaseDir"]=os.environ["HOME"]
23         else:
24           os.environ["BaseDir"]="/tmp"
25      
26         try:
27           os.mkdir(os.environ["BaseDir"] + "/logs")
28         except:
29           #print "Can't create " + os.environ["BaseDir"] + "/logs"
30           pass
31         
32         upath = os.environ["BaseDir"] + "/logs/" + os.environ["Username"]
33
34         try:
35           os.mkdir(upath)
36         except:
37           #print "Can't create " + upath
38           pass
39
40         #os.system("touch " + upath + "/dummy")
41         for fname in os.listdir(upath):
42           try:
43             os.remove(upath + "/" + fname)
44           except:
45             pass
46         #os.system("rm -f " + upath + "/omninames* " + upath + "/dummy " + upath + "/*.log")
47
48         print "Name Service... "
49         #hname=os.environ["HOST"] #commands.getoutput("hostname")
50         hname=getShortHostName()
51         print "hname=",hname
52         
53         f=open(os.environ["OMNIORB_CONFIG"])
54         ss=re.findall("NameService=corbaname::" + hname + ":\d+", f.read())
55         print "ss = ", ss
56         f.close()
57         aPort=re.findall("\d+", ss[0])[0]
58         
59         #aSedCommand="s/.*NameService=corbaname::" + hname + ":\([[:digit:]]*\)/\1/"
60         #print "sed command = ", aSedCommand
61         #aPort = commands.getoutput("sed -e\"" + aSedCommand + "\"" + os.environ["OMNIORB_CONFIG"])
62         print "port=", aPort
63         if sys.platform == "win32":
64           #print "start omniNames -start " + aPort + " -logdir " + upath
65           self.CMD=['omniNames -start ' , aPort , ' -logdir ' , upath]
66           #os.system("start omniNames -start " + aPort + " -logdir " + upath)
67         else:
68           self.CMD=['omniNames -start ' , aPort , ' -logdir ' , upath , ' &']
69           #os.system("omniNames -start " + aPort + " -logdir " + upath + " &")
70
71         print "ok"
72         print "to list contexts and objects bound int the context with the specified name : showNS "
73
74
75    def initArgs(self):
76         Server.initArgs(self)
77         if sys.platform == "win32":
78           env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + os.getenv("PATH")]
79         else:
80           env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + os.getenv("LD_LIBRARY_PATH")]
81         self.CMD=['xterm', '-e']+ env_ld_library_path + ['python']
82         self.initNSArgs()
83
84         
85 # In LifeCycleCORBA, FactoryServer is started with rsh on the requested
86 #    computer if this Container does not exist. Default is localhost.
87 #    Others Containers are started with start_impl method of FactoryServer Container.
88 # For using rsh it is necessary to have in the ${HOME} directory a .rhosts file
89 # Warning : on RedHat the file /etc/hosts contains by default a line like :
90 # 127.0.0.1               bordolex bordolex.paris1.matra-dtv.fr localhost.localdomain localhost  
91 #   (bordolex is the station name). omniNames on bordolex will be accessible from other
92 #   computers only if the computer name is removed on that line like :
93 #   127.0.0.1               bordolex.paris1.matra-dtv.fr localhost.localdomain localhost
94
95 # To start dynamically Containers on several computers you need to
96 # put in the ${OMNIORB_CONFIG} file a computer name instead of "localhost"
97 # example : ORBInitRef NameService=corbaname::dm2s0017
98
99 # If you need to use several omniNames running on the same computer, you have to :
100 #1. put in your ${OMNIORB_CONFIG} file a computer name and port number
101 # example : ORBInitRef NameService=corbaname::dm2s0017:1515
102 #2. start omninames with this port number like in orbmodile.py
103 # example : omniNames -start 1515 -logdir ${BaseDir}/logs/${Username} &