COMPS.Client module

class COMPS.Client.Client

Bases: object

Client object for managing access to COMPS

classmethod auth_manager()

Retrieve the AuthManager.

Must be logged in first in, otherwise this raises a RuntimeError.

Returns

the AuthManager instance

classmethod login(hoststring, credential_prompt=None)

Log in to the COMPS service.

The specified COMPS hoststring allows a couple points of flexibility:

  • Secure vs. Unsecure - Specifying the protocol as http or https allows the user to control whether the SSL transport is used for requests. By default, https is used.

  • Port - Specifying a particular port allows the user to control the port to communicate over for requests. By default, the standard port for the chosen protocol is used (i.e. 80 for http, 443 for https).

For example, the following are all valid formats:

  • comps.idmod.org - uses secure https protocol over port 443.

  • http://internal.idmod.org - uses unsecure http protocol over port 80.

  • localhost:54321 - uses secure https protocol over port 54321.

Calling login() when already logged into a different host is invalid and will raise a RuntimeError. When already logged into the same host, nothing is done and the function returns immediately.

Parameters
  • hoststring – the COMPS host to connect to

  • credential_prompt – a CredentialPrompt object that controls how the user will supply their login credentials. By default, pyCOMPS will try to open a graphical prompt (TKCredentialPrompt) and fall back to console (ConsoleCredentialPrompt) if that fails.

classmethod logout(hoststring=None)

Log out of the COMPS service.

If logged in, this clears any cached credentials and nulls the AuthManager instance. Otherwise, you may pass a hoststring parameter to clear cached credentials for a particular COMPS host.

Parameters

hoststring – the COMPS host to clear credentials for

classmethod post(path, include_comps_auth_token=True, http_err_handle_exceptions=None, **kwargs)
classmethod put(path, include_comps_auth_token=True, http_err_handle_exceptions=None, **kwargs)
classmethod get(path, include_comps_auth_token=True, http_err_handle_exceptions=None, **kwargs)
classmethod delete(path, include_comps_auth_token=True, http_err_handle_exceptions=None, **kwargs)
classmethod request(method, path, include_comps_auth_token=True, http_err_handle_exceptions=None, **kwargs)
classmethod raise_err_from_resp(resp)