buildapi.lib package

Submodules

buildapi.lib.app_globals module

The application’s Globals object

class buildapi.lib.app_globals.Globals(config)[source]

Bases: object

Globals acts as a container for objects available throughout the life of the application

buildapi.lib.base module

The base Controller API

Provides the BaseController class for subclassing.

class buildapi.lib.base.BaseController[source]

Bases: pylons.controllers.core.WSGIController

jsonify(data)[source]

buildapi.lib.cache module

class buildapi.lib.cache.BuildapiCache(cache, timezone)[source]
build_key_for_day(date, branch)[source]
build_key_for_rev(branch, rev)[source]
get_builds_for_date_range(starttime, endtime, branch, method=0)[source]

Returns a list of builds for the given date range. starttime and endtime should be datetime.datetime instances.

get_builds_for_day(date, branch)[source]

Returns a list of builds for the given date (a datetime.datetime instance)

get_builds_for_revision(branch, revision)[source]
buildapi.lib.cache.getBuilds(branch, starttime, endtime)[source]

buildapi.lib.cacher module

class buildapi.lib.cacher.BaseCache[source]
get(key, func, args=None, kwargs=None, expire=0, lock_time=600)[source]
has_key(key)[source]
put(key, val, expire=0)[source]

buildapi.lib.helpers module

Helper functions

Consists of functions to typically be used within templates, but also available to Controllers. This module is available to templates as ‘h’.

class buildapi.lib.helpers.Pacific[source]

Bases: buildapi.lib.helpers.USTimeZone

class buildapi.lib.helpers.USTimeZone(hours, reprname, stdname, dstname)[source]

Bases: datetime.tzinfo

DSTEND = datetime.datetime(1, 10, 25, 1, 0)
DSTSTART = datetime.datetime(1, 4, 1, 2, 0)
_first_sunday_on_or_after(dt)[source]
dst(dt)[source]
tzname(dt)[source]
utcoffset(dt)[source]
buildapi.lib.helpers.addr_for_master(claimed_by_name)[source]

Returns the fully qualified domain name and port for the master indicated by claimed_by_name

buildapi.lib.helpers.convert_master(m)[source]

Given a claimed_by_name from schedulerdb return * pretty_name, eg ‘buildbot-master1:8011’ * master_url, eg ‘http://buildbot-master1.build.mozilla.org:8011’

buildapi.lib.helpers.get_branches()[source]
buildapi.lib.helpers.get_builders(branch, starttime=None, endtime=None)[source]
buildapi.lib.helpers.get_completeness(job_items, stableDelay)[source]
buildapi.lib.helpers.get_masters()[source]
buildapi.lib.helpers.get_masters_for_pool(pool)[source]

Returns the masters for a pool.

buildapi.lib.helpers.pacific_time(timestamp, format='%a, %d %b %Y %H:%M:%S %z (%Z)')[source]

Convert a time expressed in seconds since the epoch to a string representing Pacific time. If secs is not provided or None, the current time as returned by time() is used.

buildapi.lib.helpers.strf_YmdhMs(secs)[source]
buildapi.lib.helpers.strf_hms(tspans)[source]
buildapi.lib.helpers.url_for_build(master_addr, buildername, buildnumber)[source]

buildapi.lib.mq module

Message Queue module for buildapi. Implements helper classes to cope with the connection to the message broker going away, and specific publishers/consumers to work with buildapi’s expected messages.

class buildapi.lib.mq.ConfigMixin[source]

Bases: object

get_queue(queue_name, routing_key)[source]
setup_config(config)[source]
class buildapi.lib.mq.JobRequestConsumer(config)[source]

Bases: buildapi.lib.mq.ReliableConsumer

For agents consuming job requests.

callback = None
queue_name_config = 'mq.queue.agent'
receive(message_data, message)[source]
register_callback(cb)[source]
routing_key = 'requests'
class buildapi.lib.mq.JobRequestDoneConsumer(config)[source]

Bases: buildapi.lib.mq.ReliableConsumer

For webapp to get notified that jobs have been completed.

queue_name_config = 'mq.queue.web'
routing_key = 'finished'
class buildapi.lib.mq.JobRequestDonePublisher(config)[source]

Bases: buildapi.lib.mq.ReliablePublisher

For agents publishing job completion messages.

ack_msg(message_data)[source]
routing_key = 'finished'
class buildapi.lib.mq.JobRequestPublisher(config)[source]

Bases: buildapi.lib.mq.ReliablePublisher

For publishing job requests

cancelBuild(who, bid)[source]
cancelRequest(who, brid)[source]
cancelRevision(who, branch, revision)[source]
newBuildAtRevision(who, branch, revision)[source]
newBuildForBuilder(who, branch, revision, priority, builder_name, properties, files)[source]
newNightlyAtRevision(who, branch, revision, priority)[source]
newPGOBuildAtRevision(who, branch, revision, priority)[source]
rebuildBuild(who, bid, priority)[source]
rebuildRequest(who, brid, priority)[source]
reprioritizeRequest(who, brid, priority)[source]
routing_key = 'requests'
send_msg(action, who, **kwargs)[source]
class buildapi.lib.mq.LoggingJobRequestDoneConsumer(engine, *args, **kwargs)[source]

Bases: buildapi.lib.mq.JobRequestDoneConsumer

For webapp to get notified that jobs have been completed, and update job status in DB.

_clock()

time() -> floating point number

Return the current time in seconds since the Epoch. Fractions of a second may be present if the system clock provides them.

receive(message_data, message)[source]

Handles new job completion messages. Marks them as finished in the DB by setting the complete_at and complete_data columsn.

class buildapi.lib.mq.LoggingJobRequestPublisher(engine, *args, **kwargs)[source]

Bases: buildapi.lib.mq.JobRequestPublisher

For publishing job requests, recording them first in the database.

_clock()

time() -> floating point number

Return the current time in seconds since the Epoch. Fractions of a second may be present if the system clock provides them.

send_msg(action, who, **kwargs)[source]

Wrap JobRequestPublisher.send_msg by first logging the request in the DB, and then sending the message to the broker.

class buildapi.lib.mq.ReliableConsumer(config)[source]

Bases: buildapi.lib.mq.ConfigMixin, kombu.mixins.ConsumerMixin

Reliably consume messages from a given queue, based on config. This will reconnect repeatedly on connection failures.

Subclasses should specify the routing key as a class attribute. The queue name comes from the configuration, based on a key specified at the class level, queue_name_config

Override the receive method to handle incoming messages, remembering to call the message’s ack method.

Call the run method to run forever, or until should_stop is set. Alternately, call run_until_idle, which will run until there is an iteration with no messages.

get_consumers(Consumer, channel)[source]
on_connection_error(exc, interval)[source]
on_connection_revived()[source]
on_consume_ready(conn, channel, consumers)[source]
on_iteration()[source]
queue_name_config = None
receive(body, message)[source]
routing_key = None
run_until_idle()[source]
class buildapi.lib.mq.ReliablePublisher(config)[source]

Bases: buildapi.lib.mq.ConfigMixin

Reliably produce messages with the givent routing key. This will automatically retry if there are connection failures.

Subclasses should specify the routing key as a class attribute.

Call the send_msg method to send a message.

retry_errback(exc, interval)[source]
routing_key = None
send(message_data)[source]

buildapi.lib.times module

Module for handling times. It’s harder than it looks!

buildapi.lib.times.dt2ts(dt)[source]

Returns a timestamp (epoch time) from a timezone aware datetime instance

buildapi.lib.times.now(timezone)[source]
buildapi.lib.times.ts2dt(ts, timezone)[source]

Returns a datetime instance in the given timezone (a pytz timezone instance) from a timestamp (epoch time)

buildapi.lib.visualization module

Module contents