diff options
author | Joel Andres Granados <jgranado@redhat.com> | 2007-11-20 14:02:16 +0100 |
---|---|---|
committer | Joel Andres Granados <jgranado@redhat.com> | 2007-11-20 14:02:16 +0100 |
commit | 0ead822b85428109f6089a0167c70db0fab4f9de (patch) | |
tree | 5b5887efd1f9e34797e98d293faf01afa82e2e5c | |
parent | 568b29eab782ebebe0fbae90cb3e2ca83f897977 (diff) | |
download | firstaidkit-0ead822b85428109f6089a0167c70db0fab4f9de.tar.gz firstaidkit-0ead822b85428109f6089a0167c70db0fab4f9de.tar.xz firstaidkit-0ead822b85428109f6089a0167c70db0fab4f9de.zip |
Lets use Plugin as an abstract class.
-rw-r--r-- | plugins/default.py | 33 | ||||
-rw-r--r-- | tasker/plugins.py | 30 |
2 files changed, 49 insertions, 14 deletions
diff --git a/plugins/default.py b/plugins/default.py index d49fd9b..d2701c8 100644 --- a/plugins/default.py +++ b/plugins/default.py @@ -15,8 +15,37 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -import tasker.plugins +from tasker.plugins import Plugin + +class DummyPlugin(Plugin): + def __init__(self): + Plugin.__init__(self) + def init(self): + self._result=True + return self._result + + def destroy(self): + self._result=True + return self._result + + def backup(self): + self._result=True + return self._result + + def restore(self): + self._result=True + return self._result + + def diagnose(self): + self._result=True + return self._result + + def fix(self): + self._result=False + return self._result + + def get_plugin(): - return tasker.plugins.Plugin() + return DummyPlugin() diff --git a/tasker/plugins.py b/tasker/plugins.py index d9ef0ce..aa9d0d9 100644 --- a/tasker/plugins.py +++ b/tasker/plugins.py @@ -89,8 +89,9 @@ class Plugin(object): All the actions that must be done before the execution of any plugin function. This function generaly addresses things that are global to the plugin. """ - self._result = True - return True + #We want these functions to be overridden by the plugin developer. + if self.__class__ is Plugin: + raise TypeError, "Plugin is an abstract class." def destroy(self): """Final actions. @@ -99,28 +100,33 @@ class Plugin(object): This function generaly addresses things that are global and need to be closed off, like file descriptos, or mounted partitions.... """ - self._result = True - return True + #We want these functions to be overridden by the plugin developer. + if self.__class__ is Plugin: + raise TypeError, "Plugin is an abstract class." def backup(self): """Gather important information needed for restore.""" - self._result = True - return True + #We want these functions to be overridden by the plugin developer. + if self.__class__ is Plugin: + raise TypeError, "Plugin is an abstract class." def restore(self): """Try to restore the previous state described in backup.""" - self._result = True - return True + #We want these functions to be overridden by the plugin developer. + if self.__class__ is Plugin: + raise TypeError, "Plugin is an abstract class." def diagnose(self): """Diagnose the situation.""" - self._result = True #the system is OK - return self._result + #We want these functions to be overridden by the plugin developer. + if self.__class__ is Plugin: + raise TypeError, "Plugin is an abstract class." def fix(self): """Try to fix whatever is wrong in the system.""" - self._result = False - return False + #We want these functions to be overridden by the plugin developer. + if self.__class__ is Plugin: + raise TypeError, "Plugin is an abstract class." class BinPlugin(Plugin): def __init__(self, bin): |