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