summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Andres Granados <jgranado@redhat.com>2007-11-22 15:11:43 +0100
committerJoel Andres Granados <jgranado@redhat.com>2007-11-22 15:11:43 +0100
commit9a6c6d665c7d9c9da78ea5488bcd4b8b7f7df211 (patch)
tree8ca389e60ff2d894bad023454430268ce259c376
parent83d9690c02e9189ec8ceddc92b2c400f0b1521cb (diff)
downloadfirstaidkit-9a6c6d665c7d9c9da78ea5488bcd4b8b7f7df211.tar.gz
firstaidkit-9a6c6d665c7d9c9da78ea5488bcd4b8b7f7df211.tar.xz
firstaidkit-9a6c6d665c7d9c9da78ea5488bcd4b8b7f7df211.zip
Change all references from init to prepare.
Change all references from purge to clean. Log a warning when abstract functions are not used.
-rw-r--r--COPYING2
-rw-r--r--PLUGINS2
-rw-r--r--plugins/sample1Plugin.py2
-rw-r--r--plugins/sample2Plugin.py20
-rw-r--r--plugins/sample3Plugin/__init__.py2
-rwxr-xr-xplugins/sample3Plugin/plugin8
-rw-r--r--plugins/sample3Plugin/sample3Plugin.py12
-rw-r--r--tasker/plugins.py32
8 files changed, 40 insertions, 40 deletions
diff --git a/COPYING b/COPYING
index a43ea21..02acff3 100644
--- a/COPYING
+++ b/COPYING
@@ -155,7 +155,7 @@ Sections 1 and 2 above provided that you also do one of the following:
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
+associated interface defprepareion files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
diff --git a/PLUGINS b/PLUGINS
index f57869f..47e2fcd 100644
--- a/PLUGINS
+++ b/PLUGINS
@@ -53,7 +53,7 @@ current function.
Each plugin exports some steps. The mandatory ones are
-- init -- initialize plugin, get environment, ..
+- prepare -- initialize plugin, get environment, ..
- backup -- backup everything we could touch in this plugin
- diagnose -- get info about the investigated system and determine where
the problems are
diff --git a/plugins/sample1Plugin.py b/plugins/sample1Plugin.py
index 2a059c9..223dd4a 100644
--- a/plugins/sample1Plugin.py
+++ b/plugins/sample1Plugin.py
@@ -22,7 +22,7 @@ class Sample1Plugin(Plugin):
"""This plugin uses the predefined flow in the Plugin abstract class."""
def __init__(self):
Plugin.__init__(self)
- def init(self):
+ def prepare(self):
self._result=ReturnValueTrue
return self._result
diff --git a/plugins/sample2Plugin.py b/plugins/sample2Plugin.py
index 041ecaa..57b446d 100644
--- a/plugins/sample2Plugin.py
+++ b/plugins/sample2Plugin.py
@@ -23,25 +23,25 @@ class Sample2Plugin(Plugin):
Plugin.__init__(self)
#
- # Additional flow definition.
+ # Additional flow defprepareion.
#
self.customFlow = {
- self.initial : {ReturnValue: "init"},
- "init" : {ReturnValueTrue: "diagnose"},
- "diagnose" : {ReturnValueTrue: "purge", ReturnValueFalse: "backup"},
- "backup" : {ReturnValueTrue: "fix", ReturnValueFalse: "purge"},
- "restore" : {ReturnValueTrue: "purge", ReturnValueFalse: "purge"},
+ self.initial : {ReturnValue: "prepare"},
+ "prepare" : {ReturnValueTrue: "diagnose"},
+ "diagnose" : {ReturnValueTrue: "clean", ReturnValueFalse: "backup"},
+ "backup" : {ReturnValueTrue: "fix", ReturnValueFalse: "clean"},
+ "restore" : {ReturnValueTrue: "clean", ReturnValueFalse: "clean"},
"fix" : {ReturnValueTrue: "extraStep", ReturnValueFalse: "restore"},
- "extraStep" : {ReturnValueTrue: "purge", ReturnValueFalse: "purge"},
- "purge" : {ReturnValueTrue: self.final}
+ "extraStep" : {ReturnValueTrue: "clean", ReturnValueFalse: "clean"},
+ "clean" : {ReturnValueTrue: self.final}
}
self._flows["default"] = self._defflow
- def init(self):
+ def prepare(self):
self._result=ReturnValueTrue
return self._result
- def purge(self):
+ def clean(self):
self._result=ReturnValueTrue
return self._result
diff --git a/plugins/sample3Plugin/__init__.py b/plugins/sample3Plugin/__init__.py
index 5c2e2c5..59de871 100644
--- a/plugins/sample3Plugin/__init__.py
+++ b/plugins/sample3Plugin/__init__.py
@@ -1,3 +1,3 @@
import sample3Plugin
def get_plugin():
- return FirstAidKit.plugins.sample3Plugin.Sample3Plugin()
+ return sample3Plugin.Sample3Plugin()
diff --git a/plugins/sample3Plugin/plugin b/plugins/sample3Plugin/plugin
index 9cf7e03..c3099a5 100755
--- a/plugins/sample3Plugin/plugin
+++ b/plugins/sample3Plugin/plugin
@@ -21,14 +21,14 @@ else
fi
-if [ $TASK = "init" ]; then
- echo init true
+if [ $TASK = "prepare" ]; then
+ echo prepare true
fi
if [ $TASK = "diagnose" ]; then
echo diagnose false
fi
-if [ $TASK = "purge" ]; then
- echo purge true
+if [ $TASK = "clean" ]; then
+ echo clean true
fi
if [ $TASK = "fix" ]; then
echo fix true
diff --git a/plugins/sample3Plugin/sample3Plugin.py b/plugins/sample3Plugin/sample3Plugin.py
index 415d4ba..7e8a4c2 100644
--- a/plugins/sample3Plugin/sample3Plugin.py
+++ b/plugins/sample3Plugin/sample3Plugin.py
@@ -24,10 +24,10 @@ class Sample3Plugin(Plugin):
def __init__(self):
Plugin.__init__(self)
- def init(self):
+ def prepare(self):
# Prepare command line.
- init = ["/usr/lib/FirstAidKit/plugins/sample3Plugin/plugin", "--task", "init"]
- proc = subprocess.Popen(init, stdout=subprocess.PIPE)
+ prepare = ["/usr/lib/FirstAidKit/plugins/sample3Plugin/plugin", "--task", "prepare"]
+ proc = subprocess.Popen(prepare, stdout=subprocess.PIPE)
(out, err) = proc.communicate()
out = out.strip()
if out[-5:] == "false":
@@ -36,9 +36,9 @@ class Sample3Plugin(Plugin):
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)
+ def clean(self):
+ clean = ["/usr/lib/FirstAidKit/plugins/sample3Plugin/plugin", "--task", "clean"]
+ proc = subprocess.Popen(clean, stdout=subprocess.PIPE)
(out, err) = proc.communicate()
out = out.strip()
if out[-5:] == "false":
diff --git a/tasker/plugins.py b/tasker/plugins.py
index 9ce8db4..eca96b4 100644
--- a/tasker/plugins.py
+++ b/tasker/plugins.py
@@ -68,13 +68,13 @@ class Plugin(object):
# with the parent of all ReturnValue classes.
#
self._defflow = {
- self.initial : {ReturnValue: "init"},
- "init" : {ReturnValueTrue: "diagnose"},
- "diagnose" : {ReturnValueTrue: "purge", ReturnValueFalse: "backup"},
- "backup" : {ReturnValueTrue: "fix", ReturnValueFalse: "purge"},
- "fix" : {ReturnValueTrue: "purge", ReturnValueFalse: "restore"},
- "restore" : {ReturnValueTrue: "purge", ReturnValueFalse: "purge"},
- "purge" : {ReturnValueTrue: self.final}
+ self.initial : {ReturnValue: "prepare"},
+ "prepare" : {ReturnValueTrue: "diagnose"},
+ "diagnose" : {ReturnValueTrue: "clean", ReturnValueFalse: "backup"},
+ "backup" : {ReturnValueTrue: "fix", ReturnValueFalse: "clean"},
+ "fix" : {ReturnValueTrue: "clean", ReturnValueFalse: "restore"},
+ "restore" : {ReturnValueTrue: "clean", ReturnValueFalse: "clean"},
+ "clean" : {ReturnValueTrue: self.final}
}
self._flows["default"] = self._defflow
@@ -121,7 +121,7 @@ class Plugin(object):
#list of all actions provided
def actions(self):
"""Returns list of available actions"""
- return set(["init", "backup", "diagnose", "describe", "fix", "restore", "purge"])
+ return set(["prepare", "backup", "diagnose", "describe", "fix", "restore", "clean"])
def nextstate(self, state=None, result=None):
"""Returns next state when analizing self._state, self._result and the self.cflow in automode.
@@ -174,7 +174,7 @@ class Plugin(object):
#
#default (mandatory) plugin actions
#
- def init(self):
+ def prepare(self):
"""Initial actions.
All the actions that must be done before the execution of any plugin function.
@@ -182,9 +182,9 @@ class Plugin(object):
"""
#We want these functions to be overridden by the plugin developer.
if self.__class__ is Plugin:
- raise TypeError, "Plugin is an abstract class."
+ Logger.warrning("Clean is an abstract method, it should be used as such.")
- def purge(self):
+ def clean(self):
"""Final actions.
All the actions that must be done after the exection of all plugin functions.
@@ -193,31 +193,31 @@ class Plugin(object):
"""
#We want these functions to be overridden by the plugin developer.
if self.__class__ is Plugin:
- raise TypeError, "Plugin is an abstract class."
+ Logger.warrning("Clean is an abstract method, it should be used as such.")
def backup(self):
"""Gather important information needed for restore."""
#We want these functions to be overridden by the plugin developer.
if self.__class__ is Plugin:
- raise TypeError, "Plugin is an abstract class."
+ Logger.warrning("Clean is an abstract method, it should be used as such.")
def restore(self):
"""Try to restore the previous state described in backup."""
#We want these functions to be overridden by the plugin developer.
if self.__class__ is Plugin:
- raise TypeError, "Plugin is an abstract class."
+ Logger.warrning("Clean is an abstract method, it should be used as such.")
def diagnose(self):
"""Diagnose the situation."""
#We want these functions to be overridden by the plugin developer.
if self.__class__ is Plugin:
- raise TypeError, "Plugin is an abstract class."
+ Logger.warrning("Clean is an abstract method, it should be used as such.")
def fix(self):
"""Try to fix whatever is wrong in the system."""
#We want these functions to be overridden by the plugin developer.
if self.__class__ is Plugin:
- raise TypeError, "Plugin is an abstract class."
+ Logger.warrning("Clean is an abstract method, it should be used as such.")
class PluginSystem(object):
"""Encapsulate all plugin detection and import stuff"""