toxicbuild.slave package

Submodules

toxicbuild.slave.build module

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

Bases: object

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.

coroutine get_command()[source]

Returns the command that will be executed.

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

Bases: toxicbuild.core.utils.LoggerMixin

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

coroutine build()[source]
STEP_OUTPUT_BUFF_LEN = 258

toxicbuild.slave.exceptions module

exception toxicbuild.slave.exceptions.BadBuilderConfig[source]

Bases: Exception

exception toxicbuild.slave.exceptions.BadData[source]

Bases: Exception

exception toxicbuild.slave.exceptions.BadPluginConfig[source]

Bases: Exception

exception toxicbuild.slave.exceptions.BuilderNotFound[source]

Bases: Exception

exception toxicbuild.slave.exceptions.BusyRepository[source]

Bases: Exception

exception toxicbuild.slave.exceptions.NotConnected[source]

Bases: Exception

toxicbuild.slave.managers module

class toxicbuild.slave.managers.BuildManager(protocol, repo_url, vcs_type, branch, named_tree, config_type='py', config_filename='toxicbuild.conf')[source]

Bases: toxicbuild.core.utils.LoggerMixin

A manager for remote build requests

list_builders()[source]

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

coroutine load_builder(name)[source]

Load a builder from toxicbuild.conf. If a container is to be used in for the build, returns a container builder instance. Otherwise, return a Builder instance.

Parameters:name – builder name
coroutine load_config()[source]
log(msg, level='info')[source]

Appends the class name before the log message.

send_info(info)[source]
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.
wait_all()[source]

Wait until clone and update are done.

wait_clone()[source]

Wait until the repository clone is complete.

wait_update()[source]

Wait until the repository update is complete.

building_repos = {}
cloning_repos = set()
config
current_build
is_cloning

Informs if this repository is being cloned.

is_updating

Informs it this repository is fetching changes

is_working

Informs if this repository is cloning or updating

updating_repos = set()
workdir

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

toxicbuild.slave.plugins module

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

Bases: toxicbuild.slave.plugins.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 toxicbuild.slave.plugins.AptInstallStep(packages, timeout=600)[source]

Bases: toxicbuild.slave.build.BuildStep

coroutine get_command()[source]

Returns the command that will be executed.

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

Bases: toxicbuild.slave.build.BuildStep

class toxicbuild.slave.plugins.PythonCreateVenvStep(venv_dir, pyversion)[source]

Bases: toxicbuild.slave.build.BuildStep

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

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 toxicbuild.slave.plugins.PythonVenvPlugin(pyversion, requirements_file='requirements.txt', remove_env=False)[source]

Bases: toxicbuild.slave.plugins.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
uses_data_dir = True
class toxicbuild.slave.plugins.SlavePlugin(*args, **kwargs)[source]

Bases: toxicbuild.core.plugins.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.

coroutine create_data_dir()[source]
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.

data_dir

The directory where the plugin store its data.

name = 'BaseSlavePlugin'
no_list = False

toxicbuild.slave.protocols module

class toxicbuild.slave.protocols.BuildServerProtocol(loop, connection_lost_cb=None)[source]

Bases: toxicbuild.core.protocol.BaseToxicProtocol

A simple server for build requests.

coroutine build()[source]

Performs a build requested by the client using the params sent in the request data

coroutine client_connected()[source]

Coroutine that handles connections. You must implement this in your sub-classes. When this method is called, self.data, containing a dictionary with the data passed in the request and self.action, a string indicating which action to take are already available.

coroutine get_buildmanager()[source]

Returns the builder manager for this request

coroutine healthcheck()[source]

Informs that the server is up and running

coroutine list_builders()[source]

Informs all builders’ names for this repo/branch/named_tree

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

Appends the class name before the log message.

encrypted_token = '$2b$04$uPkH68HUDSFl5SFiAonXq.MOhW/0QGyCnRedEXi5IcqyrTvvvexUK'

toxicbuild.slave.server module

This module implements a build server. Receives requests from the toxicbuild master and handles it using BuildServerProtocol.

Usage

with BuildServer(addr, port, use_ssl, **ssl_kw) as server:
    server.start()
class toxicbuild.slave.server.BuildServer(addr='0.0.0.0', port=7777, loop=None, use_ssl=False, **ssl_kw)[source]

Bases: toxicbuild.core.utils.LoggerMixin

A server that receives build requests from a toxicmaster instance.

get_protocol_instance()[source]

Returns an instance of BuildServerProtocol.

coroutine shutdown()[source]

Shuts down the build server. Waits for the current running builds to complete.

start()[source]

Starts the build server.

sync_shutdown(signum=None, frame=None)[source]

Synchronous version of shutdown().

toxicbuild.slave.server.run_server(addr='0.0.0.0', port=7777, loop=None, use_ssl=False, **ssl_kw)[source]

Module contents

toxicbuild.slave.create(root_dir)[source]

Create a new toxicslave environment.

Parameters:--root_dir – Root directory for toxicslave.
toxicbuild.slave.create_settings()[source]
toxicbuild.slave.restart(workdir, pidfile='toxicslave.pid')[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
toxicbuild.slave.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
toxicbuild.slave.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.