toxicslave package

Submodules

toxicslave.build module

class toxicslave.build.BuildStep(name, command, warning_on_fail=False, timeout=3600, stop_on_fail=False)[source]

Bases: object

async exec_cmd(cmd, cwd, timeout, out_fn, **envvars)[source]
async execute(cwd, out_fn=None, last_step_status=None, last_step_output=None, **envvars)[source]

Executes the step command.

Parameters:
  • cwd – Directory where the command will be executed.

  • out_fn – Function used to handle each line of the command output.

  • last_step_status – The status of the step before this one in the build.

  • last_step_output – The output of the step before this one in the build.

  • envvars – Environment variables to be used on execution.

Note

In the case of this method, the params last_step_status and last_step_output are not used. They are here for the use of extentions that may need it. For example, run one command in case of one status or another command in case of another status.

async get_command()[source]

Returns the command that will be executed.

class toxicslave.build.Builder(manager, bconf, workdir, platorm='linux-generic', remove_env=True, **envvars)[source]

Bases: LoggerMixin

A builder executes build steps. Builders are configured in the toxicbuild.yml file

STEP_OUTPUT_BUFF_LEN = 0
async build()[source]
property build_uuid
property slave_plugin

toxicslave.cmds module

toxicslave.cmds.create(root_dir, no_token=False)[source]

Create a new toxicslave environment.

Parameters:
  • --root_dir – Root directory for toxicslave.

  • --no-token – Should we create a access token?

toxicslave.cmds.create_token(conffile, show_encrypted=False)[source]

Creates the access token to the slave.

Parameters:
  • conffile – The path for the toxicslave.conf

  • --show-encrypted – Show the encrypted token?

toxicslave.cmds.restart(workdir, pidfile='toxicslave.pid', loglevel='info')[source]

Restarts toxicslave

The instance of toxicslave in workdir will be restarted.

Parameters:
  • workdir – Workdir for master to be killed.

  • --pidfile – Name of the file to use as pidfile. Defaults to toxicslave.pid

  • --loglevel – Level for logging messages.

toxicslave.cmds.slave_init(addr, port, use_ssl, certfile, keyfile, loglevel)[source]
toxicslave.cmds.start(workdir, daemonize=False, stdout='toxicslave.log', stderr='toxicslave.log', conffile=None, loglevel='info', pidfile='toxicslave.pid')[source]

Starts toxicslave.

Starts the build server to listen on the specified port for requests from addr (0.0.0.0 means everyone). Addr and port params came from the config file

Parameters:
  • workdir – Work directory for server.

  • --daemonize – Run as daemon. Defaults to False

  • --stdout – stdout path. Defaults to /dev/null

  • --stderr – stderr path. Defaults to /dev/null

  • --conffile (-c,) – path to config file. Defaults to None. If not conffile, will look for a file called toxicslave.conf inside workdir

  • --loglevel – Level for logging messages. Defaults to info.

  • --pidfile – Name of the file to use as pidfile. Defaults to toxicslave.pid

toxicslave.cmds.stop(workdir, pidfile='toxicslave.pid', kill=False)[source]

Stops toxicslave.

The instance of toxicslave in workdir will be stopped.

Parameters:
  • workdir – Workdir for master to be killed.

  • --pidfile – Name of the file to use as pidfile. Defaults to toxicslave.pid

  • kill – If true, send signum 9, otherwise, 15.

toxicslave.docker module

class toxicslave.docker.BuildStepDocker(name, command, warning_on_fail=False, timeout=3600, stop_on_fail=False, container_name=None)[source]

Bases: BuildStep, LoggerMixin

A build step that run the commands inside a docker container.

async exec_cmd(cmd, cwd, timeout, out_fn, **envvars)[source]
classmethod from_buildstep(step, container_name)[source]
class toxicslave.docker.DockerContainerBuilder(*args, **kwargs)[source]

Bases: Builder

Class to handle docker containers used to run builds inside it.

async container_exists(only_running=False)[source]

Checks if a container named as its self.cname already exists

Parameters:

only_running – If True, will look only for running containers.

async copy2container()[source]

Recursive copy a directory to the container’s src dir.

async is_running()[source]
async kill_container()[source]
async rm_container()[source]
async rm_from_container()[source]

Removes the source code of a container that will not be removed.

async service_is_up()[source]

Check if the docker service is running in the host (slave) machine.

async start_container()[source]
async wait_service()[source]

The docker service may start a few seconds after the build server is running. Here we wait until the docker service is up.

async wait_start()[source]

Waits for a container to start

toxicslave.exceptions module

exception toxicslave.exceptions.BadBuilderConfig[source]

Bases: Exception

exception toxicslave.exceptions.BadData[source]

Bases: Exception

exception toxicslave.exceptions.BadPluginConfig[source]

Bases: Exception

exception toxicslave.exceptions.BuilderNotFound[source]

Bases: Exception

exception toxicslave.exceptions.BusyRepository[source]

Bases: Exception

exception toxicslave.exceptions.NotConnected[source]

Bases: Exception

toxicslave.managers module

class toxicslave.managers.BuildManager(protocol, repo_id, repo_url, vcs_type, branch, named_tree, config_type='yml', config_filename='toxicbuild.yml', builders_from=None)[source]

Bases: LoggerMixin

A manager for remote build requests

classmethod add_build_task(build_uuid, task)[source]
building_repos = {}
classmethod cancel_build(build_uuid)[source]
cloning_repos = {}
property config
property current_build
classmethod get_build_task(build_uuid)[source]
property is_cloning

Informs if this repository is being cloned.

property is_updating

Informs it this repository is fetching changes

property is_working

Informs if this repository is cloning or updating

list_builders()[source]

Returns a list with all builders names for this branch based on build config file

async load_builder(name, envvars=None)[source]

Loads a builder from toxicbuild.yml. If USE_DOCKER returns a DockerContainerBuilder instance. Otherwise returns a Builder instance.

Parameters:
  • name – builder name

  • envvars – A dictionary with environment variables used in a build.

async load_config()[source]
log(msg, level='info')[source]

Appends the class name before the log message.

classmethod rm_build_task(build_uuid)[source]
async send_info(info)[source]
async update_and_checkout(work_after_wait=True, external=None)[source]

Updates self.branch and checkout to self.named_tree.

Parameters:
  • work_after_wait – Indicates if we should update and checkout after waiting for other instance finishes its job.

  • external – Info about a remote repository if the build should be executed with changes from a remote repo.

updating_repos = {}
async wait_all()[source]

Wait until clone and update are done.

async wait_clone()[source]

Wait until the repository clone is complete.

async wait_update()[source]

Wait until the repository update is complete.

property workdir

The directory where the source code of this repository is cloned into

toxicslave.plugins module

class toxicslave.plugins.AptInstallPlugin(packages, timeout=600)[source]

Bases: SlavePlugin

Installs packages using apt.

get_env_vars()[source]

Returns a dictionary containing values for environment variables.

get_steps_before()[source]

Returns a list of steps to be executed before the steps provided by the user.

name = 'apt-install'
no_list = False
class toxicslave.plugins.AptInstallStep(packages, timeout=600)[source]

Bases: BuildStep

async get_command()[source]

Returns the command that will be executed.

class toxicslave.plugins.AptUpdateStep(timeout=600)[source]

Bases: BuildStep

class toxicslave.plugins.PythonCreateVenvStep(data_dir, venv_dir, pyversion)[source]

Bases: BuildStep

Step that checks if the venv already exists before executing the command.

async execute(cwd, **envvars)[source]

Executes the step command.

Parameters:
  • cwd – Directory where the command will be executed.

  • out_fn – Function used to handle each line of the command output.

  • last_step_status – The status of the step before this one in the build.

  • last_step_output – The output of the step before this one in the build.

  • envvars – Environment variables to be used on execution.

Note

In the case of this method, the params last_step_status and last_step_output are not used. They are here for the use of extentions that may need it. For example, run one command in case of one status or another command in case of another status.

class toxicslave.plugins.PythonVenvPlugin(pyversion, requirements_file='requirements.txt', remove_env=False, extra_indexes=None)[source]

Bases: SlavePlugin

get_env_vars()[source]

Returns a dictionary containing values for environment variables.

get_steps_after()[source]

Returns a list of steps to be executed after the steps provided by the user.

get_steps_before()[source]

Returns a list of steps to be executed before the steps provided by the user.

name = 'python-venv'
no_list = False
property venv_dir
class toxicslave.plugins.SlavePlugin(*args, **kwargs)[source]

Bases: Plugin

This is a base slave plugin. Slave plugins may add steps to a build before and/or after the used defined steps. It may also set enivronment variables to be used in the tests.

property data_dir

The directory where the plugin store its data.

get_env_vars()[source]

Returns a dictionary containing values for environment variables.

get_steps_after()[source]

Returns a list of steps to be executed after the steps provided by the user.

get_steps_before()[source]

Returns a list of steps to be executed before the steps provided by the user.

name = 'BaseSlavePlugin'
no_list = False

toxicslave.protocols module

toxicslave.server module

Module contents

toxicslave.create_settings()[source]