diff options
author | Martin Sivak <msivak@redhat.com> | 2008-03-05 11:06:01 +0100 |
---|---|---|
committer | Martin Sivak <msivak@redhat.com> | 2008-03-05 11:06:01 +0100 |
commit | 379616173fb52318300334efdee234a251ad8302 (patch) | |
tree | 6df544404c347aa7d542e1e4763a909896ff144a /pyfirstaidkit/plugins.py | |
parent | 01582a1a4fd27d8b3012de4da8c70a3d8212774b (diff) | |
download | firstaidkit-379616173fb52318300334efdee234a251ad8302.tar.gz firstaidkit-379616173fb52318300334efdee234a251ad8302.tar.xz firstaidkit-379616173fb52318300334efdee234a251ad8302.zip |
When instantiating plugin, pass the path to the plugin, so it knows where to find it's parts
Diffstat (limited to 'pyfirstaidkit/plugins.py')
-rw-r--r-- | pyfirstaidkit/plugins.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/pyfirstaidkit/plugins.py b/pyfirstaidkit/plugins.py index d8fe14b..1c422c3 100644 --- a/pyfirstaidkit/plugins.py +++ b/pyfirstaidkit/plugins.py @@ -98,17 +98,19 @@ class Plugin(object): default_flow = "diagnose" - def __init__(self, flow, reporting, dependencies): + def __init__(self, flow, reporting, dependencies, path = None): """ Initialize the instance. flow -- Name of the flow to be used with this instance. reporting -- object used to report information to the user dependencies -- object encapsulating the inter-plugin dependency API (require, provide) + path -- directory from where was this plugin imported The flow is defined in the __init__ so we don't have to worry about changing it. """ self._reporting = reporting self._dependencies = dependencies + self._path = path self.provide = dependencies.provide self.unprovide = dependencies.unprovide @@ -383,6 +385,7 @@ class PluginSystem(object): imp.release_lock() self._plugins[m] = module + Logger.debug("Module %s successfully imported with basedir %s", m, os.path.dirname(module.__file__)) def list(self): """Return the list of imported plugins""" @@ -395,6 +398,7 @@ returns - True if conditions are fully satisfied exception when some other error happens""" pklass = self._plugins[plugin].get_plugin() #get top level class of plugin + plugindir = os.path.dirname(self._plugins[plugin].__file__) Logger.info("Plugin information...") Logger.info("name:%s , version:%s , author:%s " % pklass.info()) @@ -426,7 +430,7 @@ returns - True if conditions are fully satisfied Logger.info("depends on condition to be UNset: %s" % (d,)) return False - p = pklass(flowName, reporting = self._reporting, dependencies = self._deps) + p = pklass(flowName, reporting = self._reporting, dependencies = self._deps, path = plugindir) for (step, rv) in p: #autorun all the needed steps Logger.info("Running step %s in plugin %s ...", step, plugin) Logger.info("%s is current step and %s is result of that step." % (step, rv)) |