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.connectors module

class toxicbuild.ui.connectors.StreamConnector(user, repo_id, events)[source]

Bases: toxicbuild.core.utils.LoggerMixin

Class responsible for connecting the ui with the master’s stream. It is done so we don’t have one connection open for each client.

We have a client for each repository and the clients register callables to receive the messages sent throught the stream. To use it, simply plug a callback to the connector:

from toxicbuild.ui.models import Repository
repo = yield from Repository.get(id='some-id')

def callback(sender, **message):
    print(message)

StreamConnector.plug(repo, callback)

When you are done, unplug it.

StreamConnector.unplug(repo, callback)
classmethod plug(user, repo_id, events, callback)[source]

Connects callback to events sent by a repository.

Parameters:
  • user – The requester user.
  • repo_id – The Id of a repository. Messages sent by this repository will trigger callback. If repo_id is None, messages from all repositories will be sent to callback.
  • events – The events that will return messages.
  • callback – A callable that will handle messages from a repository.
classmethod unplug(user, repo_id, events, callback)[source]

Disconnects callback from events sent by a repository.

Parameters:
  • user – The requester user.
  • repo_id – The id of a repository.
  • events – A list of events that will return messages.
  • callback – A callable that will handle messages from a repository.
NONE_REPO_ID = 'NONE-REPO-ID'

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.

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

Bases: pyrocumulus.web.template.ContextProcessor

Includes a translate function in the context to internatinalize the string shown to the users.

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.utils module

toxicbuild.ui.utils.get_builders_for_buildsets(user, buildsets)[source]

Returns a list of builders used in given buildsets

Parameters:
  • user – The user to authenticate in the master
  • buildsets – A list of buildsets returned by the master.
toxicbuild.ui.utils.get_client_settings()[source]

Returns the settings that must be used by the client

toxicbuild.ui.utils.get_default_timezone_morsel()[source]

Returns a Morsel instance with UTC as its value.

toxicbuild.ui.utils.get_defaulte_locale_morsel()[source]

Returns a Morsel instance with en_US as its value.

toxicbuild.ui.utils.get_dtformat()[source]

toxicbuild.ui.web module

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

Bases: toxicbuild.ui.web.TemplateHandler

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

coroutine async_prepare()[source]
class toxicbuild.ui.web.BuildHandler(*args, **kwargs)[source]

Bases: toxicbuild.ui.web.ReadOnlyRestHandler

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

coroutine get_build()[source]
class toxicbuild.ui.web.BuildSetHandler(*args, **kwargs)[source]

Bases: toxicbuild.ui.web.ReadOnlyRestHandler

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

coroutine list_or_get()[source]
class toxicbuild.ui.web.CookieAuthBuildHandler(*args, **kwargs)[source]

Bases: toxicbuild.ui.web.CookieAuthHandlerMixin, toxicbuild.ui.web.BuildHandler

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

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

Bases: toxicbuild.ui.web.CookieAuthHandlerMixin, toxicbuild.ui.web.BuildSetHandler

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

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

Bases: toxicbuild.core.utils.LoggerMixin

A mixin that checks if the requester is logged by looking for a cookie.

coroutine async_prepare()[source]
class toxicbuild.ui.web.CookieAuthNotificationRestHandler(*args, **kwargs)[source]

Bases: toxicbuild.ui.web.CookieAuthHandlerMixin, toxicbuild.ui.web.NotificationRestHandler

Rest api handler for notifications which requires cookie auth.

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

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

Bases: toxicbuild.ui.web.CookieAuthHandlerMixin, toxicbuild.ui.web.RepositoryRestHandler

A rest api handler for repositories which requires cookie auth.

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

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

Bases: toxicbuild.ui.web.CookieAuthHandlerMixin, toxicbuild.ui.web.SlaveRestHandler

A rest api handler for slaves which requires cookie auth.

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

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

Bases: toxicbuild.ui.web.CookieAuthHandlerMixin, toxicbuild.ui.web.StepHandler

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

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

Bases: toxicbuild.ui.web.CookieAuthHandlerMixin, toxicbuild.ui.web.WaterfallRestHandler

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

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

Bases: toxicbuild.ui.web.LoggedTemplateHandler

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

show_build_details(build_uuid)[source]
show_build_template(build_uuid)[source]
coroutine show_buildset_details(buildset_id)[source]
coroutine show_buildset_template(buildset_id)[source]
show_main()[source]
show_main_template()[source]
show_repo_add()[source]
show_repo_buildset_list(full_name)[source]
show_repo_buildset_list_template(full_name)[source]
show_repo_waterfall(full_name)[source]
show_repo_waterfall_template(full_name)[source]
show_repository_details(full_name)[source]
show_repository_details_template(full_name=b'')[source]
coroutine show_repository_notifications(full_name)[source]
coroutine show_repository_notifications_template(full_name)[source]
show_settings(settings_type)[source]
show_settings_main_template(settings_type)[source]
show_settings_template(settings_type)[source]
show_slave_details(full_name=b'')[source]
show_slave_details_template()[source]
show_step_details(step_uuid)[source]
show_step_template(step_uuid)[source]
build_template = 'toxictheme/build.html'
buildset_list_template = 'toxictheme/buildset_list.html'
buildset_template = 'toxictheme/buildset.html'
main_template = 'toxictheme/main.html'
notifications_template = 'toxictheme/notifications.html'
repo_settings_template = 'toxictheme/repo_settings.html'
repository_template = 'toxictheme/repository.html'
settings_template = 'toxictheme/settings.html'
slave_settings_template = 'toxictheme/slave_settings.html'
slave_template = 'toxictheme/slave.html'
step_template = 'toxictheme/step.html'
ui_settings_template = 'toxictheme/ui_settings.html'
user_settings_template = 'toxictheme/user_settings.html'
waterfall_template = 'toxictheme/waterfall.html'
class toxicbuild.ui.web.LoggedTemplateHandler(*args, **kwargs)[source]

Bases: toxicbuild.ui.web.CookieAuthHandlerMixin, toxicbuild.ui.web.TemplateHandler

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

coroutine async_prepare()[source]
skeleton_template = 'toxictheme/skeleton.html'
class toxicbuild.ui.web.LoginHandler(*args, **kwargs)[source]

Bases: toxicbuild.ui.web.BaseNotLoggedTemplate

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

coroutine do_login()[source]

Authenticates using username and password and creates a cookie

do_logout()[source]
show_login_page()[source]
show_reset_password_page()[source]
login_template = 'toxictheme/login.html'
reset_password_template = 'toxictheme/reset_password.html'
class toxicbuild.ui.web.ModelRestHandler(*args, **kwargs)[source]

Bases: toxicbuild.core.utils.LoggerMixin, pyrocumulus.web.handlers.BasePyroHandler

A base handler for handlers that are responsible for manipulating models from models

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

coroutine add()[source]
coroutine async_prepare()[source]
coroutine delete_item()[source]
coroutine get_or_list()[source]
coroutine update()[source]
class toxicbuild.ui.web.NotificationRestHandler(*args, **kwargs)[source]

Bases: toxicbuild.ui.web.ReadOnlyRestHandler

Handler for enable/disable/update notifications for repositories.

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

coroutine disable(notif_name, repo_id)[source]
coroutine enable(notif_name, repo_id)[source]
coroutine list()[source]
coroutine update(notif_name, repo_id)[source]
class toxicbuild.ui.web.ReadOnlyRestHandler(*args, **kwargs)[source]

Bases: toxicbuild.ui.web.ModelRestHandler

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

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

Bases: toxicbuild.ui.web.BaseNotLoggedTemplate

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

show_register_page()[source]
register_template = 'toxictheme/register.html'
class toxicbuild.ui.web.RepositoryRestHandler(*args, **kwargs)[source]

Bases: toxicbuild.ui.web.ModelRestHandler

A rest api handler for repositories.

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

coroutine add_branch()[source]

Adds a new branch configuration to the repository.

coroutine add_envvars()[source]
coroutine add_slave()[source]
coroutine cancel_build()[source]

Cancels a build from a repository.

coroutine disable()[source]
coroutine enable()[source]
coroutine remove_branch()[source]

Removes a branch configuration from the repository.

coroutine remove_slave()[source]
coroutine replace_envvars()[source]
coroutine rm_envvars()[source]
coroutine start_build()[source]

Starts builds for the repository.

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

Bases: toxicbuild.ui.web.ModelRestHandler

A rest api handler for slaves.

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

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

Bases: toxicbuild.ui.web.ReadOnlyRestHandler

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

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

Bases: toxicbuild.ui.web.CookieAuthHandlerMixin, 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.

coroutine 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.

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.

receiver(sender, **message)[source]
write2sock(body)[source]
class toxicbuild.ui.web.TemplateHandler(application, request, **kwargs)[source]

Bases: pyrocumulus.web.handlers.BasePyroHandler

Handler with little improved template support

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

render_template(template, extra_context=None)[source]

Renders a template using pyrocumulus.web.template.render_template().

class toxicbuild.ui.web.ToxicRequest(request)[source]

Bases: pyrocumulus.web.handlers.PyroRequest

get(key, default=None)[source]

Returns a single value for a key. If it’s not present returns None.

items()[source]

Returns the request items

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

Bases: toxicbuild.ui.web.ModelRestHandler

A rest api handler to add new users.

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

coroutine add()[source]
coroutine change_password_with_token()[source]
coroutine check_exists()[source]
coroutine request_password_reset()[source]
class toxicbuild.ui.web.UserRestHandler(*args, **kwargs)[source]

Bases: toxicbuild.ui.web.CookieAuthHandlerMixin, toxicbuild.ui.web.ModelRestHandler

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

coroutine change_password()[source]
class toxicbuild.ui.web.WaterfallRestHandler(*args, **kwargs)[source]

Bases: toxicbuild.ui.web.ReadOnlyRestHandler

operation_mapper

alias of pyrocumulus.web.operationmappers.HandlerOperationMapper

coroutine get_waterfall()[source]

Module contents

toxicbuild.ui.create(root_dir, access_token='', output_token='', root_user_id='', cookie_secret='')[source]

Create a new toxicweb project.

Parameters:
  • root_dir – Root directory for toxicweb.
  • --access-token – Access token to master’s hole.
  • --output-token – Access token to the notifications api.
  • --root-user-id – The id for the root user of the system.
  • --cookie-secret – Secret for secure cookies.
toxicbuild.ui.create_settings()[source]
toxicbuild.ui.restart(workdir, pidfile=None, loglevel='info')[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. :param –loglevel: Level for logging messages.

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.