]> SALOME platform Git repositories - modules/kernel.git/blob - bin/runNS.py
Salome HOME
Merging with WPDev
[modules/kernel.git] / bin / runNS.py
1 #!/usr/bin/env python
2
3 #log files localization
4
5 import os, commands, sys, re, string, socket
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         if sys.platform == "win32":
49           hname=getShortHostName()
50         else:
51           hname=socket.gethostname()
52
53         print "hname=",hname
54         
55         f=open(os.environ["OMNIORB_CONFIG"])
56         ss=re.findall("NameService=corbaname::" + hname + ":\d+", f.read())
57         print "ss = ", ss
58         f.close()
59         aPort=re.findall("\d+", ss[0])[0]
60         
61         #aSedCommand="s/.*NameService=corbaname::" + hname + ":\([[:digit:]]*\)/\1/"
62         #print "sed command = ", aSedCommand
63         #aPort = commands.getoutput("sed -e\"" + aSedCommand + "\"" + os.environ["OMNIORB_CONFIG"])
64         global process_id
65         print "port=", aPort
66         if sys.platform == "win32":          
67           #import win32pm
68           #command = ['omniNames -start ' , aPort , ' -logdir ' , '\"' + upath + '\"']
69           #os.system("start omniNames -start " + aPort + " -logdir " + "\"" + upath + "\"" )
70           command = "start omniNames -start " + aPort + " -logdir " + "\"" + upath + "\""
71           #print command
72           pid = win32pm.spawnpid( string.join(command, " "), -nc )
73           process_id[pid]=command
74         else:
75           os.system("omniNames -start " + aPort + " -logdir " + upath + " &")
76
77         print "ok"
78         print "to list contexts and objects bound int the context with the specified name : showNS "
79
80 # In LifeCycleCORBA, FactoryServer is started with rsh on the requested
81 #    computer if this Container does not exist. Default is localhost.
82 #    Others Containers are started with start_impl method of FactoryServer Container.
83 # For using rsh it is necessary to have in the ${HOME} directory a .rhosts file
84 # Warning : on RedHat the file /etc/hosts contains by default a line like :
85 # 127.0.0.1               bordolex bordolex.paris1.matra-dtv.fr localhost.localdomain localhost  
86 #   (bordolex is the station name). omniNames on bordolex will be accessible from other
87 #   computers only if the computer name is removed on that line like :
88 #   127.0.0.1               bordolex.paris1.matra-dtv.fr localhost.localdomain localhost
89
90 # To start dynamically Containers on several computers you need to
91 # put in the ${OMNIORB_CONFIG} file a computer name instead of "localhost"
92 # example : ORBInitRef NameService=corbaname::dm2s0017
93
94 # If you need to use several omniNames running on the same computer, you have to :
95 #1. put in your ${OMNIORB_CONFIG} file a computer name and port number
96 # example : ORBInitRef NameService=corbaname::dm2s0017:1515
97 #2. start omninames with this port number in runNS.sh
98 # example : omniNames -start 1515 -logdir ${BaseDir}/logs/${Username} &