summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xfirstaidkit8
-rw-r--r--plugins/plugin_examples/dep1.py12
-rw-r--r--plugins/plugin_examples/dep2.py12
-rw-r--r--plugins/plugin_examples/dep3.py12
-rw-r--r--plugins/plugin_examples/sample1Plugin.py12
-rw-r--r--plugins/plugin_examples/sample2Plugin.py30
-rw-r--r--plugins/plugin_examples/sample3Plugin/sample3Plugin.py24
-rw-r--r--pyfirstaidkit/configuration.py2
-rw-r--r--pyfirstaidkit/plugins.py32
-rw-r--r--pyfirstaidkit/returns.py52
10 files changed, 97 insertions, 99 deletions
diff --git a/firstaidkit b/firstaidkit
index 8525078..cf84a62 100755
--- a/firstaidkit
+++ b/firstaidkit
@@ -44,6 +44,7 @@ class Output(Thread):
def usage(name):
print """Usage:
%s [params]
+ %s [params] -a
%s [params] -f plugin flow
%s [params] -t plugin task
params is none or more items from:
@@ -63,8 +64,8 @@ def usage(name):
""" % (name, name, name)
if __name__=="__main__":
- params, rest = getopt.getopt(sys.argv[1:], "ftc:r:vl:x:F:g:P:h",
- ["list", "info=", "flow", "task", "config=", "root=", "verbose", "log=", "exclude=",
+ params, rest = getopt.getopt(sys.argv[1:], "aftc:r:vl:x:F:g:P:h",
+ ["list", "info=", "auto", "flow", "task", "config=", "root=", "verbose", "log=", "exclude=",
"flag=", "gui=", "plugin-path=", "print-config", "help"])
#
@@ -77,6 +78,9 @@ if __name__=="__main__":
if key in ("-t", "--task"):
Config.operation.mode = "task"
Flags.main_help = False
+ elif key in ("-a", "--auto"):
+ Config.operation.mode = "auto"
+ Flags.main_help = False
elif key in ("-f", "--flow"):
Config.operation.mode = "flow"
Flags.main_help = False
diff --git a/plugins/plugin_examples/dep1.py b/plugins/plugin_examples/dep1.py
index 0556561..0fe673a 100644
--- a/plugins/plugin_examples/dep1.py
+++ b/plugins/plugin_examples/dep1.py
@@ -31,23 +31,23 @@ class Sample1Plugin(Plugin):
return set(["sample_dependency"]).union(Plugin.getDeps())
def prepare(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def backup(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def restore(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def diagnose(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
self.provide("sample_dependency2")
def fix(self):
- self._result=ReturnUnfavorable
+ self._result=ReturnFailure
def clean(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def get_plugin():
return Sample1Plugin
diff --git a/plugins/plugin_examples/dep2.py b/plugins/plugin_examples/dep2.py
index 3c49b40..e8e8f43 100644
--- a/plugins/plugin_examples/dep2.py
+++ b/plugins/plugin_examples/dep2.py
@@ -31,22 +31,22 @@ class Sample1Plugin(Plugin):
return set(["sample_dependency", "sample_dependency2"]).union(Plugin.getDeps())
def prepare(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def backup(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def restore(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def diagnose(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def fix(self):
- self._result=ReturnUnfavorable
+ self._result=ReturnFailure
def clean(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def get_plugin():
return Sample1Plugin
diff --git a/plugins/plugin_examples/dep3.py b/plugins/plugin_examples/dep3.py
index f3a329c..3da70ea 100644
--- a/plugins/plugin_examples/dep3.py
+++ b/plugins/plugin_examples/dep3.py
@@ -27,23 +27,23 @@ class Sample1Plugin(Plugin):
Plugin.__init__(self, *args, **kwargs)
def prepare(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def backup(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def restore(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def diagnose(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
self.provide("sample_dependency")
def fix(self):
- self._result=ReturnUnfavorable
+ self._result=ReturnFailure
def clean(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def get_plugin():
return Sample1Plugin
diff --git a/plugins/plugin_examples/sample1Plugin.py b/plugins/plugin_examples/sample1Plugin.py
index 8218104..22d033f 100644
--- a/plugins/plugin_examples/sample1Plugin.py
+++ b/plugins/plugin_examples/sample1Plugin.py
@@ -28,27 +28,27 @@ class Sample1Plugin(Plugin):
self.reporting = kwargs.get('reporting')
def prepare(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
self.reporting.info("Sample1Plugin in Prepare task", self)
def backup(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
self.reporting.info("Sample1Plugin in backup task", self)
def restore(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
self.reporting.info("Sample1Plugin in Restore task", self)
def diagnose(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
self.reporting.info("Sample1Plugin in diagnose task", self)
def fix(self):
- self._result=ReturnUnfavorable
+ self._result=ReturnFailure
self.reporting.info("Sample1Plugin in Fix task", self)
def clean(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
self.reporting.info("Sample1Plugin in Clean task", self)
def get_plugin():
diff --git a/plugins/plugin_examples/sample2Plugin.py b/plugins/plugin_examples/sample2Plugin.py
index 4b4764d..5b471e0 100644
--- a/plugins/plugin_examples/sample2Plugin.py
+++ b/plugins/plugin_examples/sample2Plugin.py
@@ -25,14 +25,14 @@ class Sample2Plugin(Plugin):
#
flows = Flow.init(Plugin)
flows["extra"] = Flow({
- Plugin.initial: {ReturnValue: "prepare"},
- "prepare" : {ReturnFavorable: "diagnose"},
- "diagnose" : {ReturnFavorable: "clean", ReturnUnfavorable: "backup"},
- "backup" : {ReturnFavorable: "fix", ReturnUnfavorable: "clean"},
- "restore" : {ReturnFavorable: "clean", ReturnUnfavorable: "clean"},
- "fix" : {ReturnFavorable: "extraStep", ReturnUnfavorable: "restore"},
- "extraStep" : {ReturnFavorable: "clean", ReturnUnfavorable: "clean"},
- "clean" : {ReturnFavorable: Plugin.final}
+ Plugin.initial: {Return: "prepare"},
+ "prepare" : {ReturnSuccess: "diagnose"},
+ "diagnose" : {ReturnSuccess: "clean", ReturnFailure: "backup"},
+ "backup" : {ReturnSuccess: "fix", ReturnFailure: "clean"},
+ "restore" : {ReturnSuccess: "clean", ReturnFailure: "clean"},
+ "fix" : {ReturnSuccess: "extraStep", ReturnFailure: "restore"},
+ "extraStep" : {ReturnSuccess: "clean", ReturnFailure: "clean"},
+ "clean" : {ReturnSuccess: Plugin.final}
}, description="Fixing sequence with one added extraStep")
default_flow = "extra"
@@ -44,25 +44,25 @@ class Sample2Plugin(Plugin):
Plugin.__init__(self, *args, **kwargs)
def prepare(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def clean(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def backup(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def restore(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def diagnose(self):
- self._result=ReturnUnfavorable
+ self._result=ReturnFailure
def fix(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def extraStep(self):
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def get_plugin():
return Sample2Plugin
diff --git a/plugins/plugin_examples/sample3Plugin/sample3Plugin.py b/plugins/plugin_examples/sample3Plugin/sample3Plugin.py
index 5d2e362..e58c8dc 100644
--- a/plugins/plugin_examples/sample3Plugin/sample3Plugin.py
+++ b/plugins/plugin_examples/sample3Plugin/sample3Plugin.py
@@ -36,9 +36,9 @@ class Sample3Plugin(Plugin):
(out, err) = proc.communicate()
out = out.strip()
if out[-5:] == "false":
- self._result=ReturnUnfavorable
+ self._result=ReturnFailure
elif out[-4:] == "true":
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def clean(self):
clean = [Config.plugin.path+"/sample3Plugin/plugin", "--task", "clean"]
@@ -46,9 +46,9 @@ class Sample3Plugin(Plugin):
(out, err) = proc.communicate()
out = out.strip()
if out[-5:] == "false":
- self._result=ReturnUnfavorable
+ self._result=ReturnFailure
elif out[-4:] == "true":
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def backup(self):
backup = [Config.plugin.path+"/sample3Plugin/plugin", "--task", "backup"]
@@ -56,9 +56,9 @@ class Sample3Plugin(Plugin):
(out, err) = proc.communicate()
out = out.strip()
if out[-5:] == "false":
- self._result=ReturnUnfavorable
+ self._result=ReturnFailure
elif out[-4:] == "true":
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def restore(self):
restore = [Config.plugin.path+"/sample3Plugin/plugin", "--task", "restore"]
@@ -66,9 +66,9 @@ class Sample3Plugin(Plugin):
(out, err) = proc.communicate()
out = out.strip()
if out[-5:] == "false":
- self._result=ReturnUnfavorable
+ self._result=ReturnFailure
elif out[-4:] == "true":
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def diagnose(self):
diagnose = [Config.plugin.path+"/sample3Plugin/plugin", "--task", "diagnose"]
@@ -76,9 +76,9 @@ class Sample3Plugin(Plugin):
(out, err) = proc.communicate()
out = out.strip()
if out[-5:] == "false":
- self._result=ReturnUnfavorable
+ self._result=ReturnFailure
elif out[-4:] == "true":
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
def fix(self):
fix = [Config.plugin.path+"/sample3Plugin/plugin", "--task", "fix"]
@@ -86,6 +86,6 @@ class Sample3Plugin(Plugin):
(out, err) = proc.communicate()
out = out.strip()
if out[-5:] == "false":
- self._result=ReturnUnfavorable
+ self._result=ReturnFailure
elif out[-4:] == "true":
- self._result=ReturnFavorable
+ self._result=ReturnSuccess
diff --git a/pyfirstaidkit/configuration.py b/pyfirstaidkit/configuration.py
index 0ccb5b0..dab914f 100644
--- a/pyfirstaidkit/configuration.py
+++ b/pyfirstaidkit/configuration.py
@@ -66,7 +66,7 @@ class FAKConfigSection(object):
raise ConfigParser.NoSectionError(self.__dict__["section_name"])
if not self.__dict__["configuration"].has_option(self.__dict__["section_name"], key):
- raise ConfigParser.NoOptionError(key)
+ raise ConfigParser.NoOptionError(key, self.__dict__["section_name"])
return self.__dict__["configuration"].get(self.__dict__["section_name"], key)
diff --git a/pyfirstaidkit/plugins.py b/pyfirstaidkit/plugins.py
index e7e302c..49386ae 100644
--- a/pyfirstaidkit/plugins.py
+++ b/pyfirstaidkit/plugins.py
@@ -76,16 +76,16 @@ class Plugin(object):
#
# This is the default flow that all classes deriving from plugin must
# have. As the initial state has no return value it will be indexed
- # with the parent of all ReturnValue classes.
+ # with the parent of all Return classes.
#
flows["defflow"] = Flow({
- initial : {ReturnValue: "prepare"},
- "prepare" : {ReturnFavorable: "diagnose"},
- "diagnose" : {ReturnFavorable: "clean", ReturnUnfavorable: "backup"},
- "backup" : {ReturnFavorable: "fix", ReturnUnfavorable: "clean"},
- "fix" : {ReturnFavorable: "clean", ReturnUnfavorable: "restore"},
- "restore" : {ReturnFavorable: "clean", ReturnUnfavorable: "clean"},
- "clean" : {ReturnFavorable: final}
+ initial : {Return: "prepare"},
+ "prepare" : {ReturnSuccess: "diagnose"},
+ "diagnose" : {ReturnSuccess: "clean", ReturnFailure: "backup"},
+ "backup" : {ReturnSuccess: "fix", ReturnFailure: "clean"},
+ "fix" : {ReturnSuccess: "clean", ReturnFailure: "restore"},
+ "restore" : {ReturnSuccess: "clean", ReturnFailure: "clean"},
+ "clean" : {ReturnSuccess: final, ReturnFailure: final}
}, description="The default, fully automated, fixing sequence")
def __init__(self, flow, reporting, dependencies):
@@ -198,10 +198,10 @@ class Plugin(object):
state=self._state
result=self._result
# The self.initial state does not have any return code.
- # It will only work with the ReturnValue.
+ # It will only work with the Return.
try:
if state == self.initial:
- self._state = self.cflow[self.initial][ReturnValue]
+ self._state = self.cflow[self.initial][Return]
else:
self._state = self.cflow[state][result]
return self._state
@@ -307,12 +307,12 @@ class FlagTrackerPlugin(Plugin):
#
# This is the default flow that all classes deriving from plugin must
# have. As the initial state has no return value it will be indexed
- # with the parent of all ReturnValue classes.
+ # with the parent of all Return classes.
#
flows = Flow.init(Plugin)
flows["deflogic"] = Flow({
- Plugin.initial : {ReturnValue: "decide"},
- "decide" : {ReturnValue: Plugin.final}
+ Plugin.initial : {Return: "decide"},
+ "decide" : {Return: Plugin.final}
}, description="The default, fully automated, deciding sequence")
def decide(self):
@@ -323,14 +323,14 @@ class FlagTrackerPlugin(Plugin):
if self.flag_decide is None:
Logger.warning("You have to specify flag to set when everything is ok.")
- return ReturnValue
+ return Return
for flag in self.flag_list:
if not self._dependencies.require(flag):
- return ReturnValue
+ return Return
self._dependencies.provide(self.flag_decide)
- return ReturnValue
+ return Return
class PluginSystem(object):
diff --git a/pyfirstaidkit/returns.py b/pyfirstaidkit/returns.py
index d00042d..614e7a3 100644
--- a/pyfirstaidkit/returns.py
+++ b/pyfirstaidkit/returns.py
@@ -18,58 +18,52 @@
#
# These classes expressed here are to be the keys in the flow dictionary.
-# In most default cases the values are unimportant. They are placed there
+# In most default cases the attributes are unimportant. They are placed there
# for printing or other purposes.
+# Think of those classes as of predefined constants.
+#
-class ReturnValue:
- """Its just a parent class for any Return class that might be create.
-
- The parent has no value.
- """
+class Return:
+ """Its just a parent class for any Return class that might be create."""
def __init__(self):
pass
-class ReturnValueTrue(ReturnValue):
- def __init__(self):
- self.value = True
+class ReturnTrue(Return):
+ pass
-class ReturnValueFalse(ReturnValue):
- def __init__(self):
- self.value = False
+class ReturnFalse(Return):
+ pass
-class ReturnValueNone(ReturnValue):
- def __init__(self):
- self.value = None
+class ReturnNone(Return):
+ pass
#
-# The Favorable and Unfavorable return classes are implemented to give a more
+# The Success and Failure return classes are implemented to give a more
# intuitive/logical approach to the default flow. The value given to the return
# of each task depends on the objectives of the task and of the place where the
# task is situated inside the totality of the flow.
# Examples:
# 1. If the plugin is in the diagnose flow and if found nothing wrong with the
-# system it is analysing, the return value would be Favorable.
+# system it is analysing, the return value would be Success.
# 2. If the plugin is in backup and the backup action is unseccessfull, the
-# proper return value would be Unfavorable. In this Favorable would mean that
+# proper return value would be Failure. In this Success would mean that
# the backup was successfull and the plugin can move toward the fix task.
# 3. If the plugin is in fix stage and the problem was not fixed, the return
-# value should be ResutltNotOk. On the other hand if the fix has been done
-# the return value should be Favorable.
+# value should be Failure. On the other hand if the fix has been done
+# the return value should be Success.
# Remember that the actual values of the classes is not checked, what is checked
-# is that the return value be of a specific class.
+# is that the return value be the specific class.
#
-class ReturnFavorable(ReturnValue):
+class ReturnSuccess(Return):
"""Use whenever the result of a task is positive, expected or offers the
least resistence.
-
"""
- def __init__(self):
- pass
+ pass
-class ReturnUnfavorable(ReturnValue):
+class ReturnFailure(Return):
"""Used whenever the result of a task is not possitive, not expected or
- offerst the most resistence.
+ offers the most resistence.
"""
- def __init__(self):
- pass
+ pass
+