waterbutler.core package

waterbutler.core.auth module

class waterbutler.core.auth.AuthType[source]

Bases: enum.Enum

An enumeration.

class waterbutler.core.auth.BaseAuthHandler[source]

Bases: object

fetch(request, bundle)[source]
get(resource, provider, request, action=None, auth_type=<AuthType.SOURCE: 0>, path='', version=None)[source]

waterbutler.core.exceptions module

waterbutler.core.log_payload module

waterbutler.core.logging module

class waterbutler.core.logging.MaskFormatter(fmt=None, datefmt=None, style='%', pattern=None, mask='***')[source]

Bases: logging.Formatter


Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

waterbutler.core.metadata module

waterbutler.core.metrics module

class waterbutler.core.metrics.MetricsBase[source]

Bases: object

Lightweight wrapper around a dict to make keeping track of metrics a little easier.

Current functionality is limited, but may be extended later. To do:

  • update/override method to indicate expectations of existing key

    self.metrics.add_default(‘some.flag’, True) <later> self.metrics.override(‘some.flag’, False) # dies if ‘some.flag’ doesn’t already exist

  • optional type validation?

    self.metrics.add(‘some.flag’, True, bool()) -or- self.metrics.define(‘some.flag’, bool()) <later> self.metrics.add(‘some.flag’, ‘foobar’) # dies, ‘foobar’ isn’t a bool


ID string for this object

add(key, value)[source]

add() stores the given value under the given key. Subkeys can be specified by placing a dot between the parent and child keys. e.g. ‘foo.bar’ will be interpreted as self._metrics['foo']['bar']

  • key (str) – the key to store value under
  • value – the value to store, type unrestricted

incr() increments the value stored in key, or initializes it to 1 if it has not yet been set.

Parameters:key (str) – the key to increment the value of
append(key, new_value)[source]

Assume key points to a list and append new_value to it. Will initialize a list if key is undefined. Type homogeneity of list members is not enforced.

  • key (str) – the key to store value under
  • value – the value to store, type unrestricted

Merges a dict into the current metrics.

Parameters:record (dict) – a dict to merge with the current metrics

Return a copy of the metrics


‘This is who I am and this is what I stand for!’

Returns a dict with one entry: our key pointing to our metrics

class waterbutler.core.metrics.MetricsRecord(category)[source]

Bases: waterbutler.core.metrics.MetricsBase

An extension to MetricsBase that carries a category and list of submetrics. When serialized, will include the serialized child metrics


ID string for this record: ‘{category}’


Returns its metrics with the metrics for each of the subrecords included under their key.


Create a new MetricsSubRecord object with our category and save it to the subrecords list.

class waterbutler.core.metrics.MetricsSubRecord(category, name)[source]

Bases: waterbutler.core.metrics.MetricsRecord

An extension to MetricsRecord that carries a name in addition to a category. Will identify itself as {category}_{name}. Can create its own subrecord whose category will be this subrecord’s name.


ID string for this subrecord: ‘{category}_{name}’


Creates and saves a new subrecord. The new subrecord will have its category set to the parent subrecord’s name. ex:

parent = MetricsRecord('foo')
child = parent.new_subrecord('bar')
grandchild = child.new_subrecord('baz')

print(parent.key)      # foo
print(child.key)       # foo_bar
print(grandchild.key)  # bar_baz

waterbutler.core.path module

waterbutler.core.provider module

waterbutler.core.remote_logging module

waterbutler.core.signing module


Recursively sort keys of input data and all its nested dictionaries. Used to ensure consistent ordering of JSON payloads.

class waterbutler.core.signing.Signer(secret, digest)[source]

Bases: object

verify_message(signature, message)[source]
verify_payload(signature, payload)[source]
waterbutler.core.signing.sign_data(signer, data, ttl=100)[source]

waterbutler.core.utils module

Module contents