toxicbuild.core package¶
Submodules¶
toxicbuild.core.client module¶
-
class
toxicbuild.core.client.
BaseToxicClient
(host, port)[source]¶ Bases:
toxicbuild.core.utils.LoggerMixin
Base client for access toxicbuild servers.
toxicbuild.core.cmd module¶
toxicbuild.core.conf module¶
toxicbuild.core.exceptions module¶
toxicbuild.core.plugins module¶
-
class
toxicbuild.core.plugins.
Plugin
(*args, **kwargs)[source]¶ Bases:
object
This is a base plugin. Plugins may implement aditional behavior to your builds.
-
classmethod
get_plugin
(name)[source]¶ Returns a Plugin subclass based on its name.
Parameters: name – Plugin’s name.
-
classmethod
list_plugins
(plugin_type=None)[source]¶ Returns a list of Plugin subclasses.
Parameters: plugin_type – the plugin’s type.
-
name
= 'BaseCorePlugin'¶
-
no_list
= False¶
-
classmethod
toxicbuild.core.protocol module¶
-
class
toxicbuild.core.protocol.
BaseToxicProtocol
(loop, connection_lost_cb=None)[source]¶ Bases:
asyncio.streams.StreamReaderProtocol
,toxicbuild.core.utils.LoggerMixin
Base protocol for toxicbulid servers
-
check_data
()[source]¶ Checks if the data is valid, it means, checks if has some data, checks if it is a valid json and checks if it has a
action
key
-
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 andself.action
, a string indicating which action to take are already available.
-
connection_made
(transport)[source]¶ Called once, when the client connects.
Parameters: transport – transport for asyncio.StreamReader and asyncio.StreamWriter.
-
encrypted_token
= None¶
-
salt
= None¶
-
toxicbuild.core.requests module¶
This module implements a simple asynchronous interface for http requests.
Usage:¶
from toxicbuild.core import requests
response = yield from requests.get('http://google.com/')
print(response.text)
-
class
toxicbuild.core.requests.
Response
(status, text)[source]¶ Bases:
object
Encapsulates a response from a http request
-
toxicbuild.core.requests.
delete
(url, **kwargs)[source]¶ Performs a http DELETE request
Parameters: - url – Request’s url.
- kwargs – Args passed to
toxicbuild.core.requests._request()
.
-
toxicbuild.core.requests.
get
(url, **kwargs)[source]¶ Performs a http GET request
Parameters: - url – Request’s url.
- kwargs – Args passed to
toxicbuild.core.requests._request()
.
toxicbuild.core.utils module¶
-
class
toxicbuild.core.utils.
LoggerMixin
[source]¶ Bases:
object
A simple mixin to use log on a class.
-
class
toxicbuild.core.utils.
MatchKeysDict
[source]¶ Bases:
dict
A dictionary that returns the values matching the keys using
toxicbuild.core.utils.match_string()
.>>> d = MatchKeysDict() >>> d['k*'] = 1 >>> d['key'] 1 >>> k['keyboard'] 1
-
toxicbuild.core.utils.
daemonize
(call, cargs, ckwargs, stdout, stderr, workdir, pidfile)[source]¶ Run a callable as a daemon
Parameters: - call – a callable.
- cargs – args to
call
. - ckwargs – kwargs to
call
. - stdout – daemon’s stdout.
- stderr – daemon’s stderr.
- workdir – daemon’s workdir
- pidfile – pidfile’s path
-
toxicbuild.core.utils.
datetime2string
(dt, dtformat='%a %b %d %H:%M:%S %Y %z')[source]¶ Transforms a datetime object into a formated string.
Parameters: - dt – The datetime object.
- dtformat – The format to use.
-
toxicbuild.core.utils.
exec_cmd
(cmd, cwd, timeout=3600, out_fn=None, **envvars)[source]¶ Executes a shell command. Raises with the command output if return code > 0. :param cmd: command to run. :param cwd: Directory to execute the command. :param timeout: How long we should wait some output. Default is 3600. :param out_fn: A coroutine that receives each line of the step output. The coroutine signature must be in the form: mycoro(line_index, line). :param envvars: Environment variables to be used in the command.
-
toxicbuild.core.utils.
format_timedelta
(td)[source]¶ Format a timedelta object to a human-friendly string.
Parameters: dt – A timedelta object.
-
toxicbuild.core.utils.
get_toxicbuildconf
(directory)[source]¶ Returns the toxicbuild.conf module.
Parameters: directory – Directory to look for toxicbuild.conf
-
toxicbuild.core.utils.
inherit_docs
(cls)[source]¶ Inherit docstrings from base classes’ methods. Can be used as a decorator
Parameters: cls – Class that will inherit docstrings from its parents.
-
toxicbuild.core.utils.
load_module_from_file
(filename)[source]¶ Load a module from a source file :param filename: full path for file to be loaded.
-
toxicbuild.core.utils.
localtime2utc
(localdatetime)[source]¶ Transforms a local datetime object into a datetime object in utc time.
Parameters: localdatetime – A datetime object.
-
toxicbuild.core.utils.
match_string
(smatch, filters)[source]¶ Checks if a string match agains a list of filters containing wildcards.
Parameters: - smatch – String to test against the filters
- filters – Filter to match a string.
-
toxicbuild.core.utils.
read_stream
(reader)[source]¶ Reads the input stream. First reads the bytes until the first “n”. These first bytes are the length of the full message.
Parameters: reader – An instance of asyncio.StreamReader
-
toxicbuild.core.utils.
string2datetime
(dtstr, dtformat='%a %b %d %H:%M:%S %Y %z')[source]¶ Transforns a string into a datetime object acording to
dtformat
.Parameters: - dtstr – The string containing the formated date.
- dtformat – The format of the formated date.
toxicbuild.core.vcs module¶
-
class
toxicbuild.core.vcs.
Git
(workdir)[source]¶ Bases:
toxicbuild.core.vcs.VCS
An interface to git version control system
-
date_format
= '%a %b %d %H:%M:%S %Y'¶
-
get_revisions
(since={}, branches=None)[source]¶ Returns the revisions for
branches
sincesince
.Parameters: - since – dictionary in the format: {branch_name: since_date}.
since
is a datetime object. - branches – A list of branches to look for new revisions. If
branches
is None all remote branches will be used. You can use wildcards in branches to filter the remote branches.
- since – dictionary in the format: {branch_name: since_date}.
-
get_revisions_for_branch
(branch, since=None)[source]¶ Returns the revisions for
branch
sincesince
. Ifsince
is None, all revisions will be returned.Parameters: - branch – branch name
- since – datetime
-
pull
(branch_name)[source]¶ Pull changes from
branch_name
on remote repo.Parameters: branch_name – A branch name, like ‘master’.
-
vcsbin
= 'git'¶
-
-
class
toxicbuild.core.vcs.
VCS
(workdir)[source]¶ Bases:
toxicbuild.core.utils.LoggerMixin
Generic inteface to a vcs (clone, fetch, get revisions etc...).
-
exec_cmd
(cmd, cwd=None)[source]¶ Executes a shell command. If
cwd
is Noneself.workdir
will be used.Parameters: cwd – Directory where the command will be executed.
-
get_revisions
(since={}, branches=None)[source]¶ Returns the revisions for
branches
sincesince
.Parameters: - since – dictionary in the format: {branch_name: since_date}.
since
is a datetime object. - branches – A list of branches to look for new revisions. If
branches
is None all remote branches will be used. You can use wildcards in branches to filter the remote branches.
- since – dictionary in the format: {branch_name: since_date}.
-
get_revisions_for_branch
(branch, since=None)[source]¶ Returns the revisions for
branch
sincesince
. Ifsince
is None, all revisions will be returned.Parameters: - branch – branch name
- since – datetime
-
pull
(branch_name)[source]¶ Pull changes from
branch_name
on remote repo.Parameters: branch_name – A branch name, like ‘master’.
-
vcsbin
= None¶
-
-
toxicbuild.core.vcs.
get_vcs
(vcs_type)[source]¶ Retuns a subclass of
toxicbuild.core.vcs.VCS
forvcs_type