API Reference

arbiter Module

class arbiter.Process(config, worker=None)

Each Process instance handles the processing of inputs, outputs, and notifications, as defined in the configuration. The configuration may be passed in as a file path or a JSON string. The worker, although technically optional, is intended to provide input data processing. The function passed in will be sent to each new process and provided with the input handler, the handler configuration, and a logger object. If no override is provided, the process will provide a default worker which calls each input’s get() method. Because the worker is used for all inputs, it must be capable of working with all handlers defined in the config, and any unique requirements they may have.

Parameters
  • config (path, or string) – Process configuration.

  • worker (function, optional) – Function to use for source processing.

merge_results(results)

Merges results returned from input handlers into a single result set.

run()

Execute the configured process.

arbiter.get_auth(obj)

Resolve authentication handler for a given object

arbiter.load(file)

Loads configuration data from a JSON file

Parameters

file (str) – File path to load.

arbiter.loads(data)

Loads configuration data from a JSON string

Parameters

data (str) – JSON string to parse.

arbiter.mem_cast(value, unit=None, src=None)

Memory size (base 2) unit conversion

arbiter.parse_string(input, **kwargs)

String paramter substitution resolver

Parameters
  • input (str) – Input string to parse.

  • **kwargs (dict) – Keyword pairs of additional values to substitute.


Handlers Module

class arbiter.handlers.BaseHandler(config, **kwargs)

Bases: umsg.mixins.LoggingMixin

Base handler interface definition. All handlers inherit from this class. Each handler must implement input and output methods based on intended use, as no distinction is made between inputs and outputs; thus input and output handlers must implement the get() and set() methods respectively. The atexit() method is called by the system for input and output handlers.

Parameters
  • config (dict) – Dictionary of handler configuration data

  • **kwargs – Additional handler specific options. These will override any in the config options.

authentication

Dictionary of authentication data.

Type

dict

config

Dictionary of handler specific configuration data.

Type

dict

options

Dictionary of handler specific keyword options to be passed to the handler subroutine.

Type

dict

resource

Resource identifier.

Type

str

class arbiter.handlers.FileHandler(config, **kwargs)

Bases: arbiter.handlers.BaseHandler

Generic file handler template. Provides filepath resolution to all file handlers, and removes files at program termination.

filename

Resolved filename path.

Type

str

get()

Data getter stub, to be implemented by inheriting sub-class.

set()

Data setter stub, to be implemented by inheriting sub-class.

atexit()

Will attempt to remove the file created at exit.

class arbiter.handlers.CsvFile(config, **kwargs)

Bases: arbiter.handlers.FileHandler

Provides CSV serialization and deserialization utilizing the standard Python CSV library. By default CsvFile utilizes DictReader() and DictWriter() objects.

Notes

v1.1.0 - fields is deprecated, and will be removed in v2.0. Use fieldnames.

Parameters

fieldnames (list) – Input/output whitelist of fields to filter. All fields are kept if value is None. (Default: None)

get()

Uses DictReader() to import file contents.

set(data)

Uses DictWriter() to export file contents.

class arbiter.handlers.JsonFile(config, **kwargs)

Bases: arbiter.handlers.FileHandler

Provides JSON serialization and deserialization utilizing the standard Python JSON library. By default JsonFile utilizes load() and dump() functions.

get()

Uses load() to import file contents.

set(data)

Uses dump() to export file contents.

class arbiter.handlers.ConnectionHandler(config, **kwargs)

Bases: arbiter.handlers.BaseHandler

Generic connection handler template.

connect()

Connection stub, to be implemented by inheriting sub-class.

disconnect()

Disconnection stub, to be implemented by inheriting sub-class.

class arbiter.handlers.HttpHandler(config, **kwargs)

Bases: arbiter.handlers.ConnectionHandler

Handler template for HTTP & HTTPS connections. Provides URL component resolution.

authority

URL authority component

Type

str

host

Host or IP of the resource

Type

str

path

Resource host path

Type

str

query

Query string

Type

str

secure

Secure transport flag

Type

bool

port

Connection port on host

Type

int

class arbiter.handlers.NotificationHandler(config, **kwargs)

Bases: arbiter.handlers.BaseHandler

Generic notification handler template.

errors

List of error messages collected during processing.

Type

list

files

List of files which will be sent with the notification.

Type

list

send()

Notification action stub, to be implemented by inheriting sub-class.

class arbiter.handlers.EmailHandler(config, **kwargs)

Bases: arbiter.handlers.NotificationHandler

Sends email message notifications using an STMP server.

send()

Notification action stub, to be implemented by inheriting sub-class.


Auth Module

arbiter.auth.basic(obj)

Basic username & password authentication scheme.

Returns

A dict of credentials including an ‘auth’ key continaing the base64 ‘basic auth’ representation of the data.

Warning

Although username and plaintext password authentication is supported, it should not be used outside of a test environment.

arbiter.auth.auth_string(obj)

Base64 ‘Basic Auth’ style credential hash.

Returns

A dict of credentials including an ‘auth’ key continaing the base64 ‘basic auth’ representation of the data.

arbiter.auth.os_env(obj)

OS environemnt variable scheme.

Returns

A dict with all values replaced by their respective environment variables.


Exceptions Module

exception arbiter.exceptions.RegistrationError

Raised upon register() failure.

exception arbiter.exceptions.UnknownHandlerError

Raised when a called handler name is not registerd