summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJoel Andres Granados <jgranado@redhat.com>2007-11-21 11:13:34 +0100
committerJoel Andres Granados <jgranado@redhat.com>2007-11-21 11:13:34 +0100
commit02250bc1f3f41ce27e2625bca6346cf515fbcb9e (patch)
treeddee0672e02f55826c04a3c6790d25d4e1008538 /plugins
parenta99422fb962c12adb99cfd62dd9442699b8c09be (diff)
downloadfirstaidkit-02250bc1f3f41ce27e2625bca6346cf515fbcb9e.tar.gz
firstaidkit-02250bc1f3f41ce27e2625bca6346cf515fbcb9e.tar.xz
firstaidkit-02250bc1f3f41ce27e2625bca6346cf515fbcb9e.zip
Implement the error class.
Implement the Return code class. Implement the manage flow stuff. Implement some examples of pligins
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sample1Plugin.py53
-rw-r--r--plugins/sample2Plugin.py70
2 files changed, 123 insertions, 0 deletions
diff --git a/plugins/sample1Plugin.py b/plugins/sample1Plugin.py
new file mode 100644
index 0000000..2a059c9
--- /dev/null
+++ b/plugins/sample1Plugin.py
@@ -0,0 +1,53 @@
+# First Aid Kit - diagnostic and repair tool for Linux
+# Copyright (C) 2007 Martin Sivak <msivak@redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+from tasker.plugins import Plugin
+from tasker.returns import *
+
+class Sample1Plugin(Plugin):
+ """This plugin uses the predefined flow in the Plugin abstract class."""
+ def __init__(self):
+ Plugin.__init__(self)
+ def init(self):
+ self._result=ReturnValueTrue
+ return self._result
+
+ def destroy(self):
+ self._result=ReturnValueTrue
+ return self._result
+
+ def backup(self):
+ self._result=ReturnValueTrue
+ return self._result
+
+ def restore(self):
+ self._result=ReturnValueTrue
+ return self._result
+
+ def diagnose(self):
+ self._result=ReturnValueTrue
+ return self._result
+
+ def fix(self):
+ self._result=ReturnValueFalse
+ return self._result
+
+
+
+def get_plugin():
+ return Sample1Plugin()
+
diff --git a/plugins/sample2Plugin.py b/plugins/sample2Plugin.py
new file mode 100644
index 0000000..041ecaa
--- /dev/null
+++ b/plugins/sample2Plugin.py
@@ -0,0 +1,70 @@
+# First Aid Kit - diagnostic and repair tool for Linux
+# Copyright (C) 2007 Martin Sivak <msivak@redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+from tasker.plugins import Plugin
+
+class Sample2Plugin(Plugin):
+ """This plugin will defin one more function and use it in a newly defined flow."""
+ def __init__(self):
+ Plugin.__init__(self)
+
+ #
+ # Additional flow definition.
+ #
+ self.customFlow = {
+ self.initial : {ReturnValue: "init"},
+ "init" : {ReturnValueTrue: "diagnose"},
+ "diagnose" : {ReturnValueTrue: "purge", ReturnValueFalse: "backup"},
+ "backup" : {ReturnValueTrue: "fix", ReturnValueFalse: "purge"},
+ "restore" : {ReturnValueTrue: "purge", ReturnValueFalse: "purge"},
+ "fix" : {ReturnValueTrue: "extraStep", ReturnValueFalse: "restore"},
+ "extraStep" : {ReturnValueTrue: "purge", ReturnValueFalse: "purge"},
+ "purge" : {ReturnValueTrue: self.final}
+ }
+ self._flows["default"] = self._defflow
+
+ def init(self):
+ self._result=ReturnValueTrue
+ return self._result
+
+ def purge(self):
+ self._result=ReturnValueTrue
+ return self._result
+
+ def backup(self):
+ self._result=ReturnValueTrue
+ return self._result
+
+ def restore(self):
+ self._result=ReturnValueTrue
+ return self._result
+
+ def diagnose(self):
+ self._result=ReturnValueTrue
+ return self._result
+
+ def fix(self):
+ self._result=ReturnValueFalse
+ return self._result
+
+ def extraStep(self):
+ self._result=ReturnValueTrue
+ return self._result
+
+def get_plugin():
+ return Sample2Plugin()
+