summaryrefslogtreecommitdiffstats
path: root/pyfirstaidkit
diff options
context:
space:
mode:
authorMartin Sivak <msivak@redhat.com>2008-04-22 16:51:24 +0200
committerMartin Sivak <msivak@redhat.com>2008-04-22 16:51:24 +0200
commite6c5b160cfe4705b5533241a432067dd3e570b36 (patch)
tree8379951a4fd404a8cad53f20a9cf284533155e5a /pyfirstaidkit
parentedf22559514d72714c58d8e59cb02e77d762b31c (diff)
downloadfirstaidkit-e6c5b160cfe4705b5533241a432067dd3e570b36.tar.gz
firstaidkit-e6c5b160cfe4705b5533241a432067dd3e570b36.tar.xz
firstaidkit-e6c5b160cfe4705b5533241a432067dd3e570b36.zip
Add --nodeps commandline parameter and associated operation.dependencies configuration flag
Modify the Tasker to accept list of plugins and list of flows to run with them (so it is possible to choose arbitrary combination in gui)
Diffstat (limited to 'pyfirstaidkit')
-rw-r--r--pyfirstaidkit/configuration.py1
-rw-r--r--pyfirstaidkit/interpret.py46
2 files changed, 24 insertions, 23 deletions
diff --git a/pyfirstaidkit/configuration.py b/pyfirstaidkit/configuration.py
index ac9de5d..6f32ba2 100644
--- a/pyfirstaidkit/configuration.py
+++ b/pyfirstaidkit/configuration.py
@@ -34,6 +34,7 @@ def createDefaultConfig(config):
config.operation.help = "False"
config.operation.gui = "console"
config.operation.verbose = "False"
+ config.operation.dependencies = "True"
config.log.method = "file"
config.log.filename = "/var/log/firstaidkit.log"
config.plugin.disabled = ""
diff --git a/pyfirstaidkit/interpret.py b/pyfirstaidkit/interpret.py
index beb2852..679fcec 100644
--- a/pyfirstaidkit/interpret.py
+++ b/pyfirstaidkit/interpret.py
@@ -86,16 +86,27 @@ class Tasker:
for flag in self._config.operation._list("flags"):
self._provide.provide(flag)
- if self._config.operation.mode in ("auto", "auto-flow"):
- flow = None
+ if self._config.operation.mode in ("auto", "auto-flow", "plugin", "flow"):
+
+ if self._config.operation.mode == "plugin":
+ pluginlist = self._config.operation._list("plugin")
+ else:
+ pluginlist = set(pluginSystem.list())
+
if self._config.operation.mode == "auto-flow":
- flow = self._config.operation.flow
- oldlist = set()
- actlist = set(pluginSystem.list())
+ flows = len(pluginlist)*[self._config.operation.flow]
+ elif self._config.operation.mode == "flow":
+ flows = self._config.operation._list("flow")
+ else:
+ flows = len(pluginlist)*[None]
+
#iterate through plugins until there is no plugin left or no action performed during whole iteration
+ oldlist = set()
+ actlist = set(zip(pluginlist, flows))
+
while len(actlist)>0 and oldlist!=actlist:
oldlist = copy.copy(actlist)
- for plugin in oldlist:
+ for plugin,flow in oldlist:
#If plugin does not contain the automated flow or if it ran correctly, remove it from list
if ((flow and not flow in pluginSystem.getplugin(plugin).getFlows()) or
(not flow and not pluginSystem.getplugin(plugin).default_flow in
@@ -103,25 +114,14 @@ class Tasker:
self._reporting.info("Plugin %s does not contain flow %s"%
(plugin, flow or pluginSystem.getplugin(plugin).default_flow,),
level = TASKER, origin = self)
- actlist.remove(plugin)
- elif pluginSystem.autorun(plugin, flow = flow):
- actlist.remove(plugin)
- for plugin in actlist:
+ actlist.remove((plugin, flow))
+ elif pluginSystem.autorun(plugin, flow = flow, dependencies = self._config.operation.dependencies != "False"):
+ actlist.remove((plugin, flow))
+
+ #some plugins may not be called because of unfavorable flags
+ for plugin in set(map(lambda x: x[0], actlist)):
self._reporting.info("Plugin %s was not called because of unsatisfied dependencies"%
(plugin,), level = TASKER, origin = self, importance = logging.WARNING)
- elif self._config.operation.mode == "flow":
- try:
- pluginSystem.autorun(self._config.operation.plugin,
- flow = self._config.operation.flow, dependencies = False)
- except InvalidFlowNameException, e:
- pass
- elif self._config.operation.mode == "plugin":
- try:
- pluginSystem.autorun(self._config.operation.plugin, dependencies = False)
- except (InvalidPluginNameException, InvalidFlowNameException), e:
- pass
- elif self._config.operation.mode == "task":
- pass
elif self._config.operation.mode == "flags":
self._reporting.table(self._provide.known(), level = TASKER, origin = self, title = "List of flags")
elif self._config.operation.mode == "list":