Analysis Software
Documentation for sPHENIX simulation software
|
Public Member Functions | |
def | __init__ |
def | Send |
def | __init__ |
def | Send |
Public Attributes | |
host | |
host_override | |
auth_function | |
authenticated | |
extra_headers | |
save_cookies | |
opener | |
Private Member Functions | |
def | _GetOpener |
def | _CreateRequest |
def | _GetAuthToken |
def | _GetAuthCookie |
def | _Authenticate |
def | _GetOpener |
def | _CreateRequest |
def | _GetAuthToken |
def | _GetAuthCookie |
def | _Authenticate |
Provides a common interface for a simple RPC server.
Definition at line 124 of file upload.py.
View newest version in sPHENIX GitHub at line 124 of file upload.py
def upload.AbstractRpcServer.__init__ | ( | self, | |
host, | |||
auth_function, | |||
host_override = None , |
|||
extra_headers = {} , |
|||
save_cookies = False |
|||
) |
Creates a new HttpRpcServer. Args: host: The host to send requests to. auth_function: A function that takes no arguments and returns an (email, password) tuple when called. Will be called if authentication is required. host_override: The host header to send to the server (defaults to host). extra_headers: A dict of extra headers to append to every request. save_cookies: If True, save the authentication cookies to local disk. If False, use an in-memory cookiejar instead. Subclasses must implement this functionality. Defaults to False.
Definition at line 128 of file upload.py.
View newest version in sPHENIX GitHub at line 128 of file upload.py
def upload.AbstractRpcServer.__init__ | ( | self, | |
host, | |||
auth_function, | |||
host_override = None , |
|||
extra_headers = {} , |
|||
save_cookies = False |
|||
) |
Creates a new HttpRpcServer. Args: host: The host to send requests to. auth_function: A function that takes no arguments and returns an (email, password) tuple when called. Will be called if authentication is required. host_override: The host header to send to the server (defaults to host). extra_headers: A dict of extra headers to append to every request. save_cookies: If True, save the authentication cookies to local disk. If False, use an in-memory cookiejar instead. Subclasses must implement this functionality. Defaults to False.
Definition at line 128 of file upload.py.
View newest version in sPHENIX GitHub at line 128 of file upload.py
References upload.AbstractRpcServer._GetOpener(), upload.AbstractRpcServer.auth_function, upload.AbstractRpcServer.authenticated, upload.AbstractRpcServer.extra_headers, upload.AbstractRpcServer.host, hLabHelper.host, upload.AbstractRpcServer.host_override, upload.AbstractRpcServer.opener, and upload.AbstractRpcServer.save_cookies.
|
private |
Authenticates the user. The authentication process works as follows: 1) We get a username and password from the user 2) We use ClientLogin to obtain an AUTH token for the user (see http://code.google.com/apis/accounts/AuthForInstalledApps.html). 3) We pass the auth token to /_ah/login on the server to obtain an authentication cookie. If login was successful, it tries to redirect us to the URL we provided. If we attempt to access the upload API without first obtaining an authentication cookie, it returns a 401 response and directs us to authenticate ourselves with ClientLogin.
Definition at line 239 of file upload.py.
View newest version in sPHENIX GitHub at line 239 of file upload.py
References upload.AbstractRpcServer._GetAuthCookie(), upload.AbstractRpcServer._GetAuthToken(), upload.AbstractRpcServer.auth_function, and upload.AbstractRpcServer.Send().
Referenced by upload.AbstractRpcServer._Authenticate(), and upload.AbstractRpcServer.Send().
|
private |
Authenticates the user. The authentication process works as follows: 1) We get a username and password from the user 2) We use ClientLogin to obtain an AUTH token for the user (see http://code.google.com/apis/accounts/AuthForInstalledApps.html). 3) We pass the auth token to /_ah/login on the server to obtain an authentication cookie. If login was successful, it tries to redirect us to the URL we provided. If we attempt to access the upload API without first obtaining an authentication cookie, it returns a 401 response and directs us to authenticate ourselves with ClientLogin.
Definition at line 239 of file upload.py.
View newest version in sPHENIX GitHub at line 239 of file upload.py
References upload.AbstractRpcServer._Authenticate(), upload.AbstractRpcServer._GetAuthCookie(), upload.AbstractRpcServer._GetAuthToken(), upload.AbstractRpcServer.auth_function, and upload.AbstractRpcServer.Send().
|
private |
Creates a new urllib request.
Definition at line 162 of file upload.py.
View newest version in sPHENIX GitHub at line 162 of file upload.py
References upload.AbstractRpcServer._CreateRequest(), and upload.AbstractRpcServer.host_override.
|
private |
Creates a new urllib request.
Definition at line 162 of file upload.py.
View newest version in sPHENIX GitHub at line 162 of file upload.py
References upload.AbstractRpcServer.host_override.
Referenced by upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer._GetAuthCookie(), upload.AbstractRpcServer._GetAuthToken(), and upload.AbstractRpcServer.Send().
|
private |
Fetches authentication cookies for an authentication token. Args: auth_token: The authentication token returned by ClientLogin. Raises: HTTPError: If there was an error fetching the authentication cookies.
Definition at line 215 of file upload.py.
View newest version in sPHENIX GitHub at line 215 of file upload.py
References upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer._GetAuthCookie(), upload.AbstractRpcServer.authenticated, hLabHelper.host, and upload.AbstractRpcServer.host.
|
private |
Fetches authentication cookies for an authentication token. Args: auth_token: The authentication token returned by ClientLogin. Raises: HTTPError: If there was an error fetching the authentication cookies.
Definition at line 215 of file upload.py.
View newest version in sPHENIX GitHub at line 215 of file upload.py
References upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer.authenticated, upload.AbstractRpcServer.host, and hLabHelper.host.
Referenced by upload.AbstractRpcServer._Authenticate(), and upload.AbstractRpcServer._GetAuthCookie().
|
private |
Uses ClientLogin to authenticate the user, returning an auth token. Args: email: The user's email address password: The user's password Raises: ClientLoginError: If there was an error authenticating with ClientLogin. HTTPError: If there was some other form of HTTP error. Returns: The authentication token returned by ClientLogin.
Definition at line 172 of file upload.py.
View newest version in sPHENIX GitHub at line 172 of file upload.py
References upload.AbstractRpcServer._CreateRequest(), and upload.AbstractRpcServer._GetAuthToken().
|
private |
Uses ClientLogin to authenticate the user, returning an auth token. Args: email: The user's email address password: The user's password Raises: ClientLoginError: If there was an error authenticating with ClientLogin. HTTPError: If there was some other form of HTTP error. Returns: The authentication token returned by ClientLogin.
Definition at line 172 of file upload.py.
View newest version in sPHENIX GitHub at line 172 of file upload.py
References upload.AbstractRpcServer._CreateRequest().
Referenced by upload.AbstractRpcServer._Authenticate(), and upload.AbstractRpcServer._GetAuthToken().
|
private |
Returns an OpenerDirector for making HTTP requests. Returns: A urllib2.OpenerDirector object.
Definition at line 154 of file upload.py.
View newest version in sPHENIX GitHub at line 154 of file upload.py
References upload.AbstractRpcServer._GetOpener().
|
private |
Returns an OpenerDirector for making HTTP requests. Returns: A urllib2.OpenerDirector object.
Definition at line 154 of file upload.py.
View newest version in sPHENIX GitHub at line 154 of file upload.py
Referenced by upload.AbstractRpcServer.__init__(), and upload.AbstractRpcServer._GetOpener().
def upload.AbstractRpcServer.Send | ( | self, | |
request_path, | |||
payload = None , |
|||
content_type = "application/octet-stream" , |
|||
timeout = None , |
|||
kwargs | |||
) |
Sends an RPC and returns the response. Args: request_path: The path to send the request to, eg /api/appversion/create. payload: The body of the request, or None to send an empty request. content_type: The Content-Type header to use. timeout: timeout in seconds; default None i.e. no timeout. (Note: for large requests on OS X, the timeout doesn't work right.) kwargs: Any keyword arguments are converted into query string parameters. Returns: The response body, as a string.
Definition at line 294 of file upload.py.
View newest version in sPHENIX GitHub at line 294 of file upload.py
References upload.AbstractRpcServer._Authenticate(), upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer.authenticated, hLabHelper.host, and upload.AbstractRpcServer.host.
Referenced by upload.AbstractRpcServer._Authenticate().
def upload.AbstractRpcServer.Send | ( | self, | |
request_path, | |||
payload = None , |
|||
content_type = "application/octet-stream" , |
|||
timeout = None , |
|||
kwargs | |||
) |
Sends an RPC and returns the response. Args: request_path: The path to send the request to, eg /api/appversion/create. payload: The body of the request, or None to send an empty request. content_type: The Content-Type header to use. timeout: timeout in seconds; default None i.e. no timeout. (Note: for large requests on OS X, the timeout doesn't work right.) kwargs: Any keyword arguments are converted into query string parameters. Returns: The response body, as a string.
Definition at line 294 of file upload.py.
View newest version in sPHENIX GitHub at line 294 of file upload.py
References upload.AbstractRpcServer._Authenticate(), upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer.authenticated, hLabHelper.host, and upload.AbstractRpcServer.host.
upload.AbstractRpcServer.auth_function |
Definition at line 144 of file upload.py.
View newest version in sPHENIX GitHub at line 144 of file upload.py
Referenced by upload.AbstractRpcServer.__init__(), and upload.AbstractRpcServer._Authenticate().
upload.AbstractRpcServer.authenticated |
Definition at line 145 of file upload.py.
View newest version in sPHENIX GitHub at line 145 of file upload.py
Referenced by upload.AbstractRpcServer.__init__(), upload.AbstractRpcServer._GetAuthCookie(), upload.HttpRpcServer._GetOpener(), and upload.AbstractRpcServer.Send().
upload.AbstractRpcServer.extra_headers |
Definition at line 146 of file upload.py.
View newest version in sPHENIX GitHub at line 146 of file upload.py
Referenced by upload.AbstractRpcServer.__init__().
upload.AbstractRpcServer.host |
Definition at line 142 of file upload.py.
View newest version in sPHENIX GitHub at line 142 of file upload.py
Referenced by upload.AbstractRpcServer.__init__(), upload.AbstractRpcServer._GetAuthCookie(), and upload.AbstractRpcServer.Send().
upload.AbstractRpcServer.host_override |
Definition at line 143 of file upload.py.
View newest version in sPHENIX GitHub at line 143 of file upload.py
Referenced by upload.AbstractRpcServer.__init__(), and upload.AbstractRpcServer._CreateRequest().
upload.AbstractRpcServer.opener |
Definition at line 148 of file upload.py.
View newest version in sPHENIX GitHub at line 148 of file upload.py
Referenced by upload.AbstractRpcServer.__init__().
upload.AbstractRpcServer.save_cookies |
Definition at line 147 of file upload.py.
View newest version in sPHENIX GitHub at line 147 of file upload.py
Referenced by upload.AbstractRpcServer.__init__(), upload.HttpRpcServer._Authenticate(), and upload.HttpRpcServer._GetOpener().