Connect and login.

        Coroutine.
337459
def _log_in(self):
        '''
        '''
        username = self._request.url_info.username or self._request.username or 'anonymous'
        password = self._request.url_info.password or self._request.password or '-wpull@'

        cached_login = self._login_table.get(self._control_connection)

        if cached_login and cached_login == (username, password):
            _logger.debug('Reusing existing login.')
            return

        try:
            yield from self._commander.login(username, password)
        except FTPServerError as error:
            raise AuthenticationError('Login error: {}'.format(error)) \
                from error

        self._login_table[self._control_connection] = (username, password)
717347
def connect(self, autospawn=False, wait=False):
		''''''
		if self._loop_closed:
			raise PulseError('Eventloop object was already'
				' destroyed and cannot be reused from this instance.')
		if self.connected is not None: self._ctx_init()
		flags, self.connected = 0, None
		if not autospawn: flags |= c.PA_CONTEXT_NOAUTOSPAWN
		if wait: flags |= c.PA_CONTEXT_NOFAIL
		try: c.pa.context_connect(self._ctx, self.server, flags, None)
		except c.pa.CallError: self.connected = False
		while self.connected is None: self._pulse_iterate()
		if self.connected is False: raise PulseError('Failed to connect to pulseaudio server')
1023127
async def connect(self, next_time=None):
        
        if self.status in can_connect:
            loop = self._loop
            if loop.is_running():
                self.status = StatusType.connecting
                await self._connect(next_time)
860375
async def run(self):
        """"""
        logging.info('Starting message router...')

        coroutines = set()
        while True:
            coro = self._poll_channel()
            coroutines.add(coro)
            _, coroutines = await asyncio.wait(coroutines, timeout=0.1)
1240273
def request_connect(self, act, coro):
        ""
        result = self.try_run_act(act, perform_connect)
        if result:
            return result, coro
        else:
            self.add_token(act, coro, perform_connect)
229218
def connect(self, signal, **kwargs):
        """"""
        signal.connect(self, **kwargs)
        self.connections.append((signal, kwargs))
743174
def connect(self):
        
        if self.r_session:
            self.session_logout()

        if self.admin_party:
            self._use_iam = False
            self.r_session = ClientSession(
                timeout=self._timeout
            )
        elif self._use_basic_auth:
            self._use_iam = False
            self.r_session = BasicSession(
                self._user,
                self._auth_token,
                self.server_url,
                timeout=self._timeout
            )
        elif self._use_iam:
            self.r_session = IAMSession(
                self._auth_token,
                self.server_url,
                auto_renew=self._auto_renew,
                client_id=self._iam_client_id,
                client_secret=self._iam_client_secret,
                timeout=self._timeout
            )
        else:
            self.r_session = CookieSession(
                self._user,
                self._auth_token,
                self.server_url,
                auto_renew=self._auto_renew,
                timeout=self._timeout
            )

        # If a Transport Adapter was supplied add it to the session
        if self.adapter is not None:
            self.r_session.mount(self.server_url, self.adapter)
        if self._client_user_header is not None:
            self.r_session.headers.update(self._client_user_header)

        self.session_login()

        # Utilize an event hook to append to the response message
        # using :func:`~cloudant.common_util.append_response_error_content`
        self.r_session.hooks['response'].append(append_response_error_content)
166581
def connect(self):
        '''
        
        '''
        if self.connected:
            raise RuntimeError(
                '{} is connected already'.format(self.__class__.__name__))
        if self.closed:
            raise RuntimeError(
                '{} is closed already'.format(self.__class__.__name__))
        self.connected = True
        self._connect()
318451
def connect(self):
        

        if self.session and self.session.is_expired:
            # Close the session to avoid max concurrent session errors
            self.disconnect(abandon_session=True)

        if not self.session:

            try:
                login_result = self.login(self.username, self.password)
            except AccountFault:
                log.error('Login failed, invalid username or password')
                raise
            else:
                self.session = login_result.session_id

        self.connected = time()
        return self.connected
785890
def connect(self):
        """"""
        self.sock = socket_create_connection((self.host,self.port),
                                             self.timeout, self.source_address)
        if self._tunnel_host:
            self._tunnel()
998510
def connect(*args, **kwargs):
    """"""
    global __CONNECTION
    if __CONNECTION is None:
        __CONNECTION = Connection(*args, **kwargs)

    return __CONNECTION
1120088
async def async_connect(self):
        """"""

        kwargs = {
            'username': self._username if self._username else None,
            'client_keys': [self._ssh_key] if self._ssh_key else None,
            'port': self._port,
            'password': self._password if self._password else None,
            'known_hosts': None
        }

        self._client = await asyncssh.connect(self._host, **kwargs)
        self._connected = True
507919
def connect(self):
        ''''''
        _logger.debug(__('Connecting to {0}.', self._address))

        if self._state != ConnectionState.ready:
            raise Exception('Closed connection must be reset before reusing.')

        if self._sock:
            connection_future = asyncio.open_connection(
                sock=self._sock, **self._connection_kwargs()
            )
        else:
            # TODO: maybe we don't want to ignore flow-info and scope-id?
            host = self._address[0]
            port = self._address[1]

            connection_future = asyncio.open_connection(
                host, port, **self._connection_kwargs()
            )

        self.reader, self.writer = yield from \
            self.run_network_operation(
                connection_future,
                wait_timeout=self._connect_timeout,
                name='Connect')

        if self._timeout is not None:
            self._close_timer = CloseTimer(self._timeout, self)
        else:
            self._close_timer = DummyCloseTimer()

        self._state = ConnectionState.created
        _logger.debug('Connected.')
668806
def sync(coro, timeout=None):
    '''
    
    '''
    loop = initloop()
    return asyncio.run_coroutine_threadsafe(coro, loop).result(timeout)
1256809
async def connect(self, connection):
        
        if self._user_connected:
            self._log.info('User is already connected!')
            return

        self._connection = connection
        await self._connect()
        self._user_connected = True
594212
def connect(*args, **kwargs):
    """"""
    from .connections import Connection
    conn = Connection(*args, **kwargs)
    yield conn.connect()
    raise gen.Return(conn)
236541
def submit(self, fn, *args, **kwargs):
        """"""
        corofn = asyncio.coroutine(lambda: fn(*args, **kwargs))
        return run_coroutine_threadsafe(corofn(), self.loop)