hornet.plugin – HORNET Plugin

Module author: John Paulett <john.paulett -at- vanderbilt.edu>

Plugin Interface

class hornet.plugin.Plugin

Abstract class for plugins. Plugins must subclass this class in order to be properly loaded and executed by HORNET.

listen_to
List of instances of hornet.plugin.Plugin which this plugin needs to listen to. For each plugin instance in the list, this plugin will register as a listener to that plugin and receive events from that plugin.
notify(event)
Method of running the plugin, Called by the plugins which are set in hornet.plugin.Plugin.listen_to.
accepted_events()
Returns the set of hornet.event.Event subclasses that the hornet.plugin.Plugin.notify() method with accept. The passing of Events of any other type to the notify method could potentially raise an exception. Can return either a single class or a tuple of classes.
setup()
Method that is called prior to the start of the plugin. Subclasses should override this method if they which to have certain actions performed upon initialization of the object.
teardown()
Method that is called when HORNET is stopping a plugin. Plugins that hold onto resources or large data items should implement the code necessary to close these resources and delete anything. Any exceptions that occur within this method will be caught and logged but will not be rethrown. However, care should be given to ensure that an exception does not prevent other resources from being freed.
register(listener)
Add listener to the list of listeners of this plugin.
unregister(listener)
Removes listener from the list of listeners of this plugin.
output(filename)
Returns the location to which to save filename based upon the output_dir defined in hornet.application.Config.
notify_listeners(event)
Method for notifying all the listeners of an event. Should be called at any point which the plugin should inform other plugins of its changes.
id
A unique identifier for the plugin instance. Typically set by HORNET based upon the configuration of the plugin.
type
Type of the plugin instance, which is simply the module and class name of the type of the plugin in a tuple.
parent
Reference to the main hornet.application.Hornet. Useful in select contexts.

Exceptions

exception hornet.plugin.InvalidPlugin
The plugin is not a proper implementation of hornet.plugin.Plugin

Decorators

hornet.plugin.log(func, *args, **kw)
Decorator that will print debug statements at the start and end of execution of func. Expects func to be a method of an instance of hornet.plugin.Plugin. If using hornet.plugin.log() and hornet.plugin.notify_on_finish() on the same method, it is recommended to wrap hornet.plugin.log() inside of hornet.plugin.notify_on_finish() to ensure that the finished log statement is printed before all the listeners are notified.
hornet.plugin.notify_on_finish(func, *args, **kw)
Decorator that will notify all the listeners of the the plugin once func is complete. The notification event, a subclass of hornet.event.Event must be returned by func. Expects func to be a method of an instance of hornet.plugin.Plugin.

Helper Methods

hornet.plugin.valid_plugin(plugin)
Ensures that plugin is a subclass of hornet.plugin.Plugin and implements the proper methods. If plugin is not valid, a hornet.plugin.InvalidPlugin exception is raised.

See also

Writing Plugins for HORNET
Instructions on creating your own plugin.

Table Of Contents

Previous topic

HORNET Plugins

Next topic

Writing Plugins for HORNET

This Page