From 5a0ae1c50be8e9f39478b688da175083cb4ef9f4 Mon Sep 17 00:00:00 2001 From: Joel Andres Granados Date: Fri, 8 Aug 2008 10:59:04 +0200 Subject: Add the possibility to pass arguments to plugins. Given that firstaidkit is fully automated we need a way to modify the plugin behaviour from the initial command. This makes it easy for the plugin developer to get a string with some arguments for his plugin. It is up to the plugin developer to parse the string. The arguments will be accessible through self._args variable. --- pyfirstaidkit/plugins.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'pyfirstaidkit/plugins.py') diff --git a/pyfirstaidkit/plugins.py b/pyfirstaidkit/plugins.py index 82d7049..e373322 100644 --- a/pyfirstaidkit/plugins.py +++ b/pyfirstaidkit/plugins.py @@ -110,7 +110,7 @@ class Plugin(object): default_flow = "diagnose" def __init__(self, flow, reporting, dependencies, path = None, - backups = None, info = None): + backups = None, info = None, args = None): """ Initialize the instance. flow -- Name of the flow to be used with this instance. @@ -127,6 +127,7 @@ class Plugin(object): self._path = path self._backups = backups self._info = info + self._args = args self.provide = dependencies.provide self.unprovide = dependencies.unprovide @@ -600,11 +601,15 @@ class PluginSystem(object): message = plugin) return False + args = None + if Config.has_option("plugin-args", pklass.name): + args = Config.get("plugin-args", pklass.name) + infosection = getattr(Info, plugin) infosection.unlock() p = pklass(flowName, reporting = self._reporting, dependencies = self._deps, backups = self._backups, - path = plugindir, info = infosection) + path = plugindir, info = infosection, args = args) 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." % -- cgit