summaryrefslogtreecommitdiffstats
path: root/pyfirstaidkit/interpret.py
diff options
context:
space:
mode:
authorMartin Sivak <msivak@redhat.com>2008-03-05 14:15:36 +0100
committerMartin Sivak <msivak@redhat.com>2008-03-05 14:15:36 +0100
commitb9e406a6255e2f0f14c966acb492f2d4e8d3da8c (patch)
tree5f61f9abc34145ca14143ad72785d5262da93915 /pyfirstaidkit/interpret.py
parent379616173fb52318300334efdee234a251ad8302 (diff)
downloadfirstaidkit-b9e406a6255e2f0f14c966acb492f2d4e8d3da8c.tar.gz
firstaidkit-b9e406a6255e2f0f14c966acb492f2d4e8d3da8c.tar.xz
firstaidkit-b9e406a6255e2f0f14c966acb492f2d4e8d3da8c.zip
Sanitize the origin/level/importance system
Use reporting when possible (some messages automatically use Logger to avoid duplication) Improve the Output thread to use the new level/importance system
Diffstat (limited to 'pyfirstaidkit/interpret.py')
-rw-r--r--pyfirstaidkit/interpret.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/pyfirstaidkit/interpret.py b/pyfirstaidkit/interpret.py
index 79f2f21..f6441bc 100644
--- a/pyfirstaidkit/interpret.py
+++ b/pyfirstaidkit/interpret.py
@@ -17,7 +17,7 @@
import os
from plugins import PluginSystem
-from reporting import Reports, TASKER
+from reporting import Reports, TASKER, PLUGINSYSTEM
import logging
import copy
from errors import *
@@ -54,6 +54,8 @@ class RunDependencies(object):
class Tasker:
"""The main interpret of tasks described in Config object"""
+ name = "Task interpreter"
+
def __init__(self, cfg):
self._provide = RunDependencies()
self._config = cfg
@@ -71,14 +73,15 @@ class Tasker:
self._reporting.end()
def run(self):
+ self._reporting.start(level = TASKER, origin = self)
pluginSystem = self.pluginSystem
# Check the root privilegies
if os.geteuid() == 0:
- self._reporting.info("You are running the firstaidkit as root.", origin = TASKER)
+ self._reporting.info("You are running the firstaidkit as root.", level = TASKER, origin = self, importance = logging.WARNING)
self._provide.provide("root")
else:
- self._reporting.info("You are not running the firstaidkit as root. Some plugins may not be available.", origin = TASKER)
+ self._reporting.info("You are not running the firstaidkit as root. Some plugins may not be available.", level = TASKER, origin = self, importance = logging.WARNING)
self._provide.unprovide("root")
#initialize the startup set of flags
@@ -97,12 +100,12 @@ class Tasker:
for plugin 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 pluginSystem.getplugin(plugin).getFlows()):
- self._reporting.info("Plugin %s does not contain flow %s" % (plugin, flow or pluginSystem.getplugin(plugin).default_flow,), origin = 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:
- self._reporting.info("Plugin %s was not called because of unsatisfied dependencies" % (plugin,), origin = TASKER, importance = logging.WARNING)
+ 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)
@@ -119,7 +122,7 @@ class Tasker:
p = pluginSystem.getplugin(k)
flowinfo = [ (f, p.getFlow(f).description) for f in p.getFlows() ]
rep.append((k, p.name, p.version, p.author, p.description, p.default_flow, flowinfo))
- self._reporting.table(rep, origin = TASKER)
+ self._reporting.table(rep, level = TASKER, origin = self, title = "List of plugins")
elif self._config.operation.mode == "info":
#get info about plugin
try:
@@ -129,9 +132,11 @@ class Tasker:
return False
flowinfo = [ (f, p.getFlow(f).description) for f in p.getFlows() ]
rep = {"id": self._config.operation.params, "name": p.name, "version": p.version, "author": p.author, "description": p.description, "flow": p.default_flow, "flows": flowinfo}
- self._reporting.tree(rep, origin = TASKER)
+ self._reporting.tree(rep, level = TASKER, origin = self, title = "Information about plugin %s" % (self._config.operation.params,))
else:
Logger.error("Incorrect task specified")
+ self._reporting.stop(level = TASKER, origin = self)
return False
+ self._reporting.stop(level = TASKER, origin = self)
return True