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.

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.
Method of running the plugin, Called by the plugins which are set in hornet.plugin.Plugin.listen_to.
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.
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.
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.
Add listener to the list of listeners of this plugin.
Removes listener from the list of listeners of this plugin.
Returns the location to which to save filename based upon the output_dir defined in hornet.application.Config.
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.
A unique identifier for the plugin instance. Typically set by HORNET based upon the configuration of the plugin.
Type of the plugin instance, which is simply the module and class name of the type of the plugin in a tuple.
Reference to the main hornet.application.Hornet. Useful in select contexts.


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


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

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