Login to a Glances server
969765
def _login_glances(self):
        """"""
        client_version = None
        try:
            client_version = self.client.init()
        except socket.error as err:
            # Fallback to SNMP
            self.client_mode = 'snmp'
            logger.error("Connection to Glances server failed ({} {})".format(err.errno, err.strerror))
            fallbackmsg = 'No Glances server found on {}. Trying fallback to SNMP...'.format(self.uri)
            if not self.return_to_browser:
                print(fallbackmsg)
            else:
                logger.info(fallbackmsg)
        except ProtocolError as err:
            # Other errors
            msg = "Connection to server {} failed".format(self.uri)
            if err.errcode == 401:
                msg += " (Bad username/password)"
            else:
                msg += " ({} {})".format(err.errcode, err.errmsg)
            self.log_and_exit(msg)
            return False

        if self.client_mode == 'glances':
            # Check that both client and server are in the same major version
            if __version__.split('.')[0] == client_version.split('.')[0]:
                # Init stats
                self.stats = GlancesStatsClient(config=self.config, args=self.args)
                self.stats.set_plugins(json.loads(self.client.getAllPlugins()))
                logger.debug("Client version: {} / Server version: {}".format(__version__, client_version))
            else:
                self.log_and_exit(('Client and server not compatible: '
                                   'Client version: {} / Server version: {}'.format(__version__, client_version)))
                return False

        return True
1324992
def authenticate_glance_admin(self, keystone, force_v1_client=False):
        """"""
        self.log.debug('Authenticating glance admin...')
        ep = keystone.service_catalog.url_for(service_type='image',
                                              interface='adminURL')
        if not force_v1_client and keystone.session:
            return glance_clientv2.Client("2", session=keystone.session)
        else:
            return glance_client.Client(ep, token=keystone.auth_token)
616389
def login(self, usr, pwd):
        
        self._usr = usr
        self._pwd = pwd
73524
def _login(self, csrf_token):
        """"""
        login_response = self.session.post(
            self.URLS['login'],
            data={
                'username': self._get_provider_option('auth_username') or '',
                'password': self._get_provider_option('auth_password') or '',
                'submit': '',
                'loginxtoken': csrf_token,
            }
        )
        self._log('Login', login_response)
        assert login_response.status_code == 200, \
            'Could not login due to a network error.'
        assert login_response.url == self.URLS['overview'], \
            'Easyname login failed, bad EASYNAME_USER or EASYNAME_PASS.'
1308132
def login(session):
    """"""
    if not session.auth.username or not session.auth.password:
        raise VooblyError('must supply username and password')
    _LOGGER.info("logging in (no valid cookie found)")
    session.cookies.clear()
    try:
        session.get(session.auth.base_url + LOGIN_PAGE)
        resp = session.post(session.auth.base_url + LOGIN_URL, data={
            'username': session.auth.username,
            'password': session.auth.password
        })
    except RequestException:
        raise VooblyError('failed to connect for login')
    if resp.status_code != 200:
        raise VooblyError('failed to login')
    _save_cookies(session.cookies, session.auth.cookie_path)
1366653
def connect_login(self):
        
        self.client.connect(self.options['server'], self.options['port'], self.options['username'],
                            self.options['password'])
        self.comm_chan = self.client.invoke_shell()
        time.sleep(1)  # Let the server take some time to get ready.
        while not self.comm_chan.recv_ready():
            time.sleep(0.5)
        login_response = self.comm_chan.recv(2048)
        if not login_response.endswith('$ '):
            raise AuthenticationFailed
        return login_response
1200994
def login
      response = post('/login', body: { username: configuration.username, password: configuration.password },
                                headers: { 'Content-Type' => 'application/json' })
      if response.code == 200
        @token = JSON.parse(response.body, symbolize_names: true, quirks_mode: true)
        true
      else
        false
      end
    end
562167
def connect(self, server):
        ""
        if 'connections' not in session:
            session['connections'] = {}
            session.save()

        conns = session['connections']
        id = str(len(conns))
        conn = Connection(server)
        conns[id] = conn
        yield request.environ['cogen.core'].events.AddCoro(conn.pull)
        yield id
667523
def login(username, password):
    
    check_for_cloud_server()
    old_username = config["cloud_server"]["username"]
    if old_username and old_username != username:
        raise click.ClickException(
            "Already logged in as user \"{}\". Run `openag cloud user logout` "
            "before attempting to log in as a different user".format(
                old_username
            )
        )
    server = Server(config["cloud_server"]["url"])
    server.log_in(username, password)
    config["cloud_server"]["username"] = username
    config["cloud_server"]["password"] = password
345888
def update_glances(self):
        
        # Update the stats
        try:
            server_stats = json.loads(self.client.getAll())
        except socket.error:
            # Client cannot get server stats
            return "Disconnected"
        except Fault:
            # Client cannot get server stats (issue #375)
            return "Disconnected"
        else:
            # Put it in the internal dict
            self.stats.update(server_stats)
            return "Connected"
417096
def _login(self, username="", password=""):
        
        self.log.debug("----------------")
        self.log.debug("Logging in (username: %s)..." % username)

        def run_query():
            return self._xmlrpc_server.LogIn(
                username, password, self.language, self.user_agent)

        info = self._safe_exec(run_query, None)
        if info is None:
            self._token = None
            return False

        self.log.debug("Login ended in %s with status: %s" %
                       (info['seconds'], info['status']))

        if info['status'] == "200 OK":
            self.log.debug("Session ID: %s" % info['token'])
            self.log.debug("----------------")
            self._token = info['token']
            return True
        else:
            # force token reset
            self.log.debug("----------------")
            self._token = None
            return False
1216837
def run(cutouts, hostname="localhost", port=DEFAULT_PORT):
  """"""
  def handler(*args):
    return ViewerServerHandler(cutouts, *args)

  myServer = HTTPServer((hostname, port), handler)
  print("Viewer server listening to http://{}:{}".format(hostname, port))
  try:
    myServer.serve_forever()
  except KeyboardInterrupt:
    # extra \n to prevent display of "^CContinuing"
    print("\nContinuing program execution...")
  finally:
    myServer.server_close()
872761
def login():
    """"""

    form_class = _security.login_form

    if request.is_json:
        form = form_class(MultiDict(request.get_json()))
    else:
        form = form_class(request.form)

    if form.validate_on_submit():
        login_user(form.user, remember=form.remember.data)
        after_this_request(_commit)

        if not request.is_json:
            return redirect(get_post_login_redirect(form.next.data))

    if request.is_json:
        return _render_json(form, include_auth_token=True)

    return _security.render_template(config_value('LOGIN_USER_TEMPLATE'),
                                     login_user_form=form,
                                     **_ctx('login'))
1110091
def check_auth(username, password):
    

    with open(os.path.expanduser("~/config/.note.conf")) as fd:
        config = json.loads(fd.read())

    try:
        u = config['server']['login']['username']
        p = config['server']['login']['password']
    except KeyError:
        print "cannot start server"
        sys.exit(1)

    return username == u and password == p
203049
def _request_login(self, login, password):
        """"""
        return self._request_internal("Login",
                                      login=login,
                                      password=password)
134495
def color_prompt(self):
        '''  '''
        prompt = '[' + colorize('psiTurk', 'bold')
        server_string = ''
        server_status = self.server.is_server_running()
        if server_status == 'yes':
            server_string = colorize('on', 'green')
        elif server_status == 'no':
            server_string = colorize('off', 'red')
        elif server_status == 'maybe':
            server_string = colorize('unknown', 'yellow')
        elif server_status == 'blocked':
            server_string = colorize('blocked', 'red')
        prompt += ' server:' + server_string
        prompt += ' mode:' + colorize('cabin', 'bold')
        prompt += ']$ '
        self.prompt = prompt
839450
def _login(self, username, password):
        """"""
        data = {
            'username': username,
            'password': password,
            'grant_type': 'password'
        }
        r = self.spark_api.oauth.token.POST(auth=('spark', 'spark'), data=data, timeout=self.timeout)
        self._check_error(r)
        return r.json()['access_token']