common.utils package

Submodules

common.utils.conversions module

common.utils.conversions.bytes2mac(buf)[source]
common.utils.conversions.mac2bytes(s)[source]

common.utils.db module

Helpers for working with the DB.

All of these expect to be passed a records.Database wrapping a psycopg2 connection.

class common.utils.db.Notify(channel, payload)

Bases: tuple

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

static __new__(_cls, channel, payload)

Create new instance of Notify(channel, payload)

__repr__()

Return a nicely formatted representation string

channel

Alias for field number 0

payload

Alias for field number 1

common.utils.db.listen_for_notify(db, channels, callback, debounce_timeout=1)[source]

Listen for Postgres’s NOTIFY, debouncing/deduplicating notifications.

debounce_timeout is in seconds.

common.utils.logging module

class common.utils.logging.Formatter(fmt=None, datefmt=None, style='%')[source]

Bases: logging.Formatter

Deadlock-friendly formatter for logging. It likes to shorten things.

Changes from logging.Formatter:

  • strips first name component from logger name, as it is redundant in both prod and devel config
format(record)[source]

Module contents