original_docstring: Connect to host and start the AMQP protocol.
docstring: Connect to host and start the AMQP protocol.
docstring_tokens: Connect to host and start the AMQP protocol .
code: def connect(self, host):
          """Connect to host and start the AMQP protocol."""
          addr = socket.getaddrinfo(host.hostname, host.port, socket.AF_UNSPEC,
                                    socket.SOCK_STREAM)
          if not addr:
              key = "%s:%i" % (host.hostname, host.port)
              error = "Invalid peer address '%s'" % key
              LOG.error("Invalid peer address '%s'", key)
              self._handler.socket_error(error)
              return
          my_socket = socket.socket(addr[0][0], addr[0][1], addr[0][2])
          my_socket.setblocking(0)  # 0=non-blocking
          my_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
          try:
              my_socket.connect(addr[0][4])
          except socket.error as e:
              if e.errno != errno.EINPROGRESS:
                  error = "Socket connect failure '%s'" % str(e)
                  LOG.error("Socket connect failure '%s'", str(e))
                  self._handler.socket_error(error)
                  return
          self.socket = my_socket
  
          props = self._properties.copy()
          if pyngus.VERSION >= (2, 0, 0):
              # configure client authentication
              #
              props['x-server'] = False
              if host.username:
                  props['x-username'] = host.username
                  props['x-password'] = host.password or ""
  
          self.pyngus_conn = self._container.create_connection(self.name,
                                                               self._handler,
                                                               props)
          self.pyngus_conn.user_context = self
  
          if pyngus.VERSION < (2, 0, 0):
              # older versions of pyngus requires manual SASL configuration:
              # determine the proper SASL mechanism: PLAIN if a username/password
              # is present, else ANONYMOUS
              pn_sasl = self.pyngus_conn.pn_sasl
              if host.username:
                  password = host.password if host.password else ""
                  pn_sasl.plain(host.username, password)
              else:
                  pn_sasl.mechanisms("ANONYMOUS")
                  pn_sasl.client()
  
          self.pyngus_conn.open()
code_tokens: def connect ( self , host ) : addr = socket . getaddrinfo ( host . hostname , host . port , socket . AF_UNSPEC , socket . SOCK_STREAM ) if not addr : key = "%s:%i" % ( host . hostname , host . port ) error = "Invalid peer address '%s'" % key LOG . error ( "Invalid peer address '%s'" , key ) self . _handler . socket_error ( error ) return my_socket = socket . socket ( addr [ 0 ] [ 0 ] , addr [ 0 ] [ 1 ] , addr [ 0 ] [ 2 ] ) my_socket . setblocking ( 0 ) my_socket . setsockopt ( socket . IPPROTO_TCP , socket . TCP_NODELAY , 1 ) try : my_socket . connect ( addr [ 0 ] [ 4 ] ) except socket . error as e : if e . errno != errno . EINPROGRESS : error = "Socket connect failure '%s'" % str ( e ) LOG . error ( "Socket connect failure '%s'" , str ( e ) ) self . _handler . socket_error ( error ) return self . socket = my_socket props = self . _properties . copy ( ) if pyngus . VERSION >= ( 2 , 0 , 0 ) : props [ 'x-server' ] = False if host . username : props [ 'x-username' ] = host . username props [ 'x-password' ] = host . password or "" self . pyngus_conn = self . _container . create_connection ( self . name , self . _handler , props ) self . pyngus_conn . user_context = self if pyngus . VERSION < ( 2 , 0 , 0 ) : pn_sasl = self . pyngus_conn . pn_sasl if host . username : password = host . password if host . password else "" pn_sasl . plain ( host . username , password ) else : pn_sasl . mechanisms ( "ANONYMOUS" ) pn_sasl . client ( ) self . pyngus_conn . open ( )
short_docstring: Connect to host and start the AMQP protocol.
short_docstring_tokens: Connect to host and start the AMQP protocol .
comment: """Connect to host and start the AMQP protocol."""$SEP$# 0=non-blocking$SEP$# configure client authentication$SEP$#$SEP$# older versions of pyngus requires manual SASL configuration:$SEP$# determine the proper SASL mechanism: PLAIN if a username/password$SEP$# is present, else ANONYMOUS