[openrtm-commit:02602] r825 - trunk/OpenRTM-aist-Python/OpenRTM_aist
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 5月 2日 (火) 16:25:11 JST
Author: miyamoto
Date: 2017-05-02 16:25:10 +0900 (Tue, 02 May 2017)
New Revision: 825
Modified:
trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py
trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py
trunk/OpenRTM-aist-Python/OpenRTM_aist/Process.py
Log:
[compat,->RELENG_1_2] refs #4031
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py 2017-05-02 00:49:38 UTC (rev 824)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py 2017-05-02 07:25:10 UTC (rev 825)
@@ -1445,6 +1445,9 @@
self._module.load(mpm_, basename_)
except:
self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
+
+ self._config.setProperty("manager.instance_name",self.formatString(self._config.getProperty("manager.instance_name"),
+ self._config))
return
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py 2017-05-02 00:49:38 UTC (rev 824)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerServant.py 2017-05-02 07:25:10 UTC (rev 825)
@@ -22,12 +22,12 @@
import OpenRTM_aist
import RTC,RTM,RTM__POA
import platform
+import re
-
class ManagerServant(RTM__POA.Manager):
"""
"""
@@ -339,13 +339,17 @@
self._rtcout.RTC_DEBUG(OpenRTM_aist.Logger.print_exception())
del guard
+ module_name = module_name + "&manager_name=manager_%p"
+
+ rtc = self.create_component_by_mgrname(module_name)
+ return rtc
- # create on this manager
+ else:
+ # create on this manager
+ rtc = self._mgr.createComponent(module_name)
+ if rtc:
+ return rtc.getObjRef()
- rtc = self._mgr.createComponent(module_name)
- if rtc:
- return rtc.getObjRef()
-
return RTC.RTObject._nil
@@ -911,10 +915,12 @@
mgrloc = "corbaloc:iiop:"
mgrloc += host_port
mgrloc += "/" + config.getProperty("manager.name")
+
self._rtcout.RTC_DEBUG("corbaloc: %s", mgrloc)
mobj = self._mgr.getORB().string_to_object(mgrloc)
mgr = mobj._narrow(RTM.Manager)
+
return mgr
except CORBA.SystemException:
@@ -1135,8 +1141,10 @@
return RTC.RTObject._nil
-
- mgrobj = self.findManager_by_name(mgrstr)
+ if mgrstr == "manager_%p":
+ mgrobj = None
+ else:
+ mgrobj = self.findManager_by_name(mgrstr)
tmp = [arg]
@@ -1157,6 +1165,11 @@
if not rtcd_cmd:
rtcd_cmd = "rtcd_python"
#rtcd_cmd = "rtcd_python.bat"
+
+ load_path = config.getProperty("manager.modules.load_path")
+ load_path_language = config.getProperty("manager.modules."+language+".load_path")
+ load_path = load_path + "," + load_path_language
+
if platform.system() == "Windows":
cmd = "cmd /c " + rtcd_cmd
else:
@@ -1164,8 +1177,9 @@
cmd += " -o " + "manager.is_master:NO"
cmd += " -o " + "manager.corba_servant:YES"
cmd += " -o " + "corba.master_manager:" + config.getProperty("corba.master_manager")
- cmd += " -o " + "manger.name:" + config.getProperty("manger.name")
+ cmd += " -o " + "manager.name:" + config.getProperty("manager.name")
cmd += " -o " + "manager.instance_name:" + mgrstr
+ cmd += " -o " + "\"manager.modules.load_path:" + load_path + "\""
#cmd += " -o " + "manager.supported_languages:" + language
@@ -1180,15 +1194,56 @@
return RTC.RTObject._nil
time.sleep(0.01)
count = 0
+
+ slaves_names = []
+ regex = r'manager_[0-9]+'
+ if mgrstr == "manager_%p":
+ guard_slave = OpenRTM_aist.ScopedLock(self._slaveMutex)
+ for slave in self._slaves[:]:
+ try:
+ prof = slave.get_configuration()
+ prop = OpenRTM_aist.Properties()
+ OpenRTM_aist.NVUtil.copyToProperties(prop, prof)
+ name = prop.getProperty("manager.instance_name")
+ if re.match(regex, name):
+ slaves_names.append(name)
+ except:
+ self._rtcout.RTC_ERROR("Unknown exception cought.")
+ self._rtcout.RTC_DEBUG(OpenRTM_aist.Logger.print_exception())
+ self.remove_slave_manager(slave)
+
+ del guard_slave
+
t0_ = OpenRTM_aist.Time()
+
while CORBA.is_nil(mgrobj):
- mgrobj = self.findManager_by_name(mgrstr)
+ if mgrstr == "manager_%p":
+
+ guard_slave = OpenRTM_aist.ScopedLock(self._slaveMutex)
+
+ for slave in self._slaves[:]:
+ try:
+ prof = slave.get_configuration()
+ prop = OpenRTM_aist.Properties()
+ OpenRTM_aist.NVUtil.copyToProperties(prop, prof)
+ name = prop.getProperty("manager.instance_name")
+
+ if re.match(regex, name) and not (name in slaves_names):
+ mgrobj = slave
+ except:
+ self._rtcout.RTC_ERROR("Unknown exception cought.")
+ self._rtcout.RTC_DEBUG(OpenRTM_aist.Logger.print_exception())
+ self.remove_slave_manager(slave)
+ del guard_slave
+
+ else:
+ mgrobj = self.findManager_by_name(mgrstr)
count += 1
if count > 1000:
break
t1_ = OpenRTM_aist.Time()
- if (t1_ - t0_).getTime().toDouble() > 10.0:
+ if (t1_ - t0_).getTime().toDouble() > 10.0 and count > 10:
break
time.sleep(0.01)
@@ -1272,6 +1327,9 @@
if not rtcd_cmd:
rtcd_cmd = "rtcd_python"
+ load_path = config.getProperty("manager.modules.load_path")
+ load_path_language = config.getProperty("manager.modules."+language+".load_path")
+ load_path = load_path + "," + load_path_language
if platform.system() == "Windows":
cmd = "cmd /c " + rtcd_cmd
@@ -1279,6 +1337,8 @@
cmd = rtcd_cmd
cmd += " -o corba.master_manager:"
cmd += mgrstr # port number
+ cmd += " -o \"manager.modules.load_path:"
+ cmd += load_path + "\""
cmd += " -d "
@@ -1300,7 +1360,7 @@
break
t1_ = OpenRTM_aist.Time()
- if (t1_ - t0_).getTime().toDouble() > 10.0:
+ if (t1_ - t0_).getTime().toDouble() > 10.0 and count > 10:
break
time.sleep(0.01)
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/Process.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/Process.py 2017-05-02 00:49:38 UTC (rev 824)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/Process.py 2017-05-02 07:25:10 UTC (rev 825)
@@ -18,6 +18,7 @@
import os,sys
import traceback
import subprocess
+import shlex
##
# @if jp
@@ -28,7 +29,8 @@
#
# int launch_shell(std::string command)
def launch_shell(command):
- args = command.split(" ")
+ #args = command.split(" ")
+ args = shlex.split(command," ")
if sys.platform == "win32":
CREATE_NEW_PROCESS_GROUP = 0x00000200
openrtm-commit メーリングリストの案内