plainbox.impl.exporter – shared code for session state exporters

Warning

THIS MODULE DOES NOT HAVE STABLE PUBLIC API

class plainbox.impl.exporter.ByteStringStreamTranslator(dest_stream, encoding)[source]

This is a sort of “impedance matcher” that bridges the gap between something that expects to write strings to a stream and a stream that expects to receive bytes. Instead of using, for instance, an intermediate in-memory IO object, this decodes on the fly and has the same interface as a writable stream, so it can be initialized with the destination string stream and then passed to something (usually a dump-style function) that writes bytes.

write(data)[source]

Writes to the stream, takes bytes and decodes them per the object’s specified encoding prior to writing. :param data: the chunk of data to write.

class plainbox.impl.exporter.SessionStateExporterBase(option_list=None)[source]

Base class for “exporter” that write out the state of the session after all jobs have finished running, in a user-selected format. The intent is not to preserve everything that the session may hold but instead to present it to the user in the best format possible.

Each exporter can support a set of options (currently boolean flags) that can alter the way it operates. It’s best to keep the list of exporter options under control to keep the user interface from becoming annoying.

OPTION_FLATTEN_IO_LOG = 'flatten-io-log'
OPTION_SQUASH_IO_LOG = 'squash-io-log'
OPTION_WITH_ATTACHMENTS = 'with-attachments'
OPTION_WITH_COMMENTS = 'with-comments'
OPTION_WITH_DESIRED_JOB_LIST = 'with-job-list'
OPTION_WITH_IO_LOG = 'with-io-log'
OPTION_WITH_JOB_DEFS = 'with-job-defs'
OPTION_WITH_JOB_HASH = 'with-job-hash'
OPTION_WITH_JOB_LIST = 'with-job-list'
OPTION_WITH_JOB_VIA = 'with-job-via'
OPTION_WITH_RESOURCE_MAP = 'with-resource-map'
OPTION_WITH_RUN_LIST = 'with-run-list'
SUPPORTED_OPTION_LIST = ('with-io-log', 'squash-io-log', 'flatten-io-log', 'with-run-list', 'with-job-list', 'with-resource-map', 'with-job-defs', 'with-attachments', 'with-comments', 'with-job-via', 'with-job-hash')
dump(data, stream)[source]

Dump data to stream.

This method operates on data that was returned by get_session_data_subset(). It may not really process bytes or simple collections. Instead, for efficiency, anything is required.

As in get_session_data_subset() it’s essential to safely save arbitrarily large data sets (or actually, only where it matters the most, like in io_log).

Data is a text stream suitable for writing.

get_session_data_subset(session)[source]

Compute a subset of session data.

The subset of the data that should be saved may depend on a particular saver class and options selected by the user.

Must return a collection that can be handled by save_data(). Special care must be taken when processing io_log (and in the future, attachments) as those can be arbitrarily large.

supported_option_list = ('with-io-log', 'squash-io-log', 'flatten-io-log', 'with-run-list', 'with-job-list', 'with-resource-map', 'with-job-defs', 'with-attachments', 'with-comments', 'with-job-via', 'with-job-hash')[source]
class plainbox.impl.exporter.classproperty(func)[source]

Class property.

plainbox.impl.exporter.get_all_exporters()[source]

Discover and load all exporter classes.

Returns a map of exporters (mapping from name to exporter class)

Previous topic

plainbox.impl.depmgr – dependency solver

Next topic

plainbox.impl.exporter.html

This Page