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
0
    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)
예제 #3
0
 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)