parameters: (server, email=None, host_override=None, save_cookies=True,
                   account_type=AUTH_ACCOUNT_TYPE)
return_statement: return rpc_server_class(server,
                            GetUserCredentials,
                            host_override=host_override,
                            save_cookies=save_cookies)
docstring: Returns an instance of an AbstractRpcServer.
  
    Args:
      server: String containing the review server URL.
      email: String containing user's email address.
      host_override: If not None, string containing an alternate hostname to use
        in the host header.
      save_cookies: Whether authentication cookies should be saved to disk.
      account_type: Account type for authentication, either 'GOOGLE'
        or 'HOSTED'. Defaults to AUTH_ACCOUNT_TYPE.
  
    Returns:
      A new AbstractRpcServer, on which RPC calls can be made.
docstring_summary: Returns an instance of an AbstractRpcServer.
docstring_tokens: Returns an instance of an AbstractRpcServer .
function: def GetRpcServer(server, email=None, host_override=None, save_cookies=True,
                   account_type=AUTH_ACCOUNT_TYPE):
    """Returns an instance of an AbstractRpcServer.
  
    Args:
      server: String containing the review server URL.
      email: String containing user's email address.
      host_override: If not None, string containing an alternate hostname to use
        in the host header.
      save_cookies: Whether authentication cookies should be saved to disk.
      account_type: Account type for authentication, either 'GOOGLE'
        or 'HOSTED'. Defaults to AUTH_ACCOUNT_TYPE.
  
    Returns:
      A new AbstractRpcServer, on which RPC calls can be made.
    """
  
    rpc_server_class = HttpRpcServer
  
    # If this is the dev_appserver, use fake authentication.
    host = (host_override or server).lower()
    if re.match(r'(http://)?localhost([:/]|$)', host):
      if email is None:
        email = "test@example.com"
        logging.info("Using debug user %s.  Override with --email" % email)
      server = rpc_server_class(
          server,
          lambda: (email, "password"),
          host_override=host_override,
          extra_headers={"Cookie":
                         'dev_appserver_login="%s:False"' % email},
          save_cookies=save_cookies,
          account_type=account_type)
      # Don't try to talk to ClientLogin.
      server.authenticated = True
      return server
  
    def GetUserCredentials():
      """Prompts the user for a username and password."""
      # Create a local alias to the email variable to avoid Python's crazy
      # scoping rules.
      global keyring
      local_email = email
      if local_email is None:
        local_email = GetEmail("Email (login for uploading to %s)" % server)
      password = None
      if keyring:
        try:
          password = keyring.get_password(host, local_email)
        except:
          # Sadly, we have to trap all errors here as
          # gnomekeyring.IOError inherits from object. :/
          print "Failed to get password from keyring"
          keyring = None
      if password is not None:
        print "Using password from system keyring."
      else:
        password = getpass.getpass("Password for %s: " % local_email)
        if keyring:
          answer = raw_input("Store password in system keyring?(y/N) ").strip()
          if answer == "y":
            keyring.set_password(host, local_email, password)
      return (local_email, password)
  
    return rpc_server_class(server,
                            GetUserCredentials,
                            host_override=host_override,
                            save_cookies=save_cookies)
function_tokens: def GetRpcServer ( server , email = None , host_override = None , save_cookies = True , account_type = AUTH_ACCOUNT_TYPE ) : rpc_server_class = HttpRpcServer # If this is the dev_appserver, use fake authentication. host = ( host_override or server ) . lower ( ) if re . match ( r'(http://)?localhost([:/]|$)' , host ) : if email is None : email = "test@example.com" logging . info ( "Using debug user %s.  Override with --email" % email ) server = rpc_server_class ( server , lambda : ( email , "password" ) , host_override = host_override , extra_headers = { "Cookie" : 'dev_appserver_login="%s:False"' % email } , save_cookies = save_cookies , account_type = account_type ) # Don't try to talk to ClientLogin. server . authenticated = True return server def GetUserCredentials ( ) : """Prompts the user for a username and password.""" # Create a local alias to the email variable to avoid Python's crazy # scoping rules. global keyring local_email = email if local_email is None : local_email = GetEmail ( "Email (login for uploading to %s)" % server ) password = None if keyring : try : password = keyring . get_password ( host , local_email ) except : # Sadly, we have to trap all errors here as # gnomekeyring.IOError inherits from object. :/ print "Failed to get password from keyring" keyring = None if password is not None : print "Using password from system keyring." else : password = getpass . getpass ( "Password for %s: " % local_email ) if keyring : answer = raw_input ( "Store password in system keyring?(y/N) " ) . strip ( ) if answer == "y" : keyring . set_password ( host , local_email , password ) return ( local_email , password ) return rpc_server_class ( server , GetUserCredentials , host_override = host_override , save_cookies = save_cookies )