3 import os,psutil,subprocess,socket,sys
4 from omniORB
import CORBA
12 for p
in psutil.process_iter():
15 if filter(
lambda c: c.local_address[1] == port_number, p.get_connections()):
16 print "\033[31m[rtmlaunch]", p.name,
"is already started with port", port_number,
"\033[0m" 19 orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
20 nameserver = orb.resolve_initial_references(
"NameService")
21 rootnc = nameserver._narrow(CosNaming.NamingContext)
22 def findObject(name, kind="", rnc=None) :
23 nc = CosNaming.NameComponent(name, kind)
24 if not rnc: rnc = rootnc
25 return rnc.resolve([nc])
26 cxt = findObject(socket.gethostname(),
"host_cxt")
27 obj = findObject(
"manager",
"mgr", cxt)
29 except CosNaming.NamingContext.NotFound, ex:
34 print "\033[31m[rtmlaunch] name server is unreachable so kill process\033[0m" 35 print "\033[31m[rtmlaunch] kill ", cosnames,
" of pid", p.pid,
"\033[0m" 41 print "\033[31m[rtmlaunch] do not start", cosnames,
", exiting...\033[0m" 44 print "\033[34m[rtmlaunch] Start", cosnames,
"at port", port_number,
"\033[0m" 46 hostname = socket.gethostname()
48 os.remove(logdir+
"/omninames-"+hostname+
".log")
49 os.remove(logdir+
"/omninames-"+hostname+
".bak")
53 p = subprocess.Popen([cosnames,
"-start", str(port_number),
"-always",
"-logdir", logdir])