Skip to content

Commit

Permalink
check nshost nsport mgrhost mgrport individually
Browse files Browse the repository at this point in the history
  • Loading branch information
ishiguroJSK committed Oct 22, 2018
1 parent ffdfc69 commit b1b8ef3
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions python/rtm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
rootnc = None
nshost = None
nsport = None
mgrhost = None
mgrport = None

##
Expand Down Expand Up @@ -312,8 +313,7 @@ def unbindObject(name, kind):
# \brief initialize ORB
#
def initCORBA():
global rootnc, orb, nshost, nsport, mgrport
mgrhost = None # will be unused
global rootnc, orb, nshost, nsport, mgrhost, mgrport

# from omniorb's document
# When CORBA::ORB_init() is called, the value for each configuration
Expand All @@ -331,25 +331,43 @@ def initCORBA():
mc = OpenRTM_aist.ManagerConfig();
mc.parseArgs(rtm_argv)

if nshost != None or nsport != None: # nshost and nsport can be set via other script like "import rtm; rtm.nshost=XXX"
print("\033[34m[rtm.py] nshost or nsport already set as " + str(nshost) + ":" + str(nsport) + "\033[0m")
if nshost != None: # these values can be set via other script like "import rtm; rtm.nshost=XXX"
print("\033[34m[rtm.py] nshost already set as " + str(nshost) + "\033[0m")
else:
try:
nshost, nsport = mc._argprop.getProperty("corba.nameservers").split(":")
nshost = mc._argprop.getProperty("corba.nameservers").split(":")[0]
if not nshost:
raise
except:
nshost = socket.gethostname() # default
print("\033[34m[rtm.py] Failed to parse corba.nameservers, use " + str(nshost) + " as nshost \033[0m")

if nsport != None:
print("\033[34m[rtm.py] nsport already set as " + str(nsport) + "\033[0m")
else:
try:
nsport = int(mc._argprop.getProperty("corba.nameservers").split(":")[1])
if not nsport:
raise
except:
nshost = socket.gethostname()
nsport = 15005 # default
print("\033[34m[rtm.py] No corba.nameservers set, use " + nshost + ":" + str(nsport) + "\033[0m")
print("\033[34m[rtm.py] Failed to parse corba.nameservers, use " + str(nsport) + " as nsport \033[0m")

if mgrhost != None:
print("\033[34m[rtm.py] mgrhost already set as " + str(mgrhost) + "\033[0m")
else:
mgrhost = nshost

if mgrhost != None or mgrport != None: #
print("\033[34m[rtm.py] mgrhost or mgrport already set as " + str(mgrhost) + ":" + str(mgrport) + "\033[0m")
if mgrport != None:
print("\033[34m[rtm.py] mgrport already set as " + str(mgrport) + "\033[0m")
else:
try:
mgrhost, mgrport = mc._argprop.getProperty("corba.master_manager").split(":")
mgrport = int(mc._argprop.getProperty("corba.master_manager").split(":")[1])
if not mgrport:
raise
except:
mgrhost = socket.gethostname()
mgrport = 2810 # default
print("\033[34m[rtm.py] No corba.master_manager set, use " + mgrhost + ":" + str(mgrport) + "\033[0m")
print("\033[34m[rtm.py] Failed to parse corba.master_manager, use " + str(mgrport) + "\033[0m")

print("\033[34m[rtm.py] configuration ORB with %s:%s\033[0m"%(nshost, nsport))
print("\033[34m[rtm.py] configuration RTCManager with %s:%s\033[0m"%(mgrhost, mgrport))
Expand Down

0 comments on commit b1b8ef3

Please sign in to comment.