API Docs

sloth_ci.bed

class sloth_ci.bed.Bed(config)[source]

A container for Sloth apps.

It tracks their config files and listen points, as well as handles app adding, removing, and updating.

If also implements the listen function for the main CherryPy app.

(This module is names “bed” because a group of sloths is actually called “bed.”)

bind_to_file(listen_point, config_file)[source]

Bind a Sloth app with a config file.

Parameters:
  • listen_point – app’s listen point
  • config_file – absolute path to the config file
create_from_config(config)[source]

Create a Sloth app from a config source and add it to the bed.

Parameters:config – a dict parsed from YAML
Returns:new app’s listen point
classmethod extend(extensions)[source]

Sequentially chain-inherit Bed classes from extensions.

The first extension’s Bed class inherits from the base Bed class and becomes the base class, then the second one inherits from it, and so on.

Parameters:extensions – list of extensions to load.
Returns:ExtendedBed is a Bed class inherited from all extensions’ Bed classes; errors is the list of errors raised during extension loading.
remove(listen_point)[source]

Stop Sloth app and remove it from the bed.

Parameters:listen_point – Sloth app listen point
remove_all()[source]

Stop all active Sloth apps and remove them from the bed.

start()[source]

Start CherryPy loop to listen for payload.

sloth_ci.cli

class sloth_ci.cli.CLI[source]

Welcome to Sloth CI CLI!

Run “sci start” to start the server.

classmethod extend(extensions)[source]

Sequentially chain-inherit CLI classes from extensions.

The first extension’s CLI class inherits from the base CLI class and becomes the base class, then the second one inherits from it, and so on.

Parameters:extensions – list of extensions to load.
Returns:ExtendedCLI is a CLI class inherited from all extensions’ CLI classes; errors is the list of errors raised during extension loading.
start()[source]

start server

sloth_ci.sloth

class sloth_ci.sloth.Sloth(config)[source]

Base Sloth class.

Each instance represents a separate Sloth app, with its own config, log, action queue, and queue processor.

Each app listens for incoming requests on its own URL path.

execute(action)[source]

Executes an action in an ordinary Popen.

Parameters:action – action to be executed
Returns:True if successful, exception otherwise
classmethod extend(extensions)[source]

Sequentially chain-inherit Sloth classes from extensions.

The first extension’s Sloth class inherits from the base Sloth class and becomes the base class, then the second one inherits from it, and so on.

Parameters:extensions – dict of extensions to load.
Returns:ExtendedSloth is a Sloth class inherited from all extensions’ Sloth classes; errors is the list of errors raised during extension loading.
handle(request)[source]

Validate, extract, and process incoming payload.

Parameters:request – a cherrypy.request instance
kill()[source]

Immediately stop processing the queue.

process(validator_params)[source]

Queue execution of actions with certain params.

Params are taken from the params config section and extracted from the incoming payload.

Parameters:validator_params – params extracted from the payload
process_queue()[source]

Processes execution queue in a separate thread.

Returns:True if successful, exception otherwise
run_build(actions, params)[source]

Run a build with the given params.

Parameters:
  • actions – actions in this build
  • params – params used by the actions
Returns:

True if successful, exception otherwise

stop()[source]

Gracefully stop the queue processor.

New payloads are not added to the queue, existing actions will be finished.

sloth_ci.ext

sloth_ci.ext.api

sloth_ci.ext.api.bed

sloth_ci.ext.api.bed.extend_bed(cls, extension)[source]

Add routes and handlers for the API methods.

Parameters:
  • cls – base Bed class to be extended
  • extension{'api': {'module': 'api'}}
Returns:

extended Bed class

sloth_ci.ext.api.cli

sloth_ci.ext.api.cli.extend_cli(cls, extension)[source]

Add command-line commands for the API interaction.

Parameters:
  • cls – base CLI class to be extended
  • extension{'api': {'module': 'api'}}
Returns:

extended CLI class

sloth_ci.ext.db

sloth_ci.ext.db.builds

sloth_ci.ext.db.builds.extend_sloth(cls, extension)[source]

Add SQLite logging for build events.

Parameters:
  • cls – base Sloth class to extend
  • extension{'build_history': {'module': 'db.builds', 'db': self.db_path, 'table': 'build_history'}}
Returns:

extended Sloth class

sloth_ci.ext.db.logs

sloth_ci.ext.db.logs.extend_sloth(cls, extension)[source]

Add SQLite logging for all app events.

Parameters:
  • cls – base Sloth class to extend
  • extension{'app_logs': {'module': 'db.logs', 'db': self.db_path, 'table': 'app_logs'}
Returns:

extended Sloth class

sloth_ci.ext.db.util

class sloth_ci.ext.db.util.SqliteHandler(db, table)[source]

SQLite handler for the Python logging module.