snoop Python API

Processors

class snoop.processor.Processor

A Processor represents a chunk of analysis code that can be placed into the event loop by the user.

event(event)

Called once per event.

load(rhs)

Load data from another instance. Called when instances are replaced during a module reload.

sample()

Called periodically, “sampling” the processor state.

exception snoop.processor.ProcessorAbort(value)

Processors should throw ProcessorAbort to indicate that a problem happened, but that the processor should remain in the event loop.

class snoop.processor.ProcessorBlock(processors, kwargs={})

A processor block is analagous to a block of Python statements. It consists of a list of processors, calling each of their event methods when event is called, and each of their sample methods when sample is called.

There are two ways to create a block of processors: either provide a list of Processor instances or a list of (module_name, fromlist) tuples. In the latter case, an instance of every Processor found in the given modules will be added.

event(ev)

Call Processor.event(ev) for each processor

load_processors(paths, kwargs={}, preserve=True)

(Re)load all processors found in the provided paths and add them to this ProcesorBlock. If preserve is true, load the new instances with the data from the old via Processor.load, providing some rudimentary “schema evolution.”

sample()

Call Processor.sample() for each processor.

This is done asynchronously with a thread pool farm sampling out to multiple cores and prevent I/O-heavy sample methods from blocking processing.

Returns a multiprocessing.pool.AsyncResult; get() the results out when it is ready().

Readers

class snoop.reader.DispatchReader(address)

Read records from the dispatcher stream at address.

add_db(host, dbname, mapper)

Attach a database changes feed to this reader. See avalanche documentation for more details.

add_dispatcher(address)

Attach an additional dispatch stream to this reader. See avalanche documentation for more details.

read()

Generator of events from the dispatcher.

class snoop.reader.ROOTFileReader(filenames, tree_name, branch_name, obj)

Read entries from a ROOT tree in a file.

load_tree()

Load the ROOT tree for reading. This is deferred until the first read to prevent file descriptors from getting lost if running as a daemon.

read()

Generator of entries on the requested branch. Raises StopIteration when no more entries are available.

Writers

class snoop.writer.CouchDBWriter(host, dbname, username=None, password=None)

Output handler that writes to a CouchDB database.

class snoop.writer.PrintWriter

Output handler that just prints.

class snoop.writer.Writer

Output handler (base class).

Project Versions

Table Of Contents

Previous topic

Welcome to snoop’s documentation!

Next topic

snoop Design

This Page