diff options
author | Martin Sivak <msivak@redhat.com> | 2009-07-14 16:26:17 +0200 |
---|---|---|
committer | Martin Sivak <msivak@redhat.com> | 2009-07-14 16:26:17 +0200 |
commit | c87d413a14e96c5415fce008a5a3d2a94256326f (patch) | |
tree | 361851905781c5d1b3092dcbe325e8ec6c3d68f0 | |
parent | 0e0478425e97493c5ea355d7268f58651bf6ad9b (diff) | |
download | firstaidkit-c87d413a14e96c5415fce008a5a3d2a94256326f.tar.gz firstaidkit-c87d413a14e96c5415fce008a5a3d2a94256326f.tar.xz firstaidkit-c87d413a14e96c5415fce008a5a3d2a94256326f.zip |
Make END message more generic, so the plugins can use it to signal the end of answer
-rw-r--r-- | pyfirstaidkit/interpret.py | 4 | ||||
-rw-r--r-- | pyfirstaidkit/reporting.py | 52 |
2 files changed, 28 insertions, 28 deletions
diff --git a/pyfirstaidkit/interpret.py b/pyfirstaidkit/interpret.py index 67cc9dc..09e1641 100644 --- a/pyfirstaidkit/interpret.py +++ b/pyfirstaidkit/interpret.py @@ -18,7 +18,7 @@ import os import sys from plugins import PluginSystem -from reporting import Reports, TASKER, PLUGINSYSTEM +from reporting import Reports, TASKER, PLUGINSYSTEM, FIRSTAIDKIT import logging import copy from errors import * @@ -80,7 +80,7 @@ class Tasker: def end(self): """Signalize end of operations to all necessary places""" - self._reporting.end() + self._reporting.end(level = FIRSTAIDKIT) def run(self): self._reporting.start(level = TASKER, origin = self) diff --git a/pyfirstaidkit/reporting.py b/pyfirstaidkit/reporting.py index 28e156f..c536ae2 100644 --- a/pyfirstaidkit/reporting.py +++ b/pyfirstaidkit/reporting.py @@ -107,7 +107,7 @@ class Reports(object): return self._notify_all.append((cb, args, kwargs)) def put(self, message, origin, level, action, importance = logging.INFO, - reply = None, title = "", destination = None): + reply = None, inreplyto = None, title = "", destination = None): """destination hold reference to another Reporting object""" if destination is not None: @@ -115,7 +115,7 @@ class Reports(object): data = {"level": level, "origin": origin, "action": action, "importance": importance, "message": message, - "reply": reply, "title": title} + "reply": reply, "inreplyto": inreplyto, "title": title} destination = self._queue try: @@ -190,53 +190,53 @@ class Reports(object): self._parent.notifyAll(data, sender, *args, **kwargs) #There will be helper methods inspired by logging module - def end(self): - return self.put(None, FIRSTAIDKIT, None, END, importance = 1000) + def end(self, level = PLUGIN): + return self.put(None, level, None, END, importance = 1000) - def error(self, message, origin, level = PLUGIN, action = INFO): + def error(self, message, origin, inreplyto = None, level = PLUGIN, action = INFO): Logger.error(origin.name+": "+message) return self.put(message, origin, level, action, - importance = logging.ERROR) + importance = logging.ERROR, inreplyto = inreplyto) - def start(self, origin, level = PLUGIN, message = ""): + def start(self, origin, inreplyto = None, level = PLUGIN, message = ""): return self.put(message, origin, level, START, - importance = logging.DEBUG) - def stop(self, origin, level = PLUGIN, message = ""): + importance = logging.DEBUG, inreplyto = inreplyto) + def stop(self, origin, inreplyto = None, level = PLUGIN, message = ""): return self.put(message, origin, level, STOP, - importance = logging.DEBUG) + importance = logging.DEBUG, inreplyto = inreplyto) - def progress(self, position, maximum, origin, level = PLUGIN, + def progress(self, position, maximum, origin, inreplyto = None, level = PLUGIN, importance = logging.INFO): return self.put((position, maximum), origin, level, PROGRESS, - importance = importance) + importance = importance, inreplyto = inreplyto) - def issue(self, issue, origin, level = PLUGIN, importance = logging.INFO): + def issue(self, issue, origin, inreplyto = None, level = PLUGIN, importance = logging.INFO): Logger.debug(origin.name+": issue changed state to "+str(issue)) - return self.put(issue, origin, level, ISSUE, importance = importance) + return self.put(issue, origin, level, ISSUE, inreplyto = None, importance = importance, inreplyto = inreplyto) - def info(self, message, origin, level = PLUGIN, importance = logging.INFO): + def info(self, message, origin, inreplyto = None, level = PLUGIN, importance = logging.INFO): Logger.info(origin.name+": "+message) - return self.put(message, origin, level, INFO, importance = importance) + return self.put(message, origin, level, INFO, importance = importance, inreplyto = inreplyto) - def debug(self, message, origin, level = PLUGIN, importance = logging.DEBUG): + def debug(self, message, origin, inreplyto = None, level = PLUGIN, importance = logging.DEBUG): Logger.debug(origin.name+": "+message) - return self.put(message, origin, level, INFO, importance = importance) + return self.put(message, origin, level, INFO, importance = importance, inreplyto = inreplyto) - def tree(self, message, origin, level = PLUGIN, importance = logging.INFO, + def tree(self, message, origin, inreplyto = None, level = PLUGIN, importance = logging.INFO, title = ""): return self.put(message, origin, level, TREE, importance = importance, - title = title) + title = title, inreplyto = inreplyto) - def table(self, message, origin, level = PLUGIN, importance = logging.INFO, + def table(self, message, origin, inreplyto = None, level = PLUGIN, importance = logging.INFO, title = ""): return self.put(message, origin, level, TABLE, - importance = importance, title = title) + importance = importance, title = title, inreplyto = inreplyto) - def alert(self, message, origin, level = PLUGIN, importance = logging.WARNING): - return self.put(message, origin, level, ALERT, importance = importance) + def alert(self, message, origin, inreplyto = None, level = PLUGIN, importance = logging.WARNING): + return self.put(message, origin, level, ALERT, importance = importance, inreplyto = inreplyto) - def exception(self, message, origin, level = PLUGIN, importance = logging.ERROR): + def exception(self, message, origin, inreplyto = None, level = PLUGIN, importance = logging.ERROR): Logger.error(origin.name+": "+message) return self.put(message, origin, level, EXCEPTION, - importance = importance) + importance = importance, inreplyto = inreplyto) |