本文整理汇总了Python中naoqi.ALBroker.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python ALBroker.__init__方法的具体用法?Python ALBroker.__init__怎么用?Python ALBroker.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类naoqi.ALBroker
的用法示例。
在下文中一共展示了ALBroker.__init__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import __init__ [as 别名]
def __init__(self, broker_name, broker_ip=None, broker_port=0,
nao_id=None, nao_port=None, **kwargs):
if any(x in kwargs for x in
['brokerIp', 'brokerPort', 'naoIp', 'naoPort']):
warnings.warn('''brokerIp, brokerPort, naoIp and naoPort arguments
are respectively replaced by broker_ip,
broker_port, nao_id and nao_port''',
DeprecationWarning)
broker_ip = kwargs.pop('brokerIp', broker_ip)
broker_port = kwargs.pop('brokerPort', broker_port)
nao_id = kwargs.pop('naoIp', nao_id)
nao_port = kwargs.pop('naoPort', nao_port)
if kwargs:
raise TypeError('Unexpected arguments for Broker(): %s'
% ', '.join(kwargs.keys()))
nao_ip, nao_port = _resolve_ip_port(nao_id, nao_port)
# Information concerning our new python broker
if broker_ip is None:
broker_ip = _get_local_ip(nao_ip)
ALBroker.__init__(self, broker_name, broker_ip,
broker_port, nao_ip, nao_port)
self.broker_name = broker_name
self.broker_ip = broker_ip
self.broker_port = broker_port
self.nao_id = nao_id
self.nao_port = nao_port
示例2: __init__
# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import __init__ [as 别名]
def __init__(self, brokerName, brokerIp=None, brokerPort=0, naoIp=None, naoPort=None):
# Resolve NAO ip/port
if naoIp is None:
naoPort = None # Ensure consistency. Do not support specifying only port.
else:
naoIp = str(naoIp)
if naoPort is None:
allNaos = avahi.findAllNAOs()
if naoIp is not None: # A NAO address is given, but not the port. Find it.
for aNao in allNaos:
if naoIp in aNao.values():
naoPort = aNao['naoqi_port']
break
if naoPort is None: # Can't find it in Avahi results
naoPort = 9559 # Try default port
else: # Find the most likely NAO
for aNao in allNaos:
if aNao['local']: # Prefer to connect to the local naoqi if there
naoIp = aNao['ip_address']
naoPort = aNao['naoqi_port']
break
if naoIp is None: # No local NAO detected
if allNaos: # Try to get the first NAO detected by Avahi
naoIp = allNaos[0]['ip_address']
naoPort = allNaos[0]['naoqi_port']
else: # Fallback on nao.local/9559
naoIp = 'nao.local'
naoPort = 9559
else:
naoPort = int(naoPort)
# Information concerning our new python broker
if brokerIp is None:
brokerIp = getLocalIp(naoIp)
ALBroker.__init__(self, brokerName, brokerIp, brokerPort, naoIp, naoPort)