toxicbuild.common package

Submodules

toxicbuild.common.client module

class toxicbuild.common.client.HoleClient(requester, *args, hole_token=None, **kwargs)[source]

Bases: toxicbuild.core.client.BaseToxicClient, toxicbuild.core.utils.LoggerMixin

Client for the master’s hole.

coroutine connect2stream(body)[source]

Connects the client to the master’s hole stream.

coroutine get_response()[source]

Reads data from the server and raises and exception in case of error

coroutine request2server(action, body)[source]

Performs a request to a hole server.

Parameters:
  • action – The action to perform on the server.
  • body – The body of the request, with the actions parameters.
settings = None
toxicbuild.common.client.get_hole_client(requester, host, port, hole_token=None, **kwargs)[source]

toxicbuild.common.exceptions module

exception toxicbuild.common.exceptions.AlreadyExists[source]

Bases: Exception

exception toxicbuild.common.exceptions.BadResetPasswordToken[source]

Bases: Exception

exception toxicbuild.common.exceptions.BadSettingsType[source]

Bases: Exception

exception toxicbuild.common.exceptions.NotEnoughPerms[source]

Bases: Exception

exception toxicbuild.common.exceptions.UserDoesNotExist[source]

Bases: Exception

toxicbuild.common.interfaces module

Module with base models that are populated using a remote api.

class toxicbuild.common.interfaces.BaseHoleInterface(requester, ordered_kwargs)[source]

Bases: toxicbuild.common.interfaces.BaseInterface

coroutine classmethod get_client(requester)[source]

Returns a client connected to master.

class toxicbuild.common.interfaces.BaseInterface(requester, ordered_kwargs)[source]

Bases: object

to_dict(dtformat=None, tzname=None)[source]

Transforms a model into a dict.

Parameters:
  • dtformat – Format for datetimes.
  • tzname – A timezone name.
to_json(*args, **kwargs)[source]

Transforms a model into a json.

Parameters:
  • args – Positional arguments passed to to_dict().
  • kwargs – Named arguments passed to to_dict().
references = {}
settings = None
class toxicbuild.common.interfaces.BuildInterface(requester, ordered_kwargs)[source]

Bases: toxicbuild.common.interfaces.BaseHoleInterface

coroutine classmethod get(requester, uuid)[source]

Returns information about abuild. :param uuid: The uuid of the build.

to_dict(*args, **kwargs)[source]

Converts a build object in to a dictionary.

Parameters:
  • args – Positional arguments passed to to_dict().
  • kwargs – Named arguments passed to to_dict().
references = {'builder': <class 'toxicbuild.common.interfaces.BuilderInterface'>, 'steps': <class 'toxicbuild.common.interfaces.StepInterface'>}
class toxicbuild.common.interfaces.BuildSetInterface(requester, ordered_kwargs)[source]

Bases: toxicbuild.common.interfaces.BaseHoleInterface

coroutine classmethod get(requester, buildset_id)[source]

Returns an instance of BuildSet.

Parameters:buildset_id – The id of the buildset to get.
coroutine classmethod list(requester, repo_name_or_id=None, summary=True, branch=None)[source]

Lists buildsets. If repo_name_or_id only builds of this repsitory will be listed.

Parameters:
  • repo_name – Name of a repository.
  • summary – If True, no builds information will be returned.
  • branch – List buildsets for this branch. If None list buildsets from all branches.
to_dict(*args, **kwargs)[source]

Returns a dictionary based in a BuildSet object.

Parameters:
  • args – Positional arguments passed to to_dict().
  • kwargs – Named arguments passed to to_dict().
references = {'builds': <class 'toxicbuild.common.interfaces.BuildInterface'>, 'repository': <class 'toxicbuild.common.interfaces.RepositoryInterface'>}
class toxicbuild.common.interfaces.BuilderInterface(requester, ordered_kwargs)[source]

Bases: toxicbuild.common.interfaces.BaseHoleInterface

coroutine classmethod list(requester, **kwargs)[source]

Lists builders already used.

class toxicbuild.common.interfaces.NotificationInterface(ordered_kwargs)[source]

Bases: toxicbuild.common.interfaces.BaseInterface

Integration with the notifications api.

classmethod api_token()[source]
classmethod api_url()[source]
coroutine classmethod disable(repo_id, notif_name)[source]

Disables a notification for a given repository.

Parameters:
  • repo_id – The id of the repository to enable the notification.
  • notif_name – The name of the notification.
coroutine classmethod enable(repo_id, notif_name, **config)[source]

Enables a notification for a given repository.

Parameters:
  • repo_id – The id of the repository to enable the notification.
  • notif_name – The name of the notification.
  • config – A dictionary with the config values for the notification.
coroutine classmethod list(obj_id=None)[source]

Lists all the notifications available.

Parameters:obj_id – The of of an repository. If not None, the notifications will return the values of the configuration for that repository.
coroutine classmethod update(repo_id, notif_name, **config)[source]

Updates a notification for a given repository.

Parameters:
  • repo_id – The id of the repository to enable the notification.
  • notif_name – The name of the notification.
  • config – A dictionary with the new config values for the notification.
class toxicbuild.common.interfaces.RepositoryInterface(requester, ordered_kwargs)[source]

Bases: toxicbuild.common.interfaces.BaseHoleInterface

Interface for a repository.

coroutine classmethod add(requester, name, url, owner, vcs_type, update_seconds=300, slaves=None, parallel_builds=None, schedule_poller=True, branches=None, external_id=None, external_full_name=None, fetch_url=None, envvars=None)[source]

Adds a new repository.

Parameters:
  • requester – The user who is requesting the operation.
  • name – Repository’s name.
  • url – Repository’s url.
  • owner – The repository owner
  • vcs_type – VCS type used on the repository.
  • update_seconds – Interval to update the repository code.
  • slaves – List with slave names for this reporitory.
  • schedule_poller – Should this repository be scheduled for polling? If this repository comes from an integration (with github, gitlab, etc…) this should be False.
  • branches – A list of branches configuration that trigger builds.
  • external_id – The id of the repository in an external service.
  • external_full_name – The full name in an external service.
  • fetch_url – If the repository uses a differente url to fetch code (ie: it has an auth token url) this is the fetch_url.
  • envvars – Environment variables that will be used in every build in this repository.
Params parallel_builds:
 

How many paralles builds this repository executes. If None, there is no limit.

coroutine add_branch(branch_name, notify_only_latest)[source]

Adds a branch config to a repositoiry.

Parameters:
  • branch_name – The name of the branch.
  • notify_only_latest – If we should create builds for all revisions or only for the lastest one.
coroutine add_envvars(**envvars)[source]

Adds environment variables to use in the builds of this repository.

Parameters:envvars – Environment variables in the format {var: val, …}
coroutine add_slave(slave)[source]

Adds a slave to the repository.

Parameters:slave – A Slave instance.
coroutine cancel_build(build_uuid)[source]

Cancels a build from the repository.

Parameters:build_uuid – The uuid of the build.
coroutine delete()[source]

Delete a repository.

coroutine disable()[source]

Disables this repository.

coroutine enable()[source]

Enables this repository.

coroutine classmethod get(requester, **kwargs)[source]

Returns a repository.

Parameters:
  • requester – The user who is requesting the operation.
  • kwargs – kwargs to get the repository.
coroutine classmethod list(requester, **kwargs)[source]

Lists all repositories.

Parameters:requester – The user who is requesting the operation.
coroutine list_branches()[source]

Lists the branches known by this repositor.

coroutine remove_branch(branch_name)[source]

Removes a branch config from a repository.

Parameters:branch_name – The name of the branch.
coroutine remove_slave(slave)[source]

Removes a slave from the repository.

Parameters:slave – A Slave instance.
coroutine replace_envvars(**envvars)[source]

Replaces environment variables of this repository.

Parameters:envvars – Environment variables in the format {var: val, …}
coroutine request_code_update(repo_branches=None, external=None, wait_for_lock=False)[source]

Request the code update of the repository.

Parameters:
  • repo_branches

    A dictionary with information about the branches to be updated. If no repo_branches all branches in the repo config will be updated.

    The dictionary has the following format.

    {'branch-name': {'notify_only_latest': True}}
    
  • external – If we should update code from an external (not the origin) repository, external is the information about this remote repo.
  • wait_for_lock – Indicates if we should wait for the release of the lock or simply return if we cannot get a lock.
coroutine rm_envvars(**envvars)[source]

Removes environment variables from this repository.

Parameters:envvars – Environment variables in the format {var: val, …}
coroutine start_build(branch, builder_name_or_id=None, named_tree=None)[source]

Starts a (some) build(s) for a repository.

Parameters:
  • branch – The name of the branch.
  • builder_name_or_id – The name of the builder that will execute the build
  • named_tree – The named_tree that will be builded. If no named_tree the last one will be used.
to_dict(*args, **kwargs)[source]

Transforms a repository into a dictionary.

Parameters:
  • args – Positional arguments passed to to_dict().
  • kwargs – Named arguments passed to to_dict().
coroutine update(**kwargs)[source]

Updates a slave

references = {'last_buildset': 'toxicbuild.common.interfaces.BuildSetInterface', 'slaves': <class 'toxicbuild.common.interfaces.SlaveInterface'>}
class toxicbuild.common.interfaces.SlaveInterface(requester, ordered_kwargs)[source]

Bases: toxicbuild.common.interfaces.BaseHoleInterface

coroutine classmethod add(requester, name, port, token, owner, use_ssl=True, validate_cert=True, on_demand=False, host=None, instance_type=None, instance_confs=None)[source]

Adds a new slave.

Parameters:
  • name – Slave name.
  • host – Slave host.
  • port – Slave port.
  • token – Authentication token.
  • owner – The slave owner
  • use_ssl – Indicates if the slave uses a ssl connection.
  • on_demand – Does this slave have an on-demand instance?
  • instance_type – Type of the on-demand instance.
  • instance_confs – Configuration parameters for the on-demand instance.
Pram validate_cert:
 

Should the slave certificate be validated?

coroutine delete()[source]

Delete a slave.

coroutine classmethod get(requester, **kwargs)[source]

Returns a slave.

Parameters:
  • requester – The user who is requesting the operation.
  • kwargs – kwargs to get the slave.
coroutine classmethod list(requester)[source]

Lists all slaves.

Parameters:requester – The user who is requesting the operation.
coroutine update(**kwargs)[source]

Updates a slave

class toxicbuild.common.interfaces.StepInterface(requester, ordered_kwargs)[source]

Bases: toxicbuild.common.interfaces.BaseHoleInterface

coroutine classmethod get(requester, uuid)[source]

Returns information about a step. :param uuid: The uuid of the step.

class toxicbuild.common.interfaces.UserInterface(requester, ordered_kwargs)[source]

Bases: toxicbuild.common.interfaces.BaseHoleInterface

A user created in the master

coroutine classmethod add(email, username, password, allowed_actions)[source]
coroutine classmethod authenticate(username_or_email, password)[source]
coroutine classmethod change_password(requester, old_password, new_password)[source]
coroutine classmethod change_password_with_token(token, password)[source]

Changes the user password using a token. The token was generated when request_password_reset was called and a link with the token was sent to the user email.

coroutine delete()[source]
coroutine classmethod exists(**kwargs)[source]

Checks if a user with some given information exists.

Parameters:kwargs – Named arguments to match the user
coroutine classmethod get(**kwargs)[source]

Returns a user.

Parameters:
  • requester – The user who is requesting the operation.
  • kwargs – kwargs to get the user.
coroutine classmethod request_password_reset(email, reset_link)[source]

Request the reset of the user’s password. Sends an email with a link to reset the password.

toxicbuild.common.utils module

toxicbuild.common.utils.format_datetime(dt, dtformat, tzname=None)[source]

Formats a datetime object according to the timezone and format specified in the config file.

Parameters:
  • dt – A datetime object.
  • dtformat – The format for the datetime.
  • tzname – A timezone name.
toxicbuild.common.utils.get_hole_client_settings(settings)[source]

Returns the settings that must be used by the hole client

toxicbuild.common.utils.is_datetime(dtstr)[source]

Checks if a string is a formated datetime. The format expected for the datetime string is: ‘%a %b %d %H:%M:%S %Y %z’

Module contents