def _GetRpcServer(self):

    def GetUserCredentials():
      """Prompts the user for a username and password."""
      email = self.options.email
      if email is None:
        email = self.raw_input_fn('Email: ')

      password_prompt = 'Password for %s: ' % email


      if self.options.passin:
        password = self.raw_input_fn(password_prompt)
      else:
        password = self.password_input_fn(password_prompt)

      return (email, password)

    StatusUpdate('Host: %s' % self.options.server)



    dev_appserver = self.options.host == 'localhost'
    if self.options.oauth2 and not dev_appserver:
      if not appengine_rpc_httplib2:

        raise OAuthNotAvailable()
      if not self.rpc_server_class:
        self.rpc_server_class = appengine_rpc_httplib2.HttpRpcServerOauth2

      get_user_credentials = self.options.oauth2_refresh_token

      source = (self.oauth_client_id,
                self.oauth_client_secret,
                self.oauth_scopes,
                self.options.oauth2_credential_file)

      appengine_rpc_httplib2.tools.FLAGS.auth_local_webserver = (
          self.options.auth_local_webserver)
    else:
      if not self.rpc_server_class:
        self.rpc_server_class = appengine_rpc.HttpRpcServerWithOAuth2Suggestion
      get_user_credentials = GetUserCredentials
      source = GetSourceName()


    if dev_appserver:
      email = self.options.email
      if email is None:
        email = 'test@example.com'
        logging.info('Using debug user %s.  Override with --email', email)
      rpcserver = self.rpc_server_class(
          self.options.server,
          lambda: (email, 'password'),
          GetUserAgent(),
          source,
          host_override=self.options.host,
          save_cookies=self.options.save_cookies,

          secure=False)

      rpcserver.authenticated = True
      return rpcserver


    if self.options.passin:
      auth_tries = 1
    else:
      auth_tries = 3

    return self.rpc_server_class(self.options.server, get_user_credentials,
                                 GetUserAgent(), source,
                                 host_override=self.options.host,
                                 save_cookies=self.options.save_cookies,
                                 auth_tries=auth_tries,
                                 account_type='HOSTED_OR_GOOGLE',
                                 secure=self.options.secure,
                                 ignore_certs=self.options.ignore_certs)
Returns an instance of an AbstractRpcServer.
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/tools/appcfg.py/AppCfgApp._GetRpcServer