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
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()
andset()
methods respectively. Theatexit()
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.
-
options
¶ Dictionary of handler specific keyword options to be passed to the handler subroutine.
- Type
-
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.
-
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
utilizesDictReader()
andDictWriter()
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
utilizesload()
anddump()
functions.
-
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.
URL authority component
- Type
-
class
arbiter.handlers.
NotificationHandler
(config, **kwargs)¶ Bases:
arbiter.handlers.BaseHandler
Generic notification handler template.
-
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.