From 1b34958d6340403ce9c5d1f715d7edfcd74071b0 Mon Sep 17 00:00:00 2001 From: Martin Sivak Date: Wed, 19 Mar 2008 11:24:23 +0100 Subject: Fix the return values and flag logic of IssuesPlugin --- pyfirstaidkit/plugins.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pyfirstaidkit/plugins.py b/pyfirstaidkit/plugins.py index 9b25c7f..c36c98f 100644 --- a/pyfirstaidkit/plugins.py +++ b/pyfirstaidkit/plugins.py @@ -314,18 +314,22 @@ Just fill the issue_tests list with classes describing the tests and let it run. """Diagnose the situation.""" result = False + happened = False for i in self.tests: self._reporting.info(level = TASK, origin = self, message = "Investigating '%s'" % (i.name,)) result = result or i.detect() if i.happened(): + happened = True self._reporting.info(level = TASK, origin = self, message = i.str()) - if result: + if result and not happened: self._result=ReturnSuccess for flag in self.set_flags: self._dependencies.provide(flag) - else: + elif result: self._result=ReturnFailure + else: + self._result = None def fix(self): """Try to fix whatever is wrong in the system.""" @@ -335,18 +339,22 @@ Just fill the issue_tests list with classes describing the tests and let it run. for i in self.tests: self._reporting.info(level = TASK, origin = self, message = "Fixing '%s'" % (i.name,)) result = result or i.fix() + if not i.fixed(): + fixed = False + continue + i.reset() if not i.detect() or i.happened(): fixed = False - if fixed: + if result and fixed: + self._result=ReturnSuccess for flag in self.set_flags: self._dependencies.provide(flag) - - if result: - self._result=ReturnSuccess - else: + elif result: self._result=ReturnFailure + else: + self._result = None class FlagTrackerPlugin(Plugin): -- cgit