summaryrefslogtreecommitdiffstats
path: root/plugins/sample3Plugin
diff options
context:
space:
mode:
authorJoel Andres Granados <jgranado@redhat.com>2007-11-21 16:11:14 +0100
committerJoel Andres Granados <jgranado@redhat.com>2007-11-21 16:11:14 +0100
commitf421f2295908b21b877af6705e0ac48d9a2c6455 (patch)
treedbd381dd6f220c4cd636a1581c312d8f1502ecd2 /plugins/sample3Plugin
parentd39f1d92e4251daca8234591a760c7e31a80ca5d (diff)
Get the shell/Binary example working.
Diffstat (limited to 'plugins/sample3Plugin')
-rw-r--r--plugins/sample3Plugin/__init__.py3
-rwxr-xr-xplugins/sample3Plugin/plugin42
-rw-r--r--plugins/sample3Plugin/sample3Plugin.py96
3 files changed, 141 insertions, 0 deletions
diff --git a/plugins/sample3Plugin/__init__.py b/plugins/sample3Plugin/__init__.py
new file mode 100644
index 0000000..5c2e2c5
--- /dev/null
+++ b/plugins/sample3Plugin/__init__.py
@@ -0,0 +1,3 @@
+import sample3Plugin
+def get_plugin():
+ return FirstAidKit.plugins.sample3Plugin.Sample3Plugin()
diff --git a/plugins/sample3Plugin/plugin b/plugins/sample3Plugin/plugin
new file mode 100755
index 0000000..9cf7e03
--- /dev/null
+++ b/plugins/sample3Plugin/plugin
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+# Since this is just an example this will only have default tasks.
+TASK=""
+
+use()
+{
+ echo You are using it wrong.
+}
+
+if [ $1 ] ; then
+ if [ $2 ] ;then
+ TASK=$2
+ else
+ use
+ exit 1
+ fi
+else
+ use
+ exit 1
+fi
+
+
+if [ $TASK = "init" ]; then
+ echo init true
+fi
+if [ $TASK = "diagnose" ]; then
+ echo diagnose false
+fi
+if [ $TASK = "purge" ]; then
+ echo purge true
+fi
+if [ $TASK = "fix" ]; then
+ echo fix true
+fi
+if [ $TASK = "backup" ]; then
+ echo backup true
+fi
+if [ $TASK = "restore" ]; then
+ echo restore true
+fi
+
diff --git a/plugins/sample3Plugin/sample3Plugin.py b/plugins/sample3Plugin/sample3Plugin.py
new file mode 100644
index 0000000..415d4ba
--- /dev/null
+++ b/plugins/sample3Plugin/sample3Plugin.py
@@ -0,0 +1,96 @@
+# 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.returns import *
+from tasker.plugins import Plugin
+import subprocess
+
+class Sample3Plugin(Plugin):
+ """This plugin will use a shell script as backend."""
+ def __init__(self):
+ Plugin.__init__(self)
+
+ def init(self):
+ # Prepare command line.
+ init = ["/usr/lib/FirstAidKit/plugins/sample3Plugin/plugin", "--task", "init"]
+ proc = subprocess.Popen(init, stdout=subprocess.PIPE)
+ (out, err) = proc.communicate()
+ out = out.strip()
+ if out[-5:] == "false":
+ self._result=ReturnValueFalse
+ elif out[-4:] == "true":
+ self._result=ReturnValueTrue
+ return self._result
+
+ def purge(self):
+ purge = ["/usr/lib/FirstAidKit/plugins/sample3Plugin/plugin", "--task", "purge"]
+ proc = subprocess.Popen(purge, stdout=subprocess.PIPE)
+ (out, err) = proc.communicate()
+ out = out.strip()
+ if out[-5:] == "false":
+ self._result=ReturnValueFalse
+ elif out[-4:] == "true":
+ self._result=ReturnValueTrue
+ return self._result
+
+ def backup(self):
+ backup = ["/usr/lib/FirstAidKit/plugins/sample3Plugin/plugin", "--task", "backup"]
+ proc = subprocess.Popen(backup, stdout=subprocess.PIPE)
+ (out, err) = proc.communicate()
+ out = out.strip()
+ if out[-5:] == "false":
+ self._result=ReturnValueFalse
+ elif out[-4:] == "true":
+ self._result=ReturnValueTrue
+ return self._result
+
+ def restore(self):
+ restore = ["/usr/lib/FirstAidKit/plugins/sample3Plugin/plugin", "--task", "restore"]
+ proc = subprocess.Popen(restore, stdout=subprocess.PIPE)
+ (out, err) = proc.communicate()
+ out = out.strip()
+ if out[-5:] == "false":
+ self._result=ReturnValueFalse
+ elif out[-4:] == "true":
+ self._result=ReturnValueTrue
+ return self._result
+
+ def diagnose(self):
+ diagnose = ["/usr/lib/FirstAidKit/plugins/sample3Plugin/plugin", "--task", "diagnose"]
+ proc = subprocess.Popen(diagnose, stdout=subprocess.PIPE)
+ (out, err) = proc.communicate()
+ out = out.strip()
+ if out[-5:] == "false":
+ self._result=ReturnValueFalse
+ elif out[-4:] == "true":
+ self._result=ReturnValueTrue
+ return self._result
+
+ def fix(self):
+ fix = ["/usr/lib/FirstAidKit/plugins/sample3Plugin/plugin", "--task", "fix"]
+ proc = subprocess.Popen(fix, stdout=subprocess.PIPE)
+ (out, err) = proc.communicate()
+ out = out.strip()
+ if out[-5:] == "false":
+ self._result=ReturnValueFalse
+ elif out[-4:] == "true":
+ self._result=ReturnValueTrue
+ return self._result
+
+def get_plugin():
+ return Sample3Plugin()
+