diff --git a/OpenRTM_aist/CORBA_RTCUtil.py b/OpenRTM_aist/CORBA_RTCUtil.py index 4d531a48..03654344 100644 --- a/OpenRTM_aist/CORBA_RTCUtil.py +++ b/OpenRTM_aist/CORBA_RTCUtil.py @@ -1536,3 +1536,413 @@ def set_configuration_parameter(conf, confset, value_name, value): confset.configuration_data = confData conf.set_configuration_set_values(confset) return True + + +## +# @if jp +# @class CorbaURI +# @brief 指定のCORBAオブジェクト参照用URLから参照形式、ホスト名、ポート番号、 +# パス、オブジェクトキーを取得する機能を提供するクラス +# +# @since 2.0.0 +# +# @else +# @class CorbaURI +# @brief +# +# @since 2.0.0 +# +# @endif +class CorbaURI: + ## + # @if jp + # + # @brief コンストラクタ + # + # uriには以下の形式のURLを指定できる + # - corbaloc形式(例:corbaloc:iiop:192.168.11.1:2809/Nameservice) + # - corbaname形式(例:corbaname::192.168.11.1:2809#ConsoleOut0.rtc) + # - HTTP(例:http://192.168.11.1:2809/call#Nameservice) + # - HTTPS(例:https://192.168.11.1:2809/call#Nameservice) + # - WS(例:ws://192.168.11.1:2809/ws#Nameservice) + # - WSS(例:wss://192.168.11.1:2809/ws#Nameservice) + # + # また、giop:ではじまるエンドポイントを指定することもできる + # この場合は上記のcorbaloc形式、corbaname形式、HTTP、HTTPS、WS、WSSのURLに変換する + # - giop::192.168.11.1:2809 -> corbaloc:iiop:192.168.11.1:2809 + # - giop:tcp:192.168.11.1:2809 -> corbaloc:iiop:192.168.11.1:2809 + # - giop:ssl:192.168.11.1:2809 -> corbaloc:ssliop:192.168.11.1:2809 + # - giop:http:http://192.168.11.1:2809/call -> + # http://192.168.11.1:2809/call + # + # アドレス、ポート番号を指定した場合はcorbaloc形式URLに変換する。 + # - 192.168.11.1:2809 -> corbaloc:iiop:192.168.11.1:2809 + # + # objkeyを指定した場合はURIの末尾に追加する。 + # - corbaloc:iiop:192.168.11.1:2809 -> + # corbaloc:iiop:192.168.11.1:2809/Nameservice + # - corbaname::192.168.11.1:2809 -> + # corbaloc:iiop:192.168.11.1:2809#ConsoleOut0.rtc + # - http://192.168.11.1:2809/call -> + # http://192.168.11.1:2809/call#Nameservice + # + # @param self + # @param uri CORBAオブジェクト参照用URL + # @param objkey オブジェクト名 + # + # @else + # + # @brief Consructor + # + # + # @param self + # @param uri + # @param objkey + # + # @endif + def __init__(self, uri, objkey=""): + import urllib.parse + if uri.find("giop:tcp:") == 0: + uri = uri.replace("giop:tcp:", "corbaloc:iiop:") + elif uri.find("giop:ssl:") == 0: + uri = uri.replace("giop:ssl:", "corbaloc:ssliop:") + elif uri.find("giop:http:") == 0: + uri = uri.replace("giop:http:", "") + elif uri.find("giop::") == 0: + uri = uri.replace("giop::", "corbaloc:iiop:") + elif uri.find("iiop://") == 0: + uri = uri.replace("iiop://", "corbaloc:iiop:") + elif uri.find("diop://") == 0: + uri = uri.replace("diop://", "corbaloc:diop:") + elif uri.find("uiop://") == 0: + uri = uri.replace("uiop://", "corbaloc:uiop:") + elif uri.find("shmiop://") == 0: + uri = uri.replace("shmiop://", "corbaloc:shmiop:") + elif uri.find("inet:") == 0: + uri = uri.replace("inet:", "corbaloc:iiop:") + + self._uri = "" + self._port = None + self._addressonly = False + ret = urllib.parse.urlparse(uri) + self._protocol = ret.scheme + + loc = [s.strip() for s in ret.netloc.split(":")] + if len(loc) >= 2: + self._host = loc[0] + self._port = int(loc[1]) + else: + self._host = ret.netloc + self._path = ret.path + self._fragment = ret.fragment + + if self._fragment: + self._uri = uri + return + else: + self._fragment = objkey + if self._protocol == "corbaloc": + self._uri = uri + "/" + self._uri += self._fragment + elif self._protocol: + self._uri = uri + "#" + self._uri += self._fragment + else: + self._uri = "corbaloc:iiop:" + self._uri += uri + "/" + self._uri += self._fragment + self._protocol = "corbaloc" + self._addressonly = True + host_port = [s.strip() for s in uri.split(":")] + if len(host_port) == 2: + self._host = host_port[0] + try: + self._port = int(host_port[1]) + except BaseException: + pass + ## + # @if jp + # + # @brief CORBAオブジェクト参照用URLを取得する + # + # @param self + # @return CORBAオブジェクト参照用URL + # + # @else + # + # @brief Consructor + # + # @param self + # @return + # + # @endif + + def toString(self): + return self._uri + + ## + # @if jp + # + # @brief 参照形式を取得する + # 例:corbaloc、corbaname、http、https、ws、wss + # + # @param self + # @return 参照形式 + # + # @else + # + # @brief + # + # @param self + # @return + # + # @endif + def getProtocol(self): + return self._protocol + + ## + # @if jp + # + # @brief ホスト名を取得する + # + # @param self + # @return ホスト名 + # + # @else + # + # @brief + # + # @param self + # @return + # + # @endif + def getHost(self): + return self._host + + ## + # @if jp + # + # @brief ポート番号を取得する + # + # @param self + # @return ポート番号 + # + # @else + # + # @brief + # + # @param self + # @return + # + # @endif + def getPort(self): + return self._port + + ## + # @if jp + # + # @brief 初期化時にCORBAオブジェクト参照用URLを指定した場合はfalse、 + # ホスト名、ポート番号のみを指定した場合はtrueを返す。 + # + # @param self + # @return 参照先の指定方法 + # + # @else + # + # @brief + # + # @param self + # @return + # + # @endif + def isAddressOnly(self): + return self._addressonly + + +## +# @if jp +# @class RTCURIObject クラス +# @brief RTCURIObject クラス +# rtcname形式、rtcloc形式のURIから通信先のアドレス、RTC名等を +# 取得する機能を提供するクラス +# rtcname形式は以下のようにrtcname.{通信プロトコル}/{アドレス}/{ネームサーバーでの登録パス} +# で指定可能である。通信プロトコルを省略するとiiopに設定する。 +# +# rtcname.ssliop://localhost:2809/test.host_cxt/ConsoleOut0 +# +# ただし、http通信を指定する場合は以下のようにアドレスの後は#で区切る必要がある。 +# +# rtcname.https://localhost:2809/call#test.host_cxt/ConsoleOut0 +# +# rtcloc形式は以下のようにrtcloc.{通信プロトコル}/{アドレス}/{カテゴリ名}/{RTC名} +# で指定可能である。通信プロトコルを省略するとiiopに設定する。 +# +# rtcloc.ssliop://localhost:2810/example/ConsoleOut0 +# +# ただし、http通信を指定する場合は以下のようにアドレスの後は#で区切る必要がある。 +# +# rtcloc.http://localhost:2810/call#example/ConsoleOut0 +# +# @since 2.0.0 +# +# @else +# @class RTCURIObject class +# @brief RTCURIObject class +# @brief +# +# @since 2.0.0 +# +# @endif +class RTCURIObject: + ## + # @if jp + # + # @brief コンストラクタ + # + # @param uri rtcname形式、もしくはrtcloc形式のURI + # @param isrtcname rtcname形式を指定する場合はtrue、それ以外はfalse + # @param isrtcloc rtcloc形式を指定する場合はtrue、それ以外はfalse + # + # @else + # + # @brief Consructor + # + # + # @param uri + # @param isrtcname + # @param isrtcloc + # + # @endif + def __init__(self, uri, isrtcname=False, isrtcloc=False): + self._is_rtcname = False + self._is_rtcloc = False + self._rtcpath = "" + self._address = "" + pos = uri.find("://") + if pos >= 0: + ptype = uri[0:pos] + addrname = uri[pos+3:] + protocol = "" + + if ptype.find("rtcname") == 0: + self._is_rtcname = True + elif ptype.find("rtcloc") == 0: + self._is_rtcloc = True + else: + return + + if isrtcname: + if not self._is_rtcname: + return + + if isrtcloc: + if not self._is_rtcloc: + return + + pos = ptype.find(".") + seprtc = "/" + if pos >= 0: + protocol = ptype[pos+1:] + if protocol == "http" or protocol == "https" or protocol == "ws" or protocol == "wss": + seprtc = "#" + + pos = addrname.find(seprtc) + hostport = "" + + if pos >= 0: + hostport = addrname[0:pos] + self._rtcpath = addrname[pos+1:] + else: + hostport = addrname + + if hostport != "*": + if protocol == "http" or protocol == "https" or protocol == "ws" or protocol == "wss": + self._address = protocol + self._address += "://" + self._address += hostport + + else: + self._address = "corbaloc:" + self._address += protocol + self._address += ":" + self._address += hostport + else: + self._address = hostport + + ## + # @if jp + # + # @brief RTC名を取得する + # + # rtcname形式の場合はネームサーバーに登録したRTCのパスを取得できる。 + # context1.kind1/context2.kind2/..../RTC_name + # + # rtcloc形式の場合はカテゴリ名/RTC名で取得できる。 + # + # @return RTC名 + # + # @else + # + # @brief + # + # @return + # + # @endif + def getRTCName(self): + return self._rtcpath + + ## + # @if jp + # + # @brief 通信先のアドレスを取得する + # + # + # @return 通信先のアドレス + # + # @else + # + # @brief + # + # @return + # + # @endif + def getAddress(self): + return self._address + + ## + # @if jp + # + # @brief URIがrtcname形式かを判定する + # + # @return true:rtcname形式、false:それ以外 + # + # @return RTC名 + # + # @else + # + # @brief + # + # @return + # + # @endif + def isRTCNameURI(self): + return self._is_rtcname + + ## + # @if jp + # + # @brief URIがrtcname形式かを判定する + # + # @brief URIがrtcloc形式かを判定する + # + # @return true:rtcname形式、false:それ以外 + # + # @else + # + # @brief + # + # @return + # + # @endif + def isRTCLocURI(self): + return self._is_rtcloc diff --git a/OpenRTM_aist/CorbaNaming.py b/OpenRTM_aist/CorbaNaming.py index a26611f8..4009e5fa 100644 --- a/OpenRTM_aist/CorbaNaming.py +++ b/OpenRTM_aist/CorbaNaming.py @@ -17,6 +17,7 @@ import omniORB.CORBA as CORBA import CosNaming +import OpenRTM_aist.CORBA_RTCUtil import string import sys import traceback @@ -85,7 +86,9 @@ def __init__(self, orb, name_server=None): self._blLength = 100 if name_server: - self._nameServer = "corbaloc::" + name_server + "/NameService" + self._nameServer = OpenRTM_aist.CORBA_RTCUtil.CorbaURI( + name_server, "NameService").toString() + obj = orb.string_to_object(self._nameServer) self._rootContext = obj._narrow(CosNaming.NamingContext) if CORBA.is_nil(self._rootContext): @@ -125,7 +128,8 @@ def __del__(self): # @endif def init(self, name_server): - self._nameServer = "corbaloc::" + name_server + "/NameService" + self._nameServer = OpenRTM_aist.CORBA_RTCUtil.CorbaURI( + name_server, "NameService").toString() obj = self._orb.string_to_object(self._nameServer) self._rootContext = obj._narrow(CosNaming.NamingContext) if CORBA.is_nil(self._rootContext): diff --git a/OpenRTM_aist/InPortBase.py b/OpenRTM_aist/InPortBase.py index c02534ac..8af374eb 100644 --- a/OpenRTM_aist/InPortBase.py +++ b/OpenRTM_aist/InPortBase.py @@ -1260,7 +1260,11 @@ def createProvider(self, cprof, prop): if provider is not None: self._rtcout.RTC_DEBUG("provider created") - provider.init(prop.getNode("provider")) + try: + provider.init(prop.getNode("provider")) + except BaseException: + self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception()) + return None if not provider.publishInterface(cprof.properties): self._rtcout.RTC_ERROR( @@ -1304,7 +1308,11 @@ def createConsumer(self, cprof, prop): if consumer is not None: self._rtcout.RTC_DEBUG("consumer created") - consumer.init(prop.getNode("consumer")) + try: + consumer.init(prop.getNode("consumer")) + except BaseException: + self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception()) + return None if not consumer.subscribeInterface(cprof.properties): self._rtcout.RTC_ERROR("interface subscription failed.") diff --git a/OpenRTM_aist/InPortPullConnector.py b/OpenRTM_aist/InPortPullConnector.py index d340ae26..0cb61b7b 100644 --- a/OpenRTM_aist/InPortPullConnector.py +++ b/OpenRTM_aist/InPortPullConnector.py @@ -133,7 +133,7 @@ def __init__(self, info, consumer, listeners, buffer=None): self._buffer = self.createBuffer(self._profile) if not self._buffer or not self._consumer: - raise + raise MemoryError("InPortPullConnector creation failed") self._buffer.init(info.properties.getNode("buffer")) self._consumer.init(info.properties) @@ -414,4 +414,5 @@ def unsubscribeInterface(self, prop): def setDataType(self, data): OpenRTM_aist.InPortConnector.setDataType(self, data) - self._serializer = OpenRTM_aist.SerializerFactories.instance().createSerializer(self._marshaling_type, data) \ No newline at end of file + self._serializer = OpenRTM_aist.SerializerFactories.instance( + ).createSerializer(self._marshaling_type, data) diff --git a/OpenRTM_aist/InPortPushConnector.py b/OpenRTM_aist/InPortPushConnector.py index 07088d48..31f81bea 100644 --- a/OpenRTM_aist/InPortPushConnector.py +++ b/OpenRTM_aist/InPortPushConnector.py @@ -131,7 +131,7 @@ def __init__(self, info, provider, listeners, buffer=None): self._buffer = self.createBuffer(info) if self._buffer is None or not self._provider: - raise + raise MemoryError("InPortPushConnector creation failed") self._buffer.init(info.properties.getNode("buffer")) self._provider.init(info.properties) diff --git a/OpenRTM_aist/Manager.py b/OpenRTM_aist/Manager.py index 3e6fc3f1..fc249128 100644 --- a/OpenRTM_aist/Manager.py +++ b/OpenRTM_aist/Manager.py @@ -1789,6 +1789,44 @@ def createORBOptions(self): return opt + ## + # @if jp + # @brief giopからはじまるORBエンドポイントでの指定した場合にtrue、 + # それ以外(例えばホスト名:ポート番号の指定)の場合はfalseを返す。 + # + # + # @param endpoint エンドポイント + # @return エンドポイントの指定方法 + # + # @else + # @brief + # + # @param endpoint + # @return + # + # @endif + # + # static bool isORBEndPoint(const std::string& endpoint); + + @staticmethod + def isORBEndPoint(endpoint): + if "giop:" in endpoint: + return True + elif "iiop://" in endpoint: + return True + elif "diop://" in endpoint: + return True + elif "uiop://" in endpoint: + return True + elif "shmiop://" in endpoint: + return True + elif "inet:" in endpoint: + return True + return False + + + + ## # @if jp # @brief エンドポイントの生成 @@ -1839,11 +1877,14 @@ def createORBEndpoints(self): if OpenRTM_aist.toBool(self._config.getProperty( "manager.is_master"), "YES", "NO", False): mm = self._config.getProperty("corba.master_manager", ":2810") - mmm = [s.strip() for s in mm.split(":")] - if len(mmm) == 2: - endpoints.insert(0, ":" + mmm[1]) + if not Manager.isORBEndPoint(mm): + mmm = [s.strip() for s in mm.split(":")] + if len(mmm) == 2: + endpoints.insert(0, ":" + mmm[1]) + else: + endpoints.insert(0, ":2810") else: - endpoints.insert(0, ":2810") + endpoints.insert(0, mm) endpoints = OpenRTM_aist.unique_sv(endpoints) @@ -1882,12 +1923,21 @@ def createORBEndpointOption(self, opt, endpoints): if endpoint == "all:": opt += " -ORBendPointPublish all(addr)" else: - opt += " -ORBendPoint giop:tcp:" + endpoint + if not Manager.isORBEndPoint(endpoint): + opt += " -ORBendPoint giop:tcp:" + endpoint + else: + opt += " -ORBendPoint " + endpoint elif corba == "TAO": - opt += "-ORBEndPoint iiop://" + endpoint + if not Manager.isORBEndPoint(endpoint): + opt += "-ORBEndPoint iiop://" + endpoint + else: + opt += "-ORBEndPoint " + endpoint elif corba == "MICO": - opt += "-ORBIIOPAddr inet:" + endpoint + if not Manager.isORBEndPoint(endpoint): + opt += "-ORBIIOPAddr inet:" + endpoint + else: + opt += "-ORBIIOPAddr " + endpoint endpoints[i] = endpoint @@ -3083,9 +3133,13 @@ def connectDataPorts(self, port, target_ports): con_name += ":" con_name += p1.name prop = OpenRTM_aist.Properties() - if RTC.RTC_OK != OpenRTM_aist.CORBA_RTCUtil.connect( - con_name, prop, port, p): - self._rtcout.RTC_ERROR("Connection error in topic connection.") + try: + if RTC.RTC_OK != OpenRTM_aist.CORBA_RTCUtil.connect( + con_name, prop, port, p): + self._rtcout.RTC_ERROR( + "Connection error in topic connection.") + except BaseException: + self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception()) ## # @if jp @@ -3114,9 +3168,13 @@ def connectServicePorts(self, port, target_ports): con_name += ":" con_name += p1.name prop = OpenRTM_aist.Properties() - if RTC.RTC_OK != OpenRTM_aist.CORBA_RTCUtil.connect( - con_name, prop, port, p): - self._rtcout.RTC_ERROR("Connection error in topic connection.") + try: + if RTC.RTC_OK != OpenRTM_aist.CORBA_RTCUtil.connect( + con_name, prop, port, p): + self._rtcout.RTC_ERROR( + "Connection error in topic connection.") + except BaseException: + self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception()) ## # @if jp @@ -3170,9 +3228,12 @@ def initPreConnection(self): if not ("interface_type" in configs.keys()): configs["interface_type"] = "corba_cdr" - tmp = port0_str.split(".") - tmp.pop() - comp0_name = ".".join([x.strip() for x in tmp]) + pos_port0 = port0_str.rfind(".") + comp0_name = "" + if pos_port0 >= 0: + comp0_name = port0_str[0:pos_port0] + else: + comp0_name = port0_str port0_name = port0_str @@ -3191,11 +3252,16 @@ def initPreConnection(self): comp0_ref = rtcs[0] port0_name = port0_str.split("/")[-1] - port0_var = OpenRTM_aist.CORBA_RTCUtil.get_port_by_name( - comp0_ref, port0_name) + port0_var = None + try: + port0_var = OpenRTM_aist.CORBA_RTCUtil.get_port_by_name( + comp0_ref, port0_name) + except BaseException: + self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception()) + continue if CORBA.is_nil(port0_var): - self._rtcout.RTC_DEBUG("port %s found: " % port0_str) + self._rtcout.RTC_DEBUG("port %s not found: " % port0_str) continue if not ports: @@ -3206,15 +3272,24 @@ def initPreConnection(self): v = v.strip() prop.setProperty("dataport." + k, v) - if RTC.RTC_OK != OpenRTM_aist.CORBA_RTCUtil.connect( - c, prop, port0_var, RTC.PortService._nil): - self._rtcout.RTC_ERROR("Connection error: %s" % c) + try: + if RTC.RTC_OK != OpenRTM_aist.CORBA_RTCUtil.connect( + c, prop, port0_var, RTC.PortService._nil): + self._rtcout.RTC_ERROR("Connection error: %s" % c) + except BaseException: + self._rtcout.RTC_ERROR( + OpenRTM_aist.Logger.print_exception()) + continue for port_str in ports: - tmp = port_str.split(".") - tmp.pop() - comp_name = ".".join([x.strip() for x in tmp]) + pos_port = port_str.rfind(".") + comp_name = "" + if pos_port >= 0: + comp_name = port_str[0:pos_port] + else: + comp_name = port_str + port_name = port_str if comp_name.find("://") == -1: @@ -3232,11 +3307,17 @@ def initPreConnection(self): comp_ref = rtcs[0] port_name = port_str.split("/")[-1] - port_var = OpenRTM_aist.CORBA_RTCUtil.get_port_by_name( - comp_ref, port_name) + port_var = None + try: + port_var = OpenRTM_aist.CORBA_RTCUtil.get_port_by_name( + comp_ref, port_name) + except BaseException: + self._rtcout.RTC_ERROR( + OpenRTM_aist.Logger.print_exception()) + continue if CORBA.is_nil(port_var): - self._rtcout.RTC_DEBUG("port %s found: " % port_str) + self._rtcout.RTC_DEBUG("port %s not found: " % port_str) continue prop = OpenRTM_aist.Properties() @@ -3245,10 +3326,13 @@ def initPreConnection(self): k = k.strip() v = v.strip() prop.setProperty("dataport." + k, v) - - if RTC.RTC_OK != OpenRTM_aist.CORBA_RTCUtil.connect( - c, prop, port0_var, port_var): - self._rtcout.RTC_ERROR("Connection error: %s" % c) + try: + if RTC.RTC_OK != OpenRTM_aist.CORBA_RTCUtil.connect( + c, prop, port0_var, port_var): + self._rtcout.RTC_ERROR("Connection error: %s" % c) + except BaseException: + self._rtcout.RTC_ERROR( + OpenRTM_aist.Logger.print_exception()) ## # @if jp @@ -3284,7 +3368,14 @@ def initPreActivation(self): self._rtcout.RTC_ERROR("%s not found." % c) continue comp_ref = rtcs[0] - ret = OpenRTM_aist.CORBA_RTCUtil.activate(comp_ref) + ret = RTC.RTC_OK + try: + ret = OpenRTM_aist.CORBA_RTCUtil.activate(comp_ref) + except BaseException: + self._rtcout.RTC_ERROR( + OpenRTM_aist.Logger.print_exception()) + continue + if ret != RTC.RTC_OK: self._rtcout.RTC_ERROR("%s activation failed." % c) else: diff --git a/OpenRTM_aist/ManagerServant.py b/OpenRTM_aist/ManagerServant.py index d11499f0..7667a417 100644 --- a/OpenRTM_aist/ManagerServant.py +++ b/OpenRTM_aist/ManagerServant.py @@ -20,6 +20,7 @@ import time from omniORB import CORBA import OpenRTM_aist +import OpenRTM_aist.CORBA_RTCUtil import RTC import RTM import RTM__POA @@ -1172,9 +1173,7 @@ def findManager(self, host_port): self._rtcout.RTC_TRACE("findManager(host_port = %s)", host_port) try: config = copy.deepcopy(self._mgr.getConfig()) - mgrloc = "corbaloc:iiop:" - mgrloc += host_port - mgrloc += "/" + config.getProperty("manager.name") + mgrloc = OpenRTM_aist.CORBA_RTCUtil.CorbaURI(host_port, config.getProperty("manager.name")).toString() self._rtcout.RTC_DEBUG("corbaloc: %s", mgrloc) diff --git a/OpenRTM_aist/NamingManager.py b/OpenRTM_aist/NamingManager.py index 92ebc7bd..0f7d2eae 100644 --- a/OpenRTM_aist/NamingManager.py +++ b/OpenRTM_aist/NamingManager.py @@ -19,6 +19,7 @@ import OpenRTM_aist +import OpenRTM_aist.CORBA_RTCUtil from omniORB import CORBA import RTM import RTC @@ -279,6 +280,7 @@ def getCorbaNaming(self): # @endif def getComponentByName(self, context, name, rtcs): + self._rtcout.RTC_TRACE("getComponentByName(name = %s)", name) length = 500 bl, bi = context.list(length) for i in bl: @@ -317,45 +319,53 @@ def getComponentByName(self, context, name, rtcs): # virtual RTCList string_to_component(string name) = 0; def string_to_component(self, name): + self._rtcout.RTC_TRACE("string_to_component(name = %s)", name) rtc_list = [] - tmp = name.split("://") - if len(tmp) > 1: - if tmp[0] == "rtcname": - #tag = tmp[0] - url = tmp[1] - r = url.split("/") - if len(r) > 1: - host = r[0] - rtc_name = url[len(host) + 1:] + rtcuri = OpenRTM_aist.CORBA_RTCUtil.RTCURIObject(name, True, False) - try: - cns = None - if host == "*": - cns = self._cosnaming - else: - orb = OpenRTM_aist.Manager.instance().getORB() - cns = OpenRTM_aist.CorbaNaming(orb, host) - names = rtc_name.split("/") - - if len(names) == 2 and names[0] == "*": - root_cxt = cns.getRootContext() - self.getComponentByName( - root_cxt, names[1], rtc_list) - return rtc_list - else: - rtc_name += ".rtc" - obj = cns.resolveStr(rtc_name) - if CORBA.is_nil(obj): - return [] - if obj._non_existent(): - return [] - rtc_list.append(obj) - return rtc_list - except BaseException: - self._rtcout.RTC_ERROR( - OpenRTM_aist.Logger.print_exception()) - return [] + if not rtcuri.isRTCNameURI(): + self._rtcout.RTC_WARN("syntax error: %s", name) + return rtc_list + else: + self._rtcout.RTC_INFO("URI: %s, Address: %s, Name: %s", + (name, rtcuri.getAddress(), + rtcuri.getRTCName())) + try: + cns = None + if rtcuri.getAddress() == "*": + cns = self._cosnaming + else: + orb = OpenRTM_aist.Manager.instance().getORB() + cns = OpenRTM_aist.CorbaNaming(orb, rtcuri.getAddress()) + + rtcname = rtcuri.getRTCName() + context = "" + compname = "" + + pos = rtcname.find("/") + if pos >= 0: + context = rtcname[0:pos] + compname = rtcname[pos + 1:] + + if context == "*": + root_cxt = cns.getRootContext() + self.getComponentByName( + root_cxt, compname, rtc_list) + return rtc_list + else: + rtcname += ".rtc" + obj = cns.resolveStr(rtcname) + if CORBA.is_nil(obj): + return rtc_list + if obj._non_existent(): + return rtc_list + rtc_list.append(obj) + return rtc_list + except BaseException: + self._rtcout.RTC_ERROR( + OpenRTM_aist.Logger.print_exception()) + return rtc_list return rtc_list @@ -502,33 +512,32 @@ def isAlive(self): # # virtual RTCList string_to_component(); def string_to_component(self, name): + self._rtcout.RTC_TRACE("string_to_component(name = %s)", name) rtc_list = [] - tmp = name.split("://") - - if len(tmp) > 1: - if tmp[0] == "rtcloc": - #tag = tmp[0] - url = tmp[1] - r = url.split("/") - if len(r) > 1: - host = r[0] - rtc_name = url[len(host) + 1:] - - mgr = self.getManager(host) - if not CORBA.is_nil(mgr): - rtc_list = mgr.get_components_by_name(rtc_name) - - slaves = mgr.get_slave_managers() - for slave in slaves: - try: - rtc_list.extend( - slave.get_components_by_name(rtc_name)) - except BaseException: - self._rtcout.RTC_DEBUG( - OpenRTM_aist.Logger.print_exception()) - mgr.remove_slave_manager(slave) - return rtc_list + rtcuri = OpenRTM_aist.CORBA_RTCUtil.RTCURIObject(name, False, True) + + if not rtcuri.isRTCLocURI(): + self._rtcout.RTC_WARN("syntax error: %s", name) + return rtc_list + else: + self._rtcout.RTC_INFO("URI: %s, Address: %s, Name: %s", + (name, rtcuri.getAddress(), + rtcuri.getRTCName())) + + mgr = self.getManager(rtcuri.getAddress()) + if not CORBA.is_nil(mgr): + rtc_list = mgr.get_components_by_name(rtcuri.getRTCName()) + slaves = mgr.get_slave_managers() + for slave in slaves: + try: + rtc_list.extend( + slave.get_components_by_name(rtcuri.getRTCName())) + except BaseException: + self._rtcout.RTC_DEBUG( + OpenRTM_aist.Logger.print_exception()) + mgr.remove_slave_manager(slave) + return rtc_list return rtc_list ## @@ -550,6 +559,7 @@ def string_to_component(self, name): # # virtual Manager_ptr getManager(string name); def getManager(self, name): + self._rtcout.RTC_TRACE("getManager(name = %s)", name) if name == "*": mgr_sev = self._mgr.getManagerServant() mgr = None @@ -563,11 +573,10 @@ def getManager(self, name): mgr = mgr_sev.getObjRef() return mgr try: - mgrloc = "corbaloc:iiop:" prop = self._mgr.getConfig() manager_name = prop.getProperty("manager.name") - mgrloc += name - mgrloc += "/" + manager_name + mgrloc = OpenRTM_aist.CORBA_RTCUtil.CorbaURI( + name, manager_name).toString() mobj = self._orb.string_to_object(mgrloc) mgr = mobj._narrow(RTM.Manager) @@ -793,7 +802,12 @@ def unbindObject(self, name): guard = OpenRTM_aist.ScopedLock(self._namesMutex) for n in self._names: if n.ns: - n.ns.unbindObject(name) + try: + n.ns.unbindObject(name) + except BaseException: + del n.ns + n.ns = None + self.unregisterCompName(name) self.unregisterMgrName(name) self.unregisterPortName(name) @@ -910,7 +924,10 @@ def createNamingObj(self, method, name_server): def bindCompsTo(self, ns): for comp in self._compNames: - ns.bindObject(comp.name, comp.rtobj) + try: + ns.bindObject(comp.name, comp.rtobj) + except BaseException: + pass ## # @if jp diff --git a/OpenRTM_aist/OutPortBase.py b/OpenRTM_aist/OutPortBase.py index d980d5c6..cee3fddf 100644 --- a/OpenRTM_aist/OutPortBase.py +++ b/OpenRTM_aist/OutPortBase.py @@ -1266,7 +1266,11 @@ def createProvider(self, cprof, prop): if provider is not None: self._rtcout.RTC_DEBUG("provider created") - provider.init(prop.getNode("provider")) + try: + provider.init(prop.getNode("provider")) + except BaseException: + self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception()) + return None if not provider.publishInterface(cprof.properties): self._rtcout.RTC_ERROR( @@ -1308,7 +1312,11 @@ def createConsumer(self, cprof, prop): if consumer is not None: self._rtcout.RTC_DEBUG("consumer created") - consumer.init(prop.getNode("consumer")) + try: + consumer.init(prop.getNode("consumer")) + except BaseException: + self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception()) + return None if not consumer.subscribeInterface(cprof.properties): self._rtcout.RTC_ERROR("interface subscription failed.") diff --git a/OpenRTM_aist/OutPortPullConnector.py b/OpenRTM_aist/OutPortPullConnector.py index ce22588d..83b826a1 100644 --- a/OpenRTM_aist/OutPortPullConnector.py +++ b/OpenRTM_aist/OutPortPullConnector.py @@ -134,7 +134,7 @@ def __init__(self, info, provider, listeners, buffer=None): if not self._provider or not self._buffer: self._rtcout.RTC_ERROR( "Exeption: in OutPortPullConnector.__init__().") - raise + raise MemoryError("OutPortPullConnector creation failed") self._buffer.init(info.properties.getNode("buffer")) self._provider.init(info.properties) @@ -417,7 +417,8 @@ def setDirectMode(self): def setDataType(self, data): OpenRTM_aist.OutPortConnector.setDataType(self, data) - self._serializer = OpenRTM_aist.SerializerFactories.instance().createSerializer(self._marshaling_type, data) + self._serializer = OpenRTM_aist.SerializerFactories.instance( + ).createSerializer(self._marshaling_type, data) class WorkerThreadCtrl: def __init__(self): diff --git a/OpenRTM_aist/OutPortPushConnector.py b/OpenRTM_aist/OutPortPushConnector.py index 03666796..3b906a71 100644 --- a/OpenRTM_aist/OutPortPushConnector.py +++ b/OpenRTM_aist/OutPortPushConnector.py @@ -139,17 +139,17 @@ def __init__(self, info, consumer, listeners, buffer=None): self._buffer = self.createBuffer(info) if not self._publisher or not self._buffer or not self._consumer: - raise + raise MemoryError("OutPortPushConnector creation failed") if self._publisher.init(info.properties) != self.PORT_OK: - raise + raise MemoryError("OutPortPushConnector creation failed") if self._profile.properties.hasKey("serializer"): endian = self._profile.properties.getProperty( "serializer.cdr.endian") if not endian: self._rtcout.RTC_ERROR("write(): endian is not set.") - raise + raise MemoryError("OutPortPushConnector creation failed") # Maybe endian is ["little","big"] endian = OpenRTM_aist.split(endian, ",") @@ -517,4 +517,5 @@ def unsubscribeInterface(self, prop): def setDataType(self, data): OpenRTM_aist.OutPortConnector.setDataType(self, data) - self._serializer = OpenRTM_aist.SerializerFactories.instance().createSerializer(self._marshaling_type, data) + self._serializer = OpenRTM_aist.SerializerFactories.instance( + ).createSerializer(self._marshaling_type, data) diff --git a/OpenRTM_aist/ext/http/rtc.http.conf b/OpenRTM_aist/ext/http/rtc.http.conf index 38f71370..63fdb0dc 100644 --- a/OpenRTM_aist/ext/http/rtc.http.conf +++ b/OpenRTM_aist/ext/http/rtc.http.conf @@ -6,5 +6,5 @@ manager.modules.load_path: ./ manager.preload.modules: HTTPTransport.py corba.args:-ORBserverTransportRule "* http" -ORBclientTransportRule "* http" -ORBendPoint giop:http:http:///call -corba.nameservers: http://127.0.0.1:2809/call -corba.master_manager: giop:http:http://127.0.0.1:2810/call +corba.nameservers: http://localhost:2809/call +corba.master_manager: giop:http:http://localhost:2810/call diff --git a/OpenRTM_aist/ext/http/rtc.https.conf b/OpenRTM_aist/ext/http/rtc.https.conf index fe9f59f2..471cfa9b 100644 --- a/OpenRTM_aist/ext/http/rtc.https.conf +++ b/OpenRTM_aist/ext/http/rtc.https.conf @@ -10,5 +10,5 @@ corba.http.key_file:../ssl/test/server.pem corba.http.key_file_password:password corba.args:-ORBserverTransportRule "* http" -ORBclientTransportRule "* http" -ORBendPoint giop:http:https:///call -corba.nameservers: https://127.0.0.1:2809/call -corba.master_manager: giop:http:https://127.0.0.1:2810/call +corba.nameservers: https://localhost:2809/call +corba.master_manager: giop:http:https://localhost:2810/call diff --git a/OpenRTM_aist/ext/http/rtc.ws.conf b/OpenRTM_aist/ext/http/rtc.ws.conf index 93aac207..6c191ed1 100644 --- a/OpenRTM_aist/ext/http/rtc.ws.conf +++ b/OpenRTM_aist/ext/http/rtc.ws.conf @@ -6,5 +6,5 @@ manager.modules.load_path: ./ manager.preload.modules: HTTPTransport.py corba.args:-ORBserverTransportRule "* http" -ORBclientTransportRule "* http" -ORBendPoint giop:http:ws:///ws -corba.nameservers: ws://127.0.0.1:2809/ws -corba.master_manager: giop:http:ws://127.0.0.1:2810/ws +corba.nameservers: ws://localhost:2809/ws +corba.master_manager: giop:http:ws://localhost:2810/ws diff --git a/OpenRTM_aist/ext/http/rtc.wss.conf b/OpenRTM_aist/ext/http/rtc.wss.conf index af38d952..4059f311 100644 --- a/OpenRTM_aist/ext/http/rtc.wss.conf +++ b/OpenRTM_aist/ext/http/rtc.wss.conf @@ -10,5 +10,5 @@ corba.http.key_file:../ssl/test/server.pem corba.http.key_file_password:password corba.args:-ORBserverTransportRule "* http" -ORBclientTransportRule "* http" -ORBendPoint giop:http:wss:///ws -corba.nameservers: wss://127.0.0.1:2809/ws -corba.master_manager: giop:http:wss://127.0.0.1:2810/ws +corba.nameservers: wss://localhost:2809/ws +corba.master_manager: giop:http:wss://localhost:2810/ws diff --git a/OpenRTM_aist/ext/ssl/rtc.ssl.conf b/OpenRTM_aist/ext/ssl/rtc.ssl.conf index b0ea8ac8..404ec6d1 100644 --- a/OpenRTM_aist/ext/ssl/rtc.ssl.conf +++ b/OpenRTM_aist/ext/ssl/rtc.ssl.conf @@ -9,5 +9,5 @@ corba.ssl.certificate_authority_file:test/root.crt corba.ssl.key_file:test/server.pem corba.ssl.key_file_password:password corba.args:-ORBserverTransportRule "* ssl" -ORBclientTransportRule "* ssl" -ORBendPoint giop:ssl:: -corba.nameservers: corbaloc:ssliop:127.0.0.1:2809 -corba.master_manager: giop:ssl:127.0.0.1:2810 +corba.nameservers: corbaloc:ssliop:localhost:2809 +corba.master_manager: giop:ssl:localhost:2810