toxicbuild.ui package

Submodules

toxicbuild.ui.cli module

exception toxicbuild.ui.cli.ToxicShellError[source]

Bases: Exception

class toxicbuild.ui.cli.HistoryEdit(*args, **kwargs)[source]

Bases: toxicbuild.ui.cli.HistoryEditMixin, urwid.widget.Edit

class toxicbuild.ui.cli.HistoryEditMixin(*args, **kwargs)[source]

Bases: object

append_to_history(item)[source]
get_next()[source]
get_previous()[source]
keypress(size, key)[source]
save_history()[source]
class toxicbuild.ui.cli.ToxicCli(username_or_email, password, host='localhost', port=6666, token=None, use_ssl=True, validate_cert=True)[source]

Bases: toxicbuild.ui.cli.ToxicCliActions, urwid.decoration.Filler

execute_and_show(cmdline)[source]

Executes an action requested by the user and show its output.

get_action_help_screen(action, full=True)[source]

Returns a list already formated to be displayed by self.main_screen as the help for a command.

get_help_screen(command_name=None)[source]
keypress(size, key)[source]

Pass keypress to self.original_widget.

peek(format_fn=None)[source]

Peeks throught the master’s hole.

quit()[source]
run()[source]
coroutine show_waterfall(cmdline)[source]
show_welcome_screen()[source]

Displays the welcome screen for toxiccli.

stop_peek()[source]
class toxicbuild.ui.cli.ToxicCliActions(username_or_email, password, *args, host='localhost', port=6666, token=None, use_ssl=True, validate_cert=True, loop=None, **kwargs)[source]

Bases: object

coroutine authenticate()[source]
execute_action(cmdline)[source]

Execute some action based on the cmdline inputted by the user.

get_action_from_command_line(cmdline)[source]

Returns cmdname and cmdkwargs.

get_action_help(action_name)[source]
get_actions()[source]

Asks the server for which actions are available.

get_client()[source]

Returns a client connected to a toxicbuild master

class toxicbuild.ui.cli.Waterfall(client, repo_name, cli)[source]

Bases: object

A class to show the buildset waterfall.

peek_callback(response)[source]
post_item_formatter(item)[source]
post_row_formatter(row)[source]
coroutine show_waterfall()[source]
toxicbuild.ui.cli.get_kwargs(command_params, args)[source]

Return kwargs for args based on command_params. command_params are the known parameters for a command, those sent by list-funcs.

toxicbuild.ui.cli.parse_cmdline(cmdline)[source]

Parses a command line from toxicshell. Returns action, args, kwargs for the command line.

Parameters:cmdline – Input from the user as a string.
toxicbuild.ui.cli.validate_input(command_params, user_args, user_kwargs)[source]

Validates args and kwargs from the user input against the args and kwargs of a known command.

Parameters:
  • command_params – Known parameters for the command.
  • user_args – Argument list submitted by the user.
  • user_kwargs – Keyword arguments submitted by the user.

toxicbuild.ui.client module

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

Bases: toxicbuild.core.client.BaseToxicClient

Client for the master’s hole.

connect2stream()[source]

Connects the client to the master’s hole stream.

get_response()[source]

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

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.
toxicbuild.ui.client.get_hole_client(requester, host, port, hole_token=None, **kwargs)[source]

toxicbuild.ui.context_processors module

class toxicbuild.ui.context_processors.ToxicWebMainContextProcessor(request)[source]

Bases: pyrocumulus.web.template.ContextProcessor

get_context()[source]

Returns a dict to be used as a context, returns {‘static_url’: settings.STATIC_URL}. Sub-classes should re-implement this method and returns its own context.

toxicbuild.ui.inutils module

toxicbuild.ui.models module

class toxicbuild.ui.models.BaseModel(requester, ordered_kwargs)[source]

Bases: object

classmethod get_client(requester)[source]

Returns a client connected to master.

to_dict()[source]

Transforms a model into a dict.

to_json()[source]

Transforms a model into a json.

references = {}
class toxicbuild.ui.models.Build(requester, ordered_kwargs)[source]

Bases: toxicbuild.ui.models.BaseModel

references = {'builder': <class 'toxicbuild.ui.models.Builder'>, 'steps': <class 'toxicbuild.ui.models.Step'>}
class toxicbuild.ui.models.BuildSet(requester, ordered_kwargs)[source]

Bases: toxicbuild.ui.models.BaseModel

classmethod list(requester, repo_name=None)[source]

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

Parameters:repo_name – Name of a repository.
references = {'builds': <class 'toxicbuild.ui.models.Build'>}
class toxicbuild.ui.models.Builder(requester, ordered_kwargs)[source]

Bases: toxicbuild.ui.models.BaseModel

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

Lists builders already used.

class toxicbuild.ui.models.Plugin(requester, ordered_kwargs)[source]

Bases: toxicbuild.ui.models.BaseModel

A repository plugin.

classmethod get(requester, name)[source]

Return the schema for a specific plugin

Parameters:
  • requester – The user who is requesting the operation.
  • name – The name of the plugin
classmethod list(requester)[source]

Lists all plugins available in the master.

Parameters:requester – The user who is requesting the operation.
class toxicbuild.ui.models.Repository(requester, ordered_kwargs)[source]

Bases: toxicbuild.ui.models.BaseModel

Class representing a repository.

classmethod add(requester, name, url, owner, vcs_type, update_seconds=300, slaves=None, parallel_builds=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.
Params parallel_builds:
 

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

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

Delete a repository.

disable_plugin(**kwargs)[source]

Disables a plugin from a repository.

Parameters:kwargs – kwargs to match the plugin.
enable_plugin(plugin_name, **kwargs)[source]

Enables a plugin to a repository.

Parameters:
  • plugin_name – The plugin’s name.
  • kwargs – kwargs used to configure the plugin.
classmethod get(requester, **kwargs)[source]

Returns a repository.

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

Lists all repositories.

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

Removes a branch config from a repository.

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

Removes a slave from the repository.

Parameters:slave – A Slave instance.
start_build(branch, builder_name=None, named_tree=None, slaves=None)[source]

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

Parameters:
  • branch – The name of the branch.
  • builder_name – 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.
  • slaves – A list with names of slaves that will execute the builds. If no slave is supplied all will be used.
to_dict()[source]

Transforms a repository into a dictionary.

update(**kwargs)[source]

Updates a slave

references = {'plugins': <class 'toxicbuild.ui.models.Plugin'>, 'slaves': <class 'toxicbuild.ui.models.Slave'>}
class toxicbuild.ui.models.Slave(requester, ordered_kwargs)[source]

Bases: toxicbuild.ui.models.BaseModel

classmethod add(requester, name, host, port, token, owner, use_ssl=True, validate_cert=True)[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.
Pram validate_cert:
 

Should the slave certificate be validated?

delete()[source]

Delete a slave.

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

Returns a slave.

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

Lists all slaves.

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

Updates a slave

class toxicbuild.ui.models.Step(requester, ordered_kwargs)[source]

Bases: toxicbuild.ui.models.BaseModel

class toxicbuild.ui.models.User(requester, ordered_kwargs)[source]

Bases: toxicbuild.ui.models.BaseModel

coroutine classmethod add(requester, email, username, password, allowed_actions)[source]
coroutine classmethod authenticate(username_or_email, password)[source]
coroutine delete()[source]

toxicbuild.ui.web module

class toxicbuild.ui.web.BaseModelHandler(*args, **kwargs)[source]

Bases: toxicbuild.ui.web.LoggedTemplateHandler

add(**kwargs)[source]
delete(*args)[source]
get(*args)[source]
get_item(**kwargs)[source]
initialize(*args, **kwargs)[source]

Hook for subclass initialization. Called for each request.

A dictionary passed as the third argument of a url spec will be supplied as keyword arguments to initialize().

Example:

class ProfileHandler(RequestHandler):
    def initialize(self, database):
        self.database = database

    def get(self, username):
        ...

app = Application([
    (r'/user/(.*)', ProfileHandler, dict(database=database)),
    ])
post(*args)[source]
item_template = 'item.html'
list_template = 'list.html'
class toxicbuild.ui.web.LoggedTemplateHandler(*args, **kwargs)[source]

Bases: pyrocumulus.web.handlers.TemplateHandler

prepare()[source]

Called at the beginning of a request before get/post/etc.

Override this method to perform common initialization regardless of the request method.

Asynchronous support: Decorate this method with .gen.coroutine or .return_future to make it asynchronous (the asynchronous decorator cannot be used on prepare). If this method returns a .Future execution will not proceed until the .Future is done.

New in version 3.1: Asynchronous support.

class toxicbuild.ui.web.LoginHandler(*args, **kwargs)[source]

Bases: pyrocumulus.web.handlers.TemplateHandler

get(action)[source]
post(action)[source]
class toxicbuild.ui.web.MainHandler(*args, **kwargs)[source]

Bases: toxicbuild.ui.web.LoggedTemplateHandler

get()[source]
main_template = 'main.html'
class toxicbuild.ui.web.RepositoryHandler(*args, **kwargs)[source]

Bases: toxicbuild.ui.web.BaseModelHandler

add_branch()[source]
cancel_build()[source]
delete(*args)[source]
disable_plugin()[source]
enable_plugin()[source]
list_plugins()[source]
post(*args)[source]
prepare()[source]

Called at the beginning of a request before get/post/etc.

Override this method to perform common initialization regardless of the request method.

Asynchronous support: Decorate this method with .gen.coroutine or .return_future to make it asynchronous (the asynchronous decorator cannot be used on prepare). If this method returns a .Future execution will not proceed until the .Future is done.

New in version 3.1: Asynchronous support.

put(*args)[source]
remove_branch()[source]
start_build()[source]
class toxicbuild.ui.web.SlaveHandler(*args, **kwargs)[source]

Bases: toxicbuild.ui.web.BaseModelHandler

delete(*args)[source]
prepare()[source]

Called at the beginning of a request before get/post/etc.

Override this method to perform common initialization regardless of the request method.

Asynchronous support: Decorate this method with .gen.coroutine or .return_future to make it asynchronous (the asynchronous decorator cannot be used on prepare). If this method returns a .Future execution will not proceed until the .Future is done.

New in version 3.1: Asynchronous support.

put(*args)[source]
class toxicbuild.ui.web.StreamHandler(*args, **kwargs)[source]

Bases: toxicbuild.core.utils.LoggerMixin, toxicbuild.ui.web.LoggedTemplateHandler, tornado.websocket.WebSocketHandler

initialize()[source]

Hook for subclass initialization. Called for each request.

A dictionary passed as the third argument of a url spec will be supplied as keyword arguments to initialize().

Example:

class ProfileHandler(RequestHandler):
    def initialize(self, database):
        self.database = database

    def get(self, username):
        ...

app = Application([
    (r'/user/(.*)', ProfileHandler, dict(database=database)),
    ])
on_close()[source]

Invoked when the WebSocket is closed.

If the connection was closed cleanly and a status code or reason phrase was supplied, these values will be available as the attributes self.close_code and self.close_reason.

Changed in version 4.0: Added close_code and close_reason attributes.

open(action)[source]

Invoked when a new WebSocket is opened.

The arguments to open are extracted from the tornado.web.URLSpec regular expression, just like the arguments to tornado.web.RequestHandler.get.

receiver(sender, **message)[source]
write2sock(body)[source]
class toxicbuild.ui.web.WaterfallHandler(*args, **kwargs)[source]

Bases: toxicbuild.ui.web.LoggedTemplateHandler

get(repo_name)[source]
prepare()[source]

Called at the beginning of a request before get/post/etc.

Override this method to perform common initialization regardless of the request method.

Asynchronous support: Decorate this method with .gen.coroutine or .return_future to make it asynchronous (the asynchronous decorator cannot be used on prepare). If this method returns a .Future execution will not proceed until the .Future is done.

New in version 3.1: Asynchronous support.

template = 'waterfall.html'

Module contents

toxicbuild.ui.create(root_dir, access_token)[source]

Create a new toxicweb project.

Parameters:
  • --root_dir – Root directory for toxicweb.
  • --access-token – Access token to master’s hole.
toxicbuild.ui.create_settings()[source]
toxicbuild.ui.restart(workdir, pidfile=None)[source]

Restarts the web interface

The instance of toxicweb in workdir will be restarted. :param workdir: Workdir for master to be killed. :param –pidfile: Name of the file to use as pidfile.

toxicbuild.ui.start(workdir, daemonize=False, stdout='./toxicui.log', stderr='./toxicui.log', pidfile=None, loglevel='info', conffile=None)[source]

Starts the web interface.

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 configfile

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
  • --pidfile – pid file for the process.
  • --loglevel – Level for logging messages. Defaults to info.
  • --conffile (-c,) – path to config file. It must be relative to the workdir. Defaults to None. If not conffile, will look for a file called toxicui.conf inside workdir
toxicbuild.ui.stop(workdir, pidfile=None)[source]

Stops the web interface.

Parameters:
  • workdir – Work directory for the ui to be killed.
  • --pidfile – pid file for the process.