gerrit.utils package

Submodules

gerrit.utils.common module

gerrit.utils.common.decode_response(response)[source]

Strip off Gerrit’s magic prefix and decode a response. :returns:

Decoded JSON content as a dict, or raw text if content could not be decoded as JSON.

Raises:

requests.HTTPError if the response contains an HTTP error status code.

gerrit.utils.common.params_creator(tuples, pattern_types, pattern_dispatcher)[source]
gerrit.utils.common.strip_trailing_slash(url)[source]

remove url’s trailing slash :param url: url :return:

gerrit.utils.exceptions module

Module for custom exceptions.

Where possible we try to throw exceptions with non-generic, meaningful names.

exception gerrit.utils.exceptions.AccountAlreadyExistsError[source]

Bases: GerritAPIException

Account already exists

exception gerrit.utils.exceptions.AccountEmailAlreadyExistsError[source]

Bases: GerritAPIException

Account Email already exists

exception gerrit.utils.exceptions.AccountEmailNotFoundError[source]

Bases: GerritAPIException

Account Email cannot be found

exception gerrit.utils.exceptions.AccountNotFoundError[source]

Bases: GerritAPIException

Account cannot be found

exception gerrit.utils.exceptions.AuthError[source]

Bases: GerritAPIException

403 Forbidden is returned if the operation is not allowed because the calling user does not have sufficient permissions.

exception gerrit.utils.exceptions.BranchAlreadyExistsError[source]

Bases: GerritAPIException

Branch already exists

exception gerrit.utils.exceptions.BranchNotFoundError[source]

Bases: GerritAPIException

Branch cannot be found

exception gerrit.utils.exceptions.ChangeEditNotFoundError[source]

Bases: GerritAPIException

Change edit cannot be found

exception gerrit.utils.exceptions.ChangeNotFoundError[source]

Bases: GerritAPIException

Change cannot be found

exception gerrit.utils.exceptions.ClientError[source]

Bases: GerritAPIException

Client Error

exception gerrit.utils.exceptions.CommitNotFoundError[source]

Bases: GerritAPIException

Commit cannot be found

exception gerrit.utils.exceptions.ConflictError[source]

Bases: GerritAPIException

409 Conflict is returned if the request cannot be completed because the current state of the resource doesn’t allow the operation.

exception gerrit.utils.exceptions.FileContentNotFoundError[source]

Bases: GerritAPIException

File content not found

exception gerrit.utils.exceptions.GPGKeyNotFoundError[source]

Bases: GerritAPIException

GPG key cannot be found

exception gerrit.utils.exceptions.GerritAPIException[source]

Bases: Exception

Base class for all errors

exception gerrit.utils.exceptions.GroupAlreadyExistsError[source]

Bases: GerritAPIException

Group already exists

exception gerrit.utils.exceptions.GroupMemberAlreadyExistsError[source]

Bases: GerritAPIException

Group member already exists

exception gerrit.utils.exceptions.GroupMemberNotFoundError[source]

Bases: GerritAPIException

Group member cannot be found

exception gerrit.utils.exceptions.GroupNotFoundError[source]

Bases: GerritAPIException

Group cannot be found

exception gerrit.utils.exceptions.NotAllowedError[source]

Bases: GerritAPIException

405 Method Not Allowed is returned if the resource exists but doesn’t support the operation.

exception gerrit.utils.exceptions.NotFoundError[source]

Bases: GerritAPIException

Resource cannot be found

exception gerrit.utils.exceptions.ProjectAlreadyExistsError[source]

Bases: GerritAPIException

Project already exists

exception gerrit.utils.exceptions.ProjectNotFoundError[source]

Bases: GerritAPIException

Project cannot be found

exception gerrit.utils.exceptions.ReviewerAlreadyExistsError[source]

Bases: GerritAPIException

Reviewer already exists

exception gerrit.utils.exceptions.ReviewerNotFoundError[source]

Bases: GerritAPIException

Reviewer cannot be found

exception gerrit.utils.exceptions.SSHKeyNotFoundError[source]

Bases: GerritAPIException

SSH key cannot be found

exception gerrit.utils.exceptions.ServerError[source]

Bases: GerritAPIException

Server Error

exception gerrit.utils.exceptions.TagAlreadyExistsError[source]

Bases: GerritAPIException

Tag already exists

exception gerrit.utils.exceptions.TagNotFoundError[source]

Bases: GerritAPIException

Tag cannot be found

exception gerrit.utils.exceptions.UnauthorizedError[source]

Bases: GerritAPIException

401 Unauthorized

exception gerrit.utils.exceptions.UnknownBranch[source]

Bases: KeyError, NotFoundError

Gerrit does not recognize the branch requested.

exception gerrit.utils.exceptions.UnknownFile[source]

Bases: KeyError, NotFoundError

Gerrit does not recognize the revision file requested.

exception gerrit.utils.exceptions.UnknownTag[source]

Bases: KeyError, NotFoundError

Gerrit does not recognize the tag requested.

exception gerrit.utils.exceptions.ValidationError[source]

Bases: GerritAPIException

400 Bad Request is returned if the request is not understood by the server due to malformed syntax. E.g. 400 Bad Request is returned if JSON input is expected but the ‘Content-Type’ of the request

is not ‘application/json’ or the request body doesn’t contain valid JSON.

400 Bad Request is also returned if required input fields are not set or if options are set which cannot be used together.

gerrit.utils.gerritbase module

class gerrit.utils.gerritbase.GerritBase(pull=True)[source]

Bases: object

This appears to be the base object that all other gerrit objects are inherited from

poll()[source]
to_dict()[source]

Print out all the data in this object for debugging.

gerrit.utils.requester module

class gerrit.utils.requester.Requester(**kwargs)[source]

Bases: object

A class which carries out HTTP requests. You can replace this class with one of your own implementation if you require some other way to access Gerrit. This default class can handle simple authentication only.

VALID_STATUS_CODES = [200]
static confirm_status(res)[source]

check response status code :param res: :return:

delete(url, headers=None, allow_redirects=True, raise_for_status: bool = True, **kwargs)[source]
Parameters:
  • url

  • headers

  • allow_redirects

  • raise_for_status

  • kwargs

Returns:

get(url, params=None, headers=None, allow_redirects=True, stream=False, raise_for_status: bool = True, **kwargs)[source]
Parameters:
  • url

  • params

  • headers

  • allow_redirects

  • stream

  • raise_for_status

  • kwargs

Returns:

get_request_dict(params=None, data=None, json=None, headers=None, **kwargs)[source]
Parameters:
  • params

  • data

  • json

  • headers

  • kwargs

Returns:

post(url, params=None, data=None, json=None, files=None, headers=None, allow_redirects=True, raise_for_status: bool = True, **kwargs)[source]
Parameters:
  • url

  • params

  • data

  • json

  • files

  • headers

  • allow_redirects

  • raise_for_status

  • kwargs

Returns:

put(url, params=None, data=None, json=None, files=None, headers=None, allow_redirects=True, raise_for_status: bool = True, **kwargs)[source]
Parameters:
  • url

  • params

  • data

  • json

  • files

  • headers

  • allow_redirects

  • raise_for_status

  • kwargs

Returns:

Module contents