summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Andres Granados <jgranado@redhat.com>2008-07-11 16:40:04 +0200
committerJoel Andres Granados <jgranado@redhat.com>2008-07-14 11:33:13 +0200
commitfdf629196062319bba60fa13c606ed4ba80a41ff (patch)
tree696d0fc36119b954a0d82bc1f20e665e765b7a2a
parentc5c3e6cae831bd2d88358bcb1df63f6bab3c66e6 (diff)
downloadfirstaidkit-fdf629196062319bba60fa13c606ed4ba80a41ff.tar.gz
firstaidkit-fdf629196062319bba60fa13c606ed4ba80a41ff.tar.xz
firstaidkit-fdf629196062319bba60fa13c606ed4ba80a41ff.zip
Fix the format of the firstaidkit file.
- Indendtation should be 4 spaces. There was a function indented with 8 spaces. - Lines should be shorted than 80 chars. It just looks pretty :) Think of terminals whith only 80 char of length. Think of debuging in rescue mode. - Change also the print statements. Just getting ready for python 3000. - Get some spaces between elifs - There should not be any lines ending in spaces. - This can all be read in the python code conventions http://www.python.org/dev/peps/pep-0008/
-rw-r--r--Makefile6
-rwxr-xr-xfirstaidkit189
-rw-r--r--frontend/frontend_gtk.py243
-rw-r--r--plugins/plugin_mdadmconf.py6
-rw-r--r--plugins/plugin_undelete_partitions/Makefile6
-rw-r--r--plugins/plugin_undelete_partitions/__init__.py6
-rw-r--r--plugins/plugin_undelete_partitions/undeletePartition.py10
-rw-r--r--plugins/xserver.py107
-rw-r--r--pyfirstaidkit/FirstAidKit.py6
-rw-r--r--pyfirstaidkit/__init__.py6
-rw-r--r--pyfirstaidkit/configuration.py65
-rw-r--r--pyfirstaidkit/dependency.py11
-rw-r--r--pyfirstaidkit/errors.py16
-rw-r--r--pyfirstaidkit/interpret.py97
-rw-r--r--pyfirstaidkit/issue.py29
-rw-r--r--pyfirstaidkit/plugins.py263
-rw-r--r--pyfirstaidkit/reporting.py56
-rw-r--r--pyfirstaidkit/returns.py9
-rw-r--r--pyfirstaidkit/utils/__init__.py6
-rw-r--r--pyfirstaidkit/utils/backup.py4
-rwxr-xr-xtest16
-rw-r--r--testsuite/__init__.py6
-rw-r--r--testsuite/initialization.py22
-rw-r--r--testsuite/initialization/pluginInfo.py10
24 files changed, 748 insertions, 447 deletions
diff --git a/Makefile b/Makefile
index 06d610b..b7dcd91 100644
--- a/Makefile
+++ b/Makefile
@@ -1,15 +1,15 @@
# First Aid Kit - diagnostic and repair tool for Linux
-#
+#
# 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.
diff --git a/firstaidkit b/firstaidkit
index 3887979..e0abe20 100755
--- a/firstaidkit
+++ b/firstaidkit
@@ -1,17 +1,17 @@
#!/usr/bin/python -tt
# 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.
@@ -45,51 +45,69 @@ class Output(Thread):
self.process_message(message)
def process_message(self, message):
- if message["action"]==reporting.END:
- self._running = False
- return
- elif message["action"]==reporting.QUESTION:
- print "FIXME: Questions not implemented yet"
- elif message["action"]==reporting.START:
- if self._importance<=message["importance"]:
- print "START: %s (%s)" % (message["origin"].name, message["message"])
- self.levelstack.append(message["origin"].name)
- elif message["action"]==reporting.STOP:
- if self._importance<=message["importance"]:
- print "STOP: %s (%s)" % (message["origin"].name, message["message"])
- if self.levelstack[-1]!=message["origin"].name:
- print "WARNING: START/STOP ordering mismatch in stack: "+" / ".join(self.levelstack)
- else:
- self.levelstack.pop()
- elif message["action"]==reporting.PROGRESS:
- if self._importance<=message["importance"]:
- print "PROGRESS: %d of %d (%s)" % (message["message"][0], message["message"][1], message["origin"].name)
- elif message["action"]==reporting.INFO:
- if self._importance<=message["importance"]:
- print "INFO: %s (%s)" % (message["message"], message["origin"].name)
- elif message["action"]==reporting.ALERT:
- if self._importance<=message["importance"]:
- print "ALERT: %s (%s)" % (message["message"], message["origin"].name)
- elif message["action"]==reporting.EXCEPTION:
- print "EXCEPTION: %s (%s)" % (message["message"], message["origin"].name)
- elif message["action"]==reporting.TABLE:
- if self._importance<=message["importance"]:
- print "TABLE %s FROM %s" % (message["title"], message["origin"].name,)
- pprint.pprint(message["message"])
- elif message["action"]==reporting.TREE:
- if self._importance<=message["importance"]:
- print "TREE %s FROM %s" % (message["title"], message["origin"].name,)
- pprint.pprint(message["message"])
- elif message["action"]==reporting.ISSUE:
- print "ISSUE FROM %s" % (message["origin"].name,)
- pprint.pprint(str(message["message"]))
+ if message["action"]==reporting.END:
+ self._running = False
+ return
+ elif message["action"]==reporting.QUESTION:
+ print("FIXME: Questions not implemented yet")
+
+ elif message["action"]==reporting.START:
+ if self._importance<=message["importance"]:
+ print("START: %s (%s)" % (message["origin"].name,
+ message["message"]))
+ self.levelstack.append(message["origin"].name)
+
+ elif message["action"]==reporting.STOP:
+ if self._importance<=message["importance"]:
+ print("STOP: %s (%s)" % (message["origin"].name,
+ message["message"]))
+ if self.levelstack[-1]!=message["origin"].name:
+ print("WARNING: START/STOP ordering mismatch in stack: " \
+ +" / ".join(self.levelstack))
else:
- print "FIXME: Unknown message action %d!!" % (message["action"],)
- print message
-
+ self.levelstack.pop()
+
+ elif message["action"]==reporting.PROGRESS:
+ if self._importance<=message["importance"]:
+ print("PROGRESS: %d of %d (%s)" % (message["message"][0],
+ message["message"][1], message["origin"].name))
+
+ elif message["action"]==reporting.INFO:
+ if self._importance<=message["importance"]:
+ print("INFO: %s (%s)" % (message["message"],
+ message["origin"].name))
+
+ elif message["action"]==reporting.ALERT:
+ if self._importance<=message["importance"]:
+ print("ALERT: %s (%s)" % (message["message"],
+ message["origin"].name))
+
+ elif message["action"]==reporting.EXCEPTION:
+ print("EXCEPTION: %s (%s)" % (message["message"],
+ message["origin"].name))
+
+ elif message["action"]==reporting.TABLE:
+ if self._importance<=message["importance"]:
+ print("TABLE %s FROM %s" % (message["title"],
+ message["origin"].name,))
+ pprint.pprint(message["message"])
+
+ elif message["action"]==reporting.TREE:
+ if self._importance<=message["importance"]:
+ print("TREE %s FROM %s" % (message["title"],
+ message["origin"].name,))
+ pprint.pprint(message["message"])
+
+ elif message["action"]==reporting.ISSUE:
+ print("ISSUE FROM %s" % (message["origin"].name,))
+ pprint.pprint(str(message["message"]))
+ else:
+ print("FIXME: Unknown message action %d!!" % (message["action"],))
+ print(message)
class GuiOutput(Thread):
- def __init__(self, cfg, tasker, dir, importance = logging.INFO, *args, **kwargs):
+ def __init__(self, cfg, tasker, dir, importance = logging.INFO,
+ *args, **kwargs):
Thread.__init__(self, *args, **kwargs)
self.w = MainWindow(cfg, tasker, importance = importance, dir=dir)
@@ -97,7 +115,7 @@ class GuiOutput(Thread):
self.w.run()
def usage(name):
- print """Usage:
+ print("""Usage:
%s [params]
%s [params] -a - runs the automated default mode [diagnose]
%s [params] -a <flow> - runs the automated mode with specified flow
@@ -121,7 +139,7 @@ def usage(name):
--list - list all plugins
--info <plugin> - get information about plugin
--nodeps - do not use plugin dependencies
-""" % (name, name, name, name, name)
+""" % (name, name, name, name, name))
if __name__=="__main__":
try:
@@ -130,58 +148,75 @@ if __name__=="__main__":
"verbose", "log=", "exclude=","flag=", "gui=", "plugin-path=",
"print-config", "help", "flags", "nodeps"])
except Exception, e:
- print "\nError parsing the argument line: ",e,"\n"
+ print("\nError parsing the argument line: ",e,"\n")
usage(sys.argv[0])
sys.exit(1)
- #
# Preliminary checks before we parse the options.
- #
if len(params) == 0:
Flags.main_help = True
for key,val in params:
- if key in ("-t", "--task"): #currently not implemented and not documented!
+ #currently not implemented and not documented!
+ 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
+
elif key in ("-c", "--config"):
Config.read(val)
+
elif key in ("-v", "--verbose"):
Config.operation.verbose = "True"
+
elif key in ("-l", "--log"):
Config.log.method = val
+
elif key in ("-x", "--exclude"):
- Config.plugin.disabled = Config.plugin.disabled + ' "%s"' % (val.encode("string-escape"))
- print "Excluding plugin %s\n" % (val,)
+ Config.plugin.disabled = Config.plugin.disabled + \
+ ' "%s"' % (val.encode("string-escape"))
+ print("Excluding plugin %s\n" % (val,))
+
elif key in ("-F", "--flag"):
- Config.operation.flags = Config.operation.flags + ' "%s"' % (val.encode("string-escape"))
+ Config.operation.flags = Config.operation.flags + \
+ ' "%s"' % (val.encode("string-escape"))
+
elif key in ("-r", "--root"):
Config.system.root = val
+
elif key in ("-g", "--gui"):
Config.operation.gui = val
+
elif key in ("-P", "--plugin-path"):
if not os.path.isdir(val):
- print "%s is not a valid directory. Exiting..."% val
+ print("%s is not a valid directory. Exiting..."% val)
sys.exit(1)
Config.set("paths", val.strip("/"), val)
+
elif key in ("--print-config"):
Flags.print_config = True
+
elif key in ("-h", "--help"):
Config.operation.help = "True"
Flags.main_help = True
+
elif key in ("--flags"):
Config.operation.mode = "flags"
+
elif key in ("--list"):
Config.operation.mode = "list"
+
elif key in ("--info"):
Config.operation.mode = "info"
Config.operation.params = val
+
elif key in ("--nodeps"):
Config.operation.dependencies = "False"
@@ -191,7 +226,7 @@ if __name__=="__main__":
if Config.operation.mode == "flow":
if len(rest) < 1:
- print "Error in the command arguments.\n"
+ print("Error in the command arguments.\n")
usage(sys.argv[0])
sys.exit(1)
Config.operation.plugin = rest[0].encode("string-escape")
@@ -199,10 +234,12 @@ if __name__=="__main__":
Config.operation.mode = "plugin"
else:
Config.operation.flow = rest[1].encode("string-escape")
+
elif Config.operation.mode == "auto":
if len(rest)>0:
Config.operation.mode = "auto-flow"
Config.operation.flow = rest[0].encode("string-escape")
+
elif Config.operation.mode == "task":
Config.operation.plugin = rest[0]
Config.operation.task = rest[1]
@@ -224,12 +261,12 @@ if __name__=="__main__":
# TUI/GUI detection
if not Flags.gui_available and Config.operation.gui=="gtk":
- print "GUI mode not available"
+ print("GUI mode not available")
Config.operation.gui="console"
# TUI has to have operation specified
if Config.operation.mode == "" and Config.operation.gui!="gtk":
- print "\nError in command arguments: no mode specified\n"
+ print("\nError in command arguments: no mode specified\n")
usage(sys.argv[0])
sys.exit(1)
@@ -244,7 +281,7 @@ if __name__=="__main__":
Config.log.filename = lfile
continue
else:
- print e
+ print(e)
usage(sys.argv[0])
sys.exit(1)
@@ -252,33 +289,36 @@ if __name__=="__main__":
try:
singlerun = Tasker(Config, reporting = report)
except BackupException, be:
- print "\nError: %s" % be[0]
- print "\nThis happens when firstaidkit end without properly closing the backup dir. "
- print "If you are sure you don't have sensitive information in that directory, "
- print "you can safely erase it. If you are not sure, just change the "
- print "directory name.\n"
+ print("\nError: %s\n"
+ "This happens when firstaidkit end without properly closing the "
+ "backup dir. If you are sure you don't have sensitive information "
+ "in that directory, you can safely erase it. If you are not sure, "
+ "just change the directory name.\n" % be[0])
sys.exit(1)
if Config.operation.verbose=="False":
outputThread = Output(singlerun.reporting())
if Config.operation.gui=="gtk":
- outputThreadGui = GuiOutput(Config, singlerun, dir = os.path.dirname(frontend_gtk.__file__))
+ outputThreadGui = GuiOutput(Config, singlerun,
+ dir = os.path.dirname(frontend_gtk.__file__))
else:
outputThread = Output(singlerun.reporting(), importance = 0)
if Config.operation.gui=="gtk":
- outputThreadGui = GuiOutput(Config, singlerun, importance = 0, dir = os.path.dirname(frontend_gtk.__file__))
+ outputThreadGui = GuiOutput(Config, singlerun, importance = 0,
+ dir = os.path.dirname(frontend_gtk.__file__))
if Config.operation.gui=="gtk":
singlerun.reporting().notify(outputThreadGui.w.update)
singlerun.reporting().notify(outputThread.process_message)
- print "Starting the Threads"
+ print("Starting the Threads")
#outputThread.start() #not needed, we use the callback method now
if Config.operation.gui=="gtk":
outputThreadGui.start()
- if Config.operation.gui=="console": #XXX change this to detection if GUI is not used (eg. noninteractive mode)
- print "Do the work!"
+ #XXX change this to detection if GUI is not used (eg. noninteractive mode)
+ if Config.operation.gui=="console":
+ print("Do the work!")
# Lock the Configuration
Config.lock()
@@ -286,14 +326,15 @@ if __name__=="__main__":
try:
singlerun.run()
except Exception, e:
- print "!!! Impossible happened!! The First Aid Kit crashed in very unsafe way.\n!!! Please report this to the authors along with the following message.\n\n"
+ print("!!! Impossible happened!! The First Aid Kit crashed in "
+ "very unsafe way.\n!!! Please report this to the authors "
+ "along with the following message.\n\n")
Config.write(sys.stdout)
- print
- print e
+ print("\n%s"% e)
finally:
singlerun.end()
- print "Waiting for the Threads"
+ print("Waiting for the Threads")
#outputThread.join() #not needed, we use the callback method now
if Config.operation.gui=="gtk":
outputThreadGui.join()
@@ -303,4 +344,4 @@ if __name__=="__main__":
del outputThreadGui
del singlerun
- print "Done."
+ print("Done.")
diff --git a/frontend/frontend_gtk.py b/frontend/frontend_gtk.py
index 13925ea..be4ad7d 100644
--- a/frontend/frontend_gtk.py
+++ b/frontend/frontend_gtk.py
@@ -43,7 +43,8 @@ class CallbacksMainWindow(object):
return
def _o(pages, stopbutton):
- """Always return False -> remove from the idle queue after first execution"""
+ """Always return False -> remove from the idle queue after first
+ execution"""
for i in range(pages.get_n_pages()):
pages.get_nth_page(i).set_sensitive(True)
stopbutton.set_sensitive(False)
@@ -67,17 +68,20 @@ class CallbacksMainWindow(object):
#menu callbacks
def on_mainmenu_open_activate(self, widget, *args):
- print "on_mainmenu_open_activate"
- d = gtk.FileChooserDialog(title="Load the configuration file", parent=self._dialog, action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ print("on_mainmenu_open_activate")
+ d = gtk.FileChooserDialog(title="Load the configuration file",
+ parent=self._dialog, action=gtk.FILE_CHOOSER_ACTION_OPEN,
buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
- print d.run()
+ print(d.run())
d.destroy()
return True
def on_mainmenu_save_activate(self, widget, *args):
- print "on_mainmenu_save_activate"
- d = gtk.FileChooserDialog(title="Save the configuration file", parent=self._dialog, action=gtk.FILE_CHOOSER_ACTION_SAVE,
- buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
+ print("on_mainmenu_save_activate")
+ d = gtk.FileChooserDialog(title="Save the configuration file",
+ parent=self._dialog, action=gtk.FILE_CHOOSER_ACTION_SAVE,
+ buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK,
+ gtk.RESPONSE_ACCEPT))
ret=d.run()
if ret==gtk.RESPONSE_ACCEPT:
@@ -92,14 +96,16 @@ class CallbacksMainWindow(object):
return True
def on_quit_activate(self, widget, *args):
- print "on_quit_activate"
- if True: #XXX destroy right now, but warn, in final code we have to wait until plugin finishes
- print "!!! You should wait until the running plugin finishes!!"
+ print("on_quit_activate")
+ #XXX destroy right now, but warn, in final code we have to wait until
+ #plugin finishes
+ if True:
+ print("!!! You should wait until the running plugin finishes!!")
self._dialog.destroy()
return True
def on_destroy(self, widget, *args):
- print "on_destroy"
+ print("on_destroy")
self._tasker.end()
del self._tasker
del self._cfg
@@ -107,14 +113,15 @@ class CallbacksMainWindow(object):
gtk.main_quit()
def on_mainmenu_about_activate(self, widget, *args):
- print "on_mainmenu_about_activate"
- AboutDialog(self._cfg, dir = os.path.dirname(self._glade.relative_file(".")))
+ print("on_mainmenu_about_activate")
+ AboutDialog(self._cfg,
+ dir = os.path.dirname(self._glade.relative_file(".")))
return True
#simple mode callbacks
def on_b_StartSimple_activate(self, widget, *args):
- print "on_b_StartSimple_activate"
-
+ print("on_b_StartSimple_activate")
+
flags = set(self._cfg.operation._list("flags"))
#check fix
@@ -146,16 +153,17 @@ class CallbacksMainWindow(object):
except KeyError, e:
pass
- self._cfg.operation.flags = " ".join(map(lambda x: x.encode("string-escape"), flags))
+ self._cfg.operation.flags = " ".join(
+ map(lambda x: x.encode("string-escape"), flags))
self.execute()
return True
#advanced mode callbacks
def on_b_StartAdvanced_activate(self, widget, *args):
- print "on_b_StartAdvanced_activate"
-
+ print("on_b_StartAdvanced_activate")
+
flags = set(self._cfg.operation._list("flags"))
-
+
#set the auto-flow
self._cfg.operation.mode = "auto-flow"
@@ -191,34 +199,37 @@ class CallbacksMainWindow(object):
else:
self._cfg.operation.dependencies = "False"
- self._cfg.operation.flags = " ".join(map(lambda x: x.encode("string-escape"), flags))
+ self._cfg.operation.flags = " ".join(
+ map(lambda x: x.encode("string-escape"), flags))
self.execute()
return True
#expert mode callbacks
def on_b_FlagsExpert_activate(self, widget, *args):
- print "on_b_FlagsExpert_activate"
- FlagList(self._cfg, self._tasker.flags(), dir = os.path.dirname(self._glade.relative_file(".")))
+ print("on_b_FlagsExpert_activate")
+ FlagList(self._cfg, self._tasker.flags(),
+ dir = os.path.dirname(self._glade.relative_file(".")))
return True
def on_b_InfoExpert_activate(self, widget, *args):
- print "on_b_InfoExpert_activate"
-
+ print("on_b_InfoExpert_activate")
+
path,focus = self._data.plugin_list.get_cursor()
if path is None:
return True
iter = self._data.plugin_list_store.get_iter(path)
pluginname = self._data.plugin_list_store.get_value(iter, 4)
- print "Selected: ", pluginname
+ print("Selected: %s"% pluginname)
- PluginInfo(self._tasker.pluginsystem().getplugin(pluginname), dir = os.path.dirname(self._glade.relative_file(".")))
+ PluginInfo(self._tasker.pluginsystem().getplugin(pluginname),
+ dir = os.path.dirname(self._glade.relative_file(".")))
return True
def on_b_StartExpert_activate(self, widget, *args):
- print "on_b_StartExpert_activate"
+ print("on_b_StartExpert_activate")
#check verbose
if self._glade.get_widget("check_Expert_Verbose").get_active():
@@ -245,9 +256,11 @@ class CallbacksMainWindow(object):
for pname,iter in self._data.plugin_iter.iteritems():
childiter = self._data.plugin_list_store.iter_children(iter)
while childiter is not None:
- if self._data.plugin_list_store.get_value(childiter, 0): #checkbox is checked
+ #checkbox is checked
+ if self._data.plugin_list_store.get_value(childiter, 0):
plugins.append(pname)
- flows.append(self._data.plugin_list_store.get_value(childiter, 1))
+ flows.append(self._data.plugin_list_store.get_value(
+ childiter, 1))
childiter = self._data.plugin_list_store.iter_next(childiter)
plugins = map(lambda x: x.encode("string-escape"), plugins)
@@ -263,14 +276,14 @@ class CallbacksMainWindow(object):
#results callbacks
def on_b_ResetResults_activate(self, widget, *args):
- print "on_b_ResetResults_activate"
+ print("on_b_ResetResults_activate")
self._data.result_list_store.clear()
del self._data.result_list_iter
self._data.result_list_iter = dict()
return True
def on_b_StopResults_activate(self, widget, *args):
- print "on_b_StopResults_activate"
+ print("on_b_StopResults_activate")
self._tasker.interrupt()
return True
@@ -281,7 +294,7 @@ class CallbacksFlagList(object):
self._cfg = cfg
def on_b_OK_activate(self, widget, *args):
- print "on_b_OK_activate"
+ print("on_b_OK_activate")
f = set()
for k,w in self._flags.iteritems():
@@ -291,13 +304,14 @@ class CallbacksFlagList(object):
if len(f)==0:
self._cfg.operation.flags = ""
else:
- self._cfg.operation.flags = " ".join(map(lambda x: x.encode("string-escape"), f))
+ self._cfg.operation.flags = " ".join(
+ map(lambda x: x.encode("string-escape"), f))
self._dialog.destroy()
return True
def on_b_Cancel_activate(self, widget, *args):
- print "on_b_Cancel_activate"
+ print("on_b_Cancel_activate")
self._dialog.destroy()
return True
@@ -305,9 +319,11 @@ class MainWindow(object):
def __init__(self, cfg, tasker, importance = logging.INFO, dir=""):
self._importance = importance
self._cfg = cfg
- self._glade = gtk.glade.XML(os.path.join(dir, "firstaidkit.glade"), "MainWindow")
+ self._glade = gtk.glade.XML(os.path.join(dir, "firstaidkit.glade"),
+ "MainWindow")
self._window = self._glade.get_widget("MainWindow")
- self._cb = CallbacksMainWindow(self._window, cfg, tasker, self._glade, self)
+ self._cb = CallbacksMainWindow(self._window, cfg, tasker, self._glade,
+ self)
self._glade.signal_autoconnect(self._cb)
self._window.connect("destroy", self._cb.on_destroy)
@@ -315,7 +331,9 @@ class MainWindow(object):
self.status_text = self._glade.get_widget("status_text")
self.status_progress = self._glade.get_widget("status_progress")
- self.plugin_list_store = gtk.TreeStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
+ self.plugin_list_store = gtk.TreeStore(gobject.TYPE_BOOLEAN,
+ gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,
+ gobject.TYPE_STRING)
self.plugin_list = self._glade.get_widget("tree_Expert")
self.plugin_list.set_model(self.plugin_list_store)
@@ -324,26 +342,33 @@ class MainWindow(object):
self.plugin_rend_toggle.set_radio(False)
self.plugin_rend_toggle.set_property("activatable", False)
- def plugin_rend_text_func(column, cell_renderer, tree_model, iter, user_data):
+ def plugin_rend_text_func(column, cell_renderer, tree_model, iter,
+ user_data):
if tree_model.iter_depth(iter)==0:
cell_renderer.set_property("cell-background-set", True)
- cell_renderer.set_property("cell-background-gdk", gtk.gdk.Color(red=50000, green=50000, blue=50000))
- cell_renderer.set_property("markup", "<b>" + tree_model.get_value(iter, user_data) + "</b>")
+ cell_renderer.set_property("cell-background-gdk",
+ gtk.gdk.Color(red=50000, green=50000, blue=50000))
+ cell_renderer.set_property("markup",
+ "<b>" + tree_model.get_value(iter, user_data) + "</b>")
else:
cell_renderer.set_property("cell-background-set", False)
- cell_renderer.set_property("text", tree_model.get_value(iter, user_data))
+ cell_renderer.set_property("text",
+ tree_model.get_value(iter, user_data))
return
- def plugin_rend_toggle_func(column, cell_renderer, tree_model, iter, user_data = None):
+ def plugin_rend_toggle_func(column, cell_renderer, tree_model, iter,
+ user_data = None):
if tree_model.iter_depth(iter)==0:
cell_renderer.set_property("activatable", False)
cell_renderer.set_property("active", False)
cell_renderer.set_property("visible", False)
cell_renderer.set_property("cell-background-set", True)
- cell_renderer.set_property("cell-background-gdk", gtk.gdk.Color(red=40000, green=40000, blue=40000))
+ cell_renderer.set_property("cell-background-gdk",
+ gtk.gdk.Color(red=40000, green=40000, blue=40000))
else:
cell_renderer.set_property("activatable", True)
- cell_renderer.set_property("active", tree_model.get_value(iter,0))
+ cell_renderer.set_property("active",
+ tree_model.get_value(iter,0))
cell_renderer.set_property("visible", True)
cell_renderer.set_property("cell-background-set", False)
return
@@ -355,20 +380,25 @@ class MainWindow(object):
self.plugin_list_col_0 = gtk.TreeViewColumn('Use')
self.plugin_list_col_0.pack_start(self.plugin_rend_toggle, False)
- self.plugin_list_col_0.set_cell_data_func(self.plugin_rend_toggle, plugin_rend_toggle_func)
- self.plugin_rend_toggle.connect("toggled", plugin_rend_toggle_cb, (self.plugin_list_store, 0))
+ self.plugin_list_col_0.set_cell_data_func(self.plugin_rend_toggle,
+ plugin_rend_toggle_func)
+ self.plugin_rend_toggle.connect("toggled", plugin_rend_toggle_cb,
+ (self.plugin_list_store, 0))
self.plugin_list_col_1 = gtk.TreeViewColumn('Name')
self.plugin_list_col_1.pack_start(self.plugin_rend_text, True)
- self.plugin_list_col_1.set_cell_data_func(self.plugin_rend_text, plugin_rend_text_func, 1)
+ self.plugin_list_col_1.set_cell_data_func(self.plugin_rend_text,
+ plugin_rend_text_func, 1)
self.plugin_list_col_2 = gtk.TreeViewColumn('Description')
self.plugin_list_col_2.pack_start(self.plugin_rend_text, True)
- self.plugin_list_col_2.set_cell_data_func(self.plugin_rend_text, plugin_rend_text_func, 2)
+ self.plugin_list_col_2.set_cell_data_func(self.plugin_rend_text,
+ plugin_rend_text_func, 2)
self.plugin_list_col_3 = gtk.TreeViewColumn('Parameters')
self.plugin_list_col_3.pack_start(self.plugin_rend_text, True)
- self.plugin_list_col_3.set_cell_data_func(self.plugin_rend_text, plugin_rend_text_func, 3)
+ self.plugin_list_col_3.set_cell_data_func(self.plugin_rend_text,
+ plugin_rend_text_func, 3)
self.plugin_list.append_column(self.plugin_list_col_0)
self.plugin_list.append_column(self.plugin_list_col_1)
@@ -383,7 +413,9 @@ class MainWindow(object):
#flow combobox
for plname in pluginsystem.list():
p = pluginsystem.getplugin(plname)
- piter = self.plugin_list_store.append(None, [False, "%s (%s)" % (p.name, p.version), p.description, "", plname])
+ piter = self.plugin_list_store.append(None,
+ [False, "%s (%s)" % (p.name, p.version), p.description,
+ "", plname])
self.plugin_iter[plname] = piter
for n,d in [ (f, p.getFlow(f).description) for f in p.getFlows() ]:
self.plugin_list_store.append(piter, [False, n, d, "", plname])
@@ -403,12 +435,14 @@ class MainWindow(object):
self.flow_list.set_active(self.flow_list_store_diagnose)
# results
- self.result_list_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_INT)
+ self.result_list_store = gtk.ListStore(gobject.TYPE_STRING,
+ gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_INT)
self.result_list = self._glade.get_widget("tree_Results")
self.result_list.set_model(self.result_list_store)
self.result_list_iter = {}
-
- def result_rend_text_func(column, cell_renderer, tree_model, iter, user_data):
+
+ def result_rend_text_func(column, cell_renderer, tree_model, iter,
+ user_data):
colors = [
gtk.gdk.Color(red=50000, green=50000, blue=50000),
gtk.gdk.Color(red=10000, green=50000, blue=10000),
@@ -422,26 +456,31 @@ class MainWindow(object):
if user_data==2 and state!=2:
cell_renderer.set_property("foreground-set", True)
- cell_renderer.set_property("foreground-gdk", gtk.gdk.Color(red=40000, green=40000, blue=40000))
+ cell_renderer.set_property("foreground-gdk",
+ gtk.gdk.Color(red=40000, green=40000, blue=40000))
else:
cell_renderer.set_property("foreground-set", False)
- cell_renderer.set_property("text", tree_model.get_value(iter, user_data))
+ cell_renderer.set_property("text",
+ tree_model.get_value(iter, user_data))
return
-
+
self.result_rend_text = gtk.CellRendererText()
-
+
self.result_list_col_0 = gtk.TreeViewColumn('Name')
self.result_list_col_0.pack_start(self.result_rend_text, True)
- self.result_list_col_0.set_cell_data_func(self.result_rend_text, result_rend_text_func, 0)
+ self.result_list_col_0.set_cell_data_func(self.result_rend_text,
+ result_rend_text_func, 0)
self.result_list_col_1 = gtk.TreeViewColumn('Status')
self.result_list_col_1.pack_start(self.result_rend_text, True)
- self.result_list_col_1.set_cell_data_func(self.result_rend_text, result_rend_text_func, 1)
+ self.result_list_col_1.set_cell_data_func(self.result_rend_text,
+ result_rend_text_func, 1)
self.result_list_col_2 = gtk.TreeViewColumn('Description')
self.result_list_col_2.pack_start(self.result_rend_text, True)
- self.result_list_col_2.set_cell_data_func(self.result_rend_text, result_rend_text_func, 2)
+ self.result_list_col_2.set_cell_data_func(self.result_rend_text,
+ result_rend_text_func, 2)
self.result_list_col_3 = gtk.TreeViewColumn('Status ID')
self.result_list_col_3.pack_start(self.result_rend_text, True)
@@ -456,7 +495,8 @@ class MainWindow(object):
def update(self, message):
def _o(func, *args, **kwargs):
- """Always return False -> remove from the idle queue after first execution"""
+ """Always return False -> remove from the idle queue after first
+ execution"""
func(*args, **kwargs)
return False
@@ -476,57 +516,86 @@ class MainWindow(object):
else:
self._importance = logging.INFO
- """Read the reporting system message and schedule a call to update stuff in the gui using gobject.idle_add(_o, func, params...)"""
+ """Read the reporting system message and schedule a call to update
+ stuff in the gui using gobject.idle_add(_o, func, params...)"""
if message["action"]==reporting.END:
gobject.idle_add(_o, self._window.destroy)
+
elif message["action"]==reporting.QUESTION:
- print "FIXME: Questions not implemented yet"
+ print("FIXME: Questions not implemented yet")
+
elif message["action"]==reporting.START:
if self._importance<=message["importance"]:
ctx = self.status_text.get_context_id(message["origin"].name)
- gobject.idle_add(_o, self.status_text.push, ctx, "START: %s (%s)" % (message["origin"].name, message["message"]))
+ gobject.idle_add(_o, self.status_text.push, ctx,
+ "START: %s (%s)" % (message["origin"].name,
+ message["message"]))
+
elif message["action"]==reporting.STOP:
if self._importance<=message["importance"]:
ctx = self.status_text.get_context_id(message["origin"].name)
- gobject.idle_add(_o, self.status_text.push, ctx, "STOP: %s (%s)" % (message["origin"].name, message["message"]))
+ gobject.idle_add(_o, self.status_text.push, ctx,
+ "STOP: %s (%s)" % (message["origin"].name,
+ message["message"]))
+
elif message["action"]==reporting.PROGRESS:
if self._importance<=message["importance"]:
if message["message"] is None:
gobject.idle_add(self.status_progress.hide)
else:
- gobject.idle_add(_o, self.status_progress.set_text, "%d/%d - %s" % (message["message"][0], message["message"][1], message["origin"].name))
- gobject.idle_add(_o, self.status_progress.set_fraction, float(message["message"][0])/message["message"][1])
+ gobject.idle_add(_o, self.status_progress.set_text,
+ "%d/%d - %s" % (message["message"][0],
+ message["message"][1], message["origin"].name))
+ gobject.idle_add(_o, self.status_progress.set_fraction,
+ float(message["message"][0])/message["message"][1])
gobject.idle_add(_o, self.status_progress.show)
+
elif message["action"]==reporting.INFO:
if self._importance<=message["importance"]:
ctx = self.status_text.get_context_id(message["origin"].name)
- gobject.idle_add(_o, self.status_text.push, ctx, "INFO: %s (%s)" % (message["message"], message["origin"].name))
+ gobject.idle_add(_o, self.status_text.push, ctx,
+ "INFO: %s (%s)" % (message["message"],
+ message["origin"].name))
+
elif message["action"]==reporting.ALERT:
if self._importance<=message["importance"]:
ctx = self.status_text.get_context_id(message["origin"].name)
- gobject.idle_add(_o, self.status_text.push, ctx, "ALERT: %s (%s)" % (message["message"], message["origin"].name))
+ gobject.idle_add(_o, self.status_text.push, ctx,
+ "ALERT: %s (%s)" % (message["message"],
+ message["origin"].name))
+
elif message["action"]==reporting.EXCEPTION:
ctx = self.status_text.get_context_id(message["origin"].name)
- gobject.idle_add(_o, self.status_text.push, ctx, "EXCEPTION: %s (%s)" % (message["message"], message["origin"].name))
+ gobject.idle_add(_o, self.status_text.push, ctx,
+ "EXCEPTION: %s (%s)" % (message["message"],
+ message["origin"].name))
+
elif message["action"]==reporting.TABLE:
if self._importance<=message["importance"]:
- print "TABLE %s FROM %s" % (message["title"], message["origin"].name,)
+ print("TABLE %s FROM %s" % (message["title"],
+ message["origin"].name,))
pprint.pprint(message["message"])
+
elif message["action"]==reporting.TREE:
if self._importance<=message["importance"]:
- print "TREE %s FROM %s" % (message["title"], message["origin"].name,)
+ print("TREE %s FROM %s" % (message["title"],
+ message["origin"].name,))
pprint.pprint(message["message"])
+
elif message["action"]==reporting.ISSUE:
i = message["message"]
t,ids = issue_state(i)
if not self.result_list_iter.has_key(i):
- self.result_list_iter[i] = self.result_list_store.append([i.name, t, i.description, ids])
+ self.result_list_iter[i] = self.result_list_store.append(
+ [i.name, t, i.description, ids])
else:
for idx,val in enumerate([i.name, t, i.description, ids]):
- gobject.idle_add(_o, self.result_list_store.set, self.result_list_iter[i], idx, val)
+ gobject.idle_add(_o, self.result_list_store.set,
+ self.result_list_iter[i], idx, val)
+
else:
- print "FIXME: Unknown message action %d!!" % (message["action"],)
- print message
+ print("FIXME: Unknown message action %d!!" % (message["action"],))
+ print(message)
def run(self):
gtk.gdk.threads_init()
@@ -534,7 +603,8 @@ class MainWindow(object):
class FlagList(object):
def __init__(self, cfg, flags, dir=""):
- self._glade = gtk.glade.XML(os.path.join(dir, "firstaidkit.glade"), "FlagList")
+ self._glade = gtk.glade.XML(os.path.join(dir, "firstaidkit.glade"),
+ "FlagList")
self._window = self._glade.get_widget("FlagList")
self._window.set_modal(True)
self.flags = {}
@@ -558,7 +628,8 @@ class AboutDialog(object):
self._window.destroy()
def __init__(self, cfg, dir=""):
- self._glade = gtk.glade.XML(os.path.join(dir, "firstaidkit.glade"), "AboutDialog")
+ self._glade = gtk.glade.XML(os.path.join(dir, "firstaidkit.glade"),
+ "AboutDialog")
self._window = self._glade.get_widget("AboutDialog")
self._window.connect("response", self.close)
@@ -581,14 +652,15 @@ class PluginInfo(object):
self._window.destroy()
def __init__(self, plugin, dir=""):
- self._glade = gtk.glade.XML(os.path.join(dir, "firstaidkit.glade"), "PluginInfo")
+ self._glade = gtk.glade.XML(os.path.join(dir, "firstaidkit.glade"),
+ "PluginInfo")
self._window = self._glade.get_widget("PluginInfo")
self._window.set_modal(True)
self._window.set_title(self._window.get_title()+plugin.name)
self._close = self._glade.get_widget("CloseButton")
self._close.connect("clicked", self.close)
-
+
self._name = self._glade.get_widget("Info_name")
self._name.set_label(plugin.name)
@@ -600,10 +672,11 @@ class PluginInfo(object):
self._description = self._glade.get_widget("Info_description")
self._description.set_label(plugin.description)
-
+
self._table = self._glade.get_widget("Table")
- for n,d in [ (f, plugin.getFlow(f).description) for f in plugin.getFlows() ]:
+ for n,d in [ (f, plugin.getFlow(f).description)
+ for f in plugin.getFlows() ]:
if n==plugin.default_flow:
lname = gtk.Label("<b>"+n+"</b>")
lname.set_property("use-markup", True)
@@ -618,9 +691,11 @@ class PluginInfo(object):
sx = self._table.get_property("n-columns")
sy += 1
self._table.resize(sy, sx)
- self._table.attach(lname, 0, 1, sy-1, sy, yoptions = gtk.FILL, xoptions = gtk.FILL)
+ self._table.attach(lname, 0, 1, sy-1, sy, yoptions = gtk.FILL,
+ xoptions = gtk.FILL)
lname.set_alignment(0, 0)
- self._table.attach(ldesc, 1, 2, sy-1, sy, yoptions = gtk.FILL, xoptions = gtk.FILL)
+ self._table.attach(ldesc, 1, 2, sy-1, sy, yoptions = gtk.FILL,
+ xoptions = gtk.FILL)
ldesc.set_alignment(0, 0)
diff --git a/plugins/plugin_mdadmconf.py b/plugins/plugin_mdadmconf.py
index cc55341..5c2b638 100644
--- a/plugins/plugin_mdadmconf.py
+++ b/plugins/plugin_mdadmconf.py
@@ -1,16 +1,16 @@
# First Aid Kit - diagnostic and repair tool for Linux
# Copyright (C) 2008 Joel Andres Granados <jgranado@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.
diff --git a/plugins/plugin_undelete_partitions/Makefile b/plugins/plugin_undelete_partitions/Makefile
index 1b615be..a9ef6cc 100644
--- a/plugins/plugin_undelete_partitions/Makefile
+++ b/plugins/plugin_undelete_partitions/Makefile
@@ -2,17 +2,17 @@
#
# First Aid Kit - diagnostic and repair tool for Linux
# Copyright (C) 2008 Joel Andres Granados <jgranado@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.
diff --git a/plugins/plugin_undelete_partitions/__init__.py b/plugins/plugin_undelete_partitions/__init__.py
index cae0a96..b3402ea 100644
--- a/plugins/plugin_undelete_partitions/__init__.py
+++ b/plugins/plugin_undelete_partitions/__init__.py
@@ -1,16 +1,16 @@
# First Aid Kit - diagnostic and repair tool for Linux
# Copyright (C) 2008 Joel Andres Granados <jgranado@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.
diff --git a/plugins/plugin_undelete_partitions/undeletePartition.py b/plugins/plugin_undelete_partitions/undeletePartition.py
index ca5f1b7..47566d2 100644
--- a/plugins/plugin_undelete_partitions/undeletePartition.py
+++ b/plugins/plugin_undelete_partitions/undeletePartition.py
@@ -1,16 +1,16 @@
# First Aid Kit - diagnostic and repair tool for Linux
# Copyright (C) 2008 Joel Andres Granados <jgranado@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.
@@ -26,7 +26,7 @@ class UndeletePartition(Plugin):
Uses parted libriary to search for partitions that are not included in
the partition table of a disk. If it is possible, this plugin will put
- the partition back into the parition table so it is visible to the
+ the partition back into the parition table so it is visible to the
system again.
"""
@@ -48,7 +48,7 @@ class UndeletePartition(Plugin):
# Dictionary that will hold the partitions that are not included in the
# partition table of a certain disk and can be recovered. It will also
- # house the initial partition table and the partition table that is a
+ # house the initial partition table and the partition table that is a
# result of running the fix. The structure is:
# slef.disks={diskname: [ [recoverables], initialPT, finalPT ], .... }
self.disks = {}
diff --git a/plugins/xserver.py b/plugins/xserver.py
index 4518965..02659da 100644
--- a/plugins/xserver.py
+++ b/plugins/xserver.py
@@ -1,16 +1,16 @@
# First Aid Kit - diagnostic and repair tool for Linux
# Copyright (C) 2008 Joel Andres Granados <jgranado@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.
@@ -37,14 +37,14 @@ class Xserver(Plugin):
""" Plugin to detect an rescue faulty xserver configurations. """
flows = Flow.init(Plugin)
flows["force"] = Flow({
- Plugin.initial: {Return: "prepare"},
- "prepare" : {ReturnSuccess: "diagnose2"},
- "diagnose2" : {ReturnSuccess: "clean", ReturnFailure: "backup"},
- "backup" : {ReturnSuccess: "fix", ReturnFailure: "clean"},
- "restore" : {ReturnSuccess: "clean", ReturnFailure: "clean"},
- "fix" : {ReturnSuccess: "clean", ReturnFailure: "restore"},
- "clean" : {ReturnSuccess: Plugin.final}
- }, description="This flow skips the search for the xserver lock file")
+ Plugin.initial: {Return: "prepare"},
+ "prepare" : {ReturnSuccess: "diagnose2"},
+ "diagnose2" : {ReturnSuccess: "clean", ReturnFailure: "backup"},
+ "backup" : {ReturnSuccess: "fix", ReturnFailure: "clean"},
+ "restore" : {ReturnSuccess: "clean", ReturnFailure: "clean"},
+ "fix" : {ReturnSuccess: "clean", ReturnFailure: "restore"},
+ "clean" : {ReturnSuccess: Plugin.final}
+ }, description="This flow skips the search for the xserver lock file")
name = "X server"
version = "0.0.1"
author = "Joel Andres Granados"
@@ -64,80 +64,104 @@ class Xserver(Plugin):
def prepare(self):
# Nothing to prepare really.
self._result = ReturnSuccess
- self._issue.set(reporting = self._reporting, level = PLUGIN, origin = self)
+ self._issue.set(reporting = self._reporting, level = PLUGIN,
+ origin = self)
def diagnose(self):
# Lets see if there is a server active.
if os.path.exists("/tmp/.X0-lock"):
- self._reporting.info("An X server is already running.", level = PLUGIN, origin = self)
- self._reporting.info("You can run the \"force\" flow to avoud this check. In some cases it works.",
+ self._reporting.info("An X server is already running.",
+ level = PLUGIN, origin = self)
+ self._reporting.info("You can run the \"force\" flow to \
+ avoud this check. In some cases it works.",
level = PLUGIN, origin = self)
self._result = ReturnSuccess
elif self.serverStart():
- self._reporting.info("Everything seems ok with the X server.", level = PLUGIN, origin = self)
+ self._reporting.info("Everything seems ok with the X server.",
+ level = PLUGIN, origin = self)
self._result = ReturnSuccess
elif not os.path.exists(self.confPath):
- # If the configuration is not there dont even bother to try fixing it.
- # This will go through the proces of trying to fix it. at least we told the user.
- self._reporting.info("The error is in the xservers autodetection mechanism, this does not have an automated solution yet.",
+ # If the configuration is not there dont even bother to try
+ #fixing it. This will go through the proces of trying to fix
+ #it. at least we told the user.
+ self._reporting.info("The error is in the xservers autodetection \
+ mechanism, this does not have an automated solution yet.",
level = PLUGIN, origin = self)
self._result = ReturnFailure
else:
- self._reporting.info("X server is missconfigured.", level = PLUGIN, origin = self)
+ self._reporting.info("X server is missconfigured.", level = PLUGIN,
+ origin = self)
self._result = ReturnFailure
- self._issue.set(checked = True, happened = (self._result == ReturnFailure), reporting = self._reporting, level = PLUGIN, origin = self)
+ self._issue.set(checked = True,
+ happened = (self._result == ReturnFailure),
+ reporting = self._reporting, level = PLUGIN, origin = self)
def diagnose2(self):
"""Just a diagnose without the lock check"""
if self.serverStart():
- self._reporting.info("Everything seems ok with the X server.", level = PLUGIN, origin = self)
+ self._reporting.info("Everything seems ok with the X server.",
+ level = PLUGIN, origin = self)
self._result = ReturnSuccess
elif not os.path.exists(self.confPath):
# If the configuration is not there dont even bother to try fixing it.
- # This will go through the proces of trying to fix it. at least we told the user.
- self._reporting.info("The error is in the xservers autodetection mechanism, this does not have an automated solution yet.",
+ # This will go through the proces of trying to fix it. at least we
+ #told the user.
+ self._reporting.info("The error is in the xservers autodetection \
+ mechanism, this does not have an automated solution yet.",
level = PLUGIN, origin = self)
self._result = ReturnFailure
else:
- self._reporting.info("X server is missconfigured.", level = PLUGIN, origin = self)
+ self._reporting.info("X server is missconfigured.", level = PLUGIN,
+ origin = self)
self._result = ReturnFailure
- self._issue.set(checked = True, happened = (self._result == ReturnFailure), reporting = self._reporting, level = PLUGIN, origin = self)
+ self._issue.set(checked = True,
+ happened = (self._result == ReturnFailure),
+ reporting = self._reporting, level = PLUGIN, origin = self)
def backup(self):
if os.path.isfile(self.confPath):
self.backupSpace.backupPath(self.confPath)
else:
- self._reporting.info("%s does not exist." % self.confPath, level = PLUGIN, origin = self)
+ self._reporting.info("%s does not exist." % self.confPath,
+ level = PLUGIN, origin = self)
self._result = ReturnSuccess
def fix(self):
- self._reporting.info("Starting the fix task.", level = PLUGIN, origin = self)
- # With the current xorg server the only thing that we need to do is to erase the conf file.
+ self._reporting.info("Starting the fix task.", level = PLUGIN,
+ origin = self)
+ # With the current xorg server the only thing that we need to do is to
+ # erase the conf file.
if os.path.exists(self.confPath):
os.remove(self.confPath)
- self._reporting.info("Testing modified environment", level = PLUGIN, origin = self)
+ self._reporting.info("Testing modified environment", level = PLUGIN,
+ origin = self)
if self.serverStart():
- self._reporting.info("X server started successfully with new file.", level = PLUGIN, origin = self)
+ self._reporting.info("X server started successfully with new file.",
+ level = PLUGIN, origin = self)
self._result = ReturnSuccess
else:
- self._reporting.info("X server is still missconfigured with new file.", level = PLUGIN, origin = self)
+ self._reporting.info("X server is still missconfigured with new \
+ file.", level = PLUGIN, origin = self)
self._result = ReturnFailure
- self._issue.set(fixed = (self._result == ReturnSuccess), reporting = self._reporting, level = PLUGIN, origin = self)
+ self._issue.set(fixed = (self._result == ReturnSuccess),
+ reporting = self._reporting, level = PLUGIN, origin = self)
def restore(self):
if not self.backupSpace.exists(path=self.confPath):
# This is the case where there is no config file.
- self._reporting.info("The backedup file was not present. Assuming that xorg did not have a config file to begin with.",
+ self._reporting.info("The backedup file was not present. Assuming \
+ that xorg did not have a config file to begin with.",
level = PLUGIN, origin = self)
else:
- self._reporting.info("Restoring original file.", level = PLUGIN , origin = self)
+ self._reporting.info("Restoring original file.", level = PLUGIN ,
+ origin = self)
self.backupSpace.restoreName(self.confPath)
self._result = ReturnSuccess
@@ -147,19 +171,24 @@ class Xserver(Plugin):
def serverStart(self):
- self._reporting.info("Trying to start X server", level = PLUGIN, origin = self)
+ self._reorting.info("Trying to start X server", level = PLUGIN,
+ origin = self)
xorgargs = [self.display]
try:
- proc = spawnvch(executable = "/usr/bin/Xorg", args = xorgargs, chroot = Config.system.root)
- self._reporting.info("Waiting for the X server to start...", level = PLUGIN, origin = self)
+ proc = spawnvch(executable = "/usr/bin/Xorg", args = xorgargs,
+ chroot = Config.system.root)
+ self._reporting.info("Waiting for the X server to start...",
+ level = PLUGIN, origin = self)
time.sleep(5)
if proc.poll() is not None:
# process has terminated, failed.
raise OSError
except:
- self._reporting.info("The X server has failed to start", level = PLUGIN, origin = self)
+ self._reporting.info("The X server has failed to start",
+ level = PLUGIN, origin = self)
return False
- self._reporting.info("The X server has started successfully", level = PLUGIN, origin = self)
+ self._reporting.info("The X server has started successfully",
+ level = PLUGIN, origin = self)
os.kill(proc.pid, signal.SIGINT)
return True
diff --git a/pyfirstaidkit/FirstAidKit.py b/pyfirstaidkit/FirstAidKit.py
index 44d6775..b8eb726 100644
--- a/pyfirstaidkit/FirstAidKit.py
+++ b/pyfirstaidkit/FirstAidKit.py
@@ -1,16 +1,16 @@
# 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.
diff --git a/pyfirstaidkit/__init__.py b/pyfirstaidkit/__init__.py
index e7409b0..2468ddb 100644
--- a/pyfirstaidkit/__init__.py
+++ b/pyfirstaidkit/__init__.py
@@ -1,16 +1,16 @@
# 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.
diff --git a/pyfirstaidkit/configuration.py b/pyfirstaidkit/configuration.py
index feb0b46..4ad74f3 100644
--- a/pyfirstaidkit/configuration.py
+++ b/pyfirstaidkit/configuration.py
@@ -1,16 +1,16 @@
# 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.
@@ -23,7 +23,8 @@ from shlex import shlex
if os.environ.has_key("FIRST_AID_KIT_CONF"):
cfgfile = os.environ["FIRST_AID_KIT_CONF"].split(":")
else:
- cfgfile = ["/etc/firstaidkit/firstaidkit.conf", os.environ["HOME"]+"/.firstaidkit.conf"]
+ cfgfile = ["/etc/firstaidkit/firstaidkit.conf",
+ os.environ["HOME"]+"/.firstaidkit.conf"]
def createDefaultConfig(config):
@@ -54,17 +55,21 @@ def createDefaultConfig(config):
config.system.configuration = "/etc/firstaidkit"
# Frontend modules are in specified directories
- config.system.frontend = "'/usr/lib64/firstaidkit/frontend' '/usr/lib/firstaidkit/frontend'"
+ config.system.frontend = "'/usr/lib64/firstaidkit/frontend' \
+ '/usr/lib/firstaidkit/frontend'"
#
- # There will be 4 default places where FAK will look for plugins, these 4 names
- # will be reserved in the configuration. lib{,64}-firstaidkit-{,examples}
+ # There will be 4 default places where FAK will look for plugins,
+ # these 4 names will be reserved in the configuration.
+ # lib{,64}-firstaidkit-{,examples}
#
config.add_section("paths")
for dir in ["firstaidkit/plugins", "firstaidkit/plugins/examples"]:
for root in [ "usr/lib64", "usr/lib"]:
if os.path.exists( "/%s/%s" % (root,dir)):
- config.set( "paths", "%s/%s"%(dir[19:], root[4]),"/%s/%s" %(root, dir) )
+
+ config.set( "paths", "%s/%s"%(dir[19:], root[4]),
+ "/%s/%s" %(root, dir) )
class LockedError(Exception):
@@ -85,21 +90,33 @@ class FAKConfigSection(object):
self.__dict__["__use_lock"] = False
def __getattr__(self, key):
- if not self.__dict__["__configuration"].has_section(self.__dict__["__section_name"]) and self.__dict__["__section_name"]!="DEFAULT":
+ if not self.__dict__["__configuration"]. \
+ has_section(self.__dict__["__section_name"]) and \
+ self.__dict__["__section_name"]!="DEFAULT":
+
raise ConfigParser.NoSectionError(self.__dict__["__section_name"])
- if not self.__dict__["__configuration"].has_option(self.__dict__["__section_name"], key):
- raise ConfigParser.NoOptionError(key, self.__dict__["__section_name"])
+ if not self.__dict__["__configuration"]. \
+ has_option(self.__dict__["__section_name"], key):
+ raise ConfigParser. \
+ NoOptionError(key, self.__dict__["__section_name"])
- return self.__dict__["__configuration"].get(self.__dict__["__section_name"], key)
+ return self.__dict__["__configuration"]. \
+ get(self.__dict__["__section_name"], key)
def __setattr__(self, key, value):
- if self.__dict__["__configuration"].__dict__.has_key("_lock") and self.__dict__["__configuration"].__dict__["_lock"] and self.__dict__["__use_lock"]:
+ if self.__dict__["__configuration"]. __dict__.has_key("_lock") and \
+ self.__dict__["__configuration"].__dict__["_lock"] and \
+ self.__dict__["__use_lock"]:
raise LockedError(key)
- if not self.__dict__["__configuration"].has_section(self.__dict__["__section_name"]) and self.__dict__["__section_name"]!="DEFAULT":
- self.__dict__["__configuration"].add_section(self.__dict__["__section_name"])
- self.__dict__["__configuration"].set(self.__dict__["__section_name"], key, value)
+ if not self.__dict__["__configuration"]. \
+ has_section(self.__dict__["__section_name"]) and \
+ self.__dict__["__section_name"]!="DEFAULT":
+ self.__dict__["__configuration"]. \
+ add_section(self.__dict__["__section_name"])
+ self.__dict__["__configuration"].set(self.__dict__["__section_name"], \
+ key, value)
def _list(self, key):
l = []
@@ -112,9 +129,12 @@ class FAKConfigSection(object):
def valueItems(self):
"""Usefull when you don't care about the name of the items."""
- if not self.__dict__["__configuration"].has_section(self.__dict__["__section_name"]) and self.__dict__["__section_name"]!="DEFAULT":
+ if not self.__dict__["__configuration"]. \
+ has_section(self.__dict__["__section_name"]) and \
+ self.__dict__["__section_name"]!="DEFAULT":
raise ConfigParser.NoSectionError(self.__dict__["__section_name"])
- tmpList = self.__dict__["__configuration"].items(self.__dict__["__section_name"])
+ tmpList = self.__dict__["__configuration"]. \
+ items(self.__dict__["__section_name"])
retVal = []
for element in tmpList:
retVal.append(element[1])
@@ -122,7 +142,7 @@ class FAKConfigSection(object):
class FAKConfigMixIn(object):
- """Enhance ConfigParser so we can use it in the python way (config.section.value)"""
+ """Enhance ConfigParser so (config.section.value) is possible."""
def __getattr__(self, section):
return FAKConfigSection(self, section)
@@ -142,10 +162,11 @@ createDefaultConfig(Config)
Config.read(cfgfile)
def getConfigBits(name, cfg = Config):
- """returns configuration object loaded with bits from designated configuration file/service
-
+ """Returns conf object loaded with bits from designated config file/service
+
name - service you need info from
- cfg - configuration object containing the system.configuration value, to specify, where to look for the service file"""
+ cfg - configuration object containing the system.configuration value,
+ to specify, where to look for the service file"""
c = FAKConfig()
c.read(os.path.join(cfg.system.configuration, name))
c.lock()
diff --git a/pyfirstaidkit/dependency.py b/pyfirstaidkit/dependency.py
index de80437..73100bd 100644
--- a/pyfirstaidkit/dependency.py
+++ b/pyfirstaidkit/dependency.py
@@ -36,8 +36,9 @@ class Dependencies(object):
"""Add flag"""
Logger.info("Setting dependency flag %s", id)
self._provide.add(id)
- if setactionflag: self._provide.add(id+"?") #Action flags denote activity happening on some regular flag
-
+ #Action flags denote activity happening on some regular flag
+ if setactionflag: self._provide.add(id+"?")
+
def unprovide(self, id, setactionflag = True):
"""Remove flag"""
Logger.info("Resetting dependency flag %s", id)
@@ -55,13 +56,15 @@ class Dependencies(object):
return id in self._provide
def introduce(self, s):
- """Notifies the system about dependency names used in the plugins, so we can list them in help"""
+ """Notifies the system about dep names used in the plugins.
+
+ This allows us to list them in help"""
self._known = self._known.union(s)
def known(self):
"""Returns list of known flags"""
return list(self._known.union(self._provide))
-
+
def valid(self):
"""Returns list of valid/provided flags"""
return list(self._provide)
diff --git a/pyfirstaidkit/errors.py b/pyfirstaidkit/errors.py
index 9ce9500..a32d1ec 100644
--- a/pyfirstaidkit/errors.py
+++ b/pyfirstaidkit/errors.py
@@ -1,16 +1,16 @@
# 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.
@@ -18,7 +18,8 @@
class InvalidFlowStateException(Exception):
def __init__(self, flow):
- self.message="There appears to be an inconsistency with the %s varialbe. " % flow
+ self.message="There appears to be an inconsistency with the %s \
+ varialbe. " % flow
def __str__(self):
return self.message
@@ -37,10 +38,11 @@ class InvalidPluginNameException(Exception):
class GeneralPluginException(Exception):
"""General exception
- This exception should be used for all exceptions that come from the plugins and
- have no specific exception class yet.
+ This exception should be used for all exceptions that come from the
+ plugins and have no specific exception class yet.
"""
def __init__(self, plugin, message):
- self.message="There was an exception in plugin %s with message %s"%(plugin,message)
+ self.message="There was an exception in plugin %s with message %s"% \
+ (plugin,message)
def __str__(self):
return self.message
diff --git a/pyfirstaidkit/interpret.py b/pyfirstaidkit/interpret.py
index e140e4e..ecbfc3e 100644
--- a/pyfirstaidkit/interpret.py
+++ b/pyfirstaidkit/interpret.py
@@ -1,16 +1,16 @@
# 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.
@@ -33,7 +33,8 @@ class Tasker:
name = "Task interpreter"
- def __init__(self, cfg, reporting = None, dependencies = None, backups = None, pluginsystem = None):
+ def __init__(self, cfg, reporting = None, dependencies = None,
+ backups = None, pluginsystem = None):
self._config = cfg
self._running = True
@@ -53,13 +54,16 @@ class Tasker:
self._backups = backups
if pluginsystem is None:
- self.pluginSystem = PluginSystem(reporting = self._reporting, dependencies = self._provide, backups = self._backups)
+ self.pluginSystem = PluginSystem(reporting = self._reporting,
+ dependencies = self._provide, backups = self._backups)
else:
self.pluginSystem = pluginsystem
def interrupt(self):
self._running = False
- self._reporting.info("You sent an interrupt signal to Tasker! This is not recommended.", level = TASKER, origin = self, importance = logging.WARNING)
+ self._reporting.info("You sent an interrupt signal to \
+ Tasker! This is not recommended.", level = TASKER,
+ origin = self, importance = logging.WARNING)
def flags(self):
return self._provide
@@ -84,8 +88,9 @@ class Tasker:
level = TASKER, origin = self, importance = logging.WARNING)
self._provide.provide("root")
else:
- self._reporting.info("You are not running the firstaidkit as root." \
- "Some plugins may not be available.", level = TASKER, origin = self, importance = logging.WARNING)
+ self._reporting.info("You are not running the firstaidkit as " \
+ "root. Some plugins may not be available.", level = TASKER,
+ origin = self, importance = logging.WARNING)
self._provide.unprovide("root")
#initialize the startup set of flags
@@ -93,13 +98,15 @@ class Tasker:
for flag in self._config.operation._list("flags"):
self._provide.provide(flag)
- if self._config.operation.mode in ("auto", "auto-flow", "plugin", "flow"):
+ # For the auto, auto-flow, plugin, flow cases.
+ if self._config.operation.mode in ("auto", "auto-flow", "plugin",
+ "flow"):
if self._config.operation.mode == "plugin":
pluginlist = self._config.operation._list("plugin")
else:
pluginlist = set(pluginSystem.list())
-
+
if self._config.operation.mode == "auto-flow":
flows = len(pluginlist)*[self._config.operation.flow]
elif self._config.operation.mode == "flow":
@@ -108,61 +115,87 @@ class Tasker:
else:
flows = len(pluginlist)*[None]
- #iterate through plugins until there is no plugin left or no action performed during whole iteration
+ #iterate through plugins until there is no plugin left or no
+ #action performed during whole iteration
oldlist = set()
actlist = set(zip(pluginlist, flows))
self._running = True
while self._running and len(actlist)>0 and oldlist!=actlist:
oldlist = copy.copy(actlist)
+
for plugin,flow in oldlist:
- #If plugin does not contain the automated flow or if it ran correctly, remove it from list
- if ((flow and not flow in pluginSystem.getplugin(plugin).getFlows()) or
- (not flow and not pluginSystem.getplugin(plugin).default_flow in
- pluginSystem.getplugin(plugin).getFlows())):
- self._reporting.info("Plugin %s does not contain flow %s"%
- (plugin, flow or pluginSystem.getplugin(plugin).default_flow,),
+ #If plugin does not contain the automated flow or if
+ #it ran correctly, remove it from list
+ if ((flow and
+ not flow in pluginSystem.getplugin(plugin).getFlows())
+ or (not flow and
+ not pluginSystem.getplugin(plugin).default_flow in
+ pluginSystem.getplugin(plugin).getFlows())):
+
+ self._reporting.info("Plugin %s does not contain \
+ flow %s"% (plugin, flow or \
+ pluginSystem.getplugin(plugin).default_flow,), \
level = TASKER, origin = self)
+
actlist.remove((plugin, flow))
- elif pluginSystem.autorun(plugin, flow = flow, dependencies = self._config.operation.dependencies != "False"):
+
+ elif (pluginSystem.autorun(plugin, flow = flow,
+ dependencies = self._config.operation.dependencies
+ != "False")):
actlist.remove((plugin, flow))
#some plugins may not be called because of unfavorable flags
for plugin in set(map(lambda x: x[0], actlist)):
- self._reporting.info("Plugin %s was not called because of unsatisfied dependencies"%
- (plugin,), level = TASKER, origin = self, importance = logging.WARNING)
+ self._reporting.info("Plugin %s was not called because of \
+ unsatisfied dependencies"% (plugin,), level = TASKER, \
+ origin = self, importance = logging.WARNING)
+
+ # For the flags case
elif self._config.operation.mode == "flags":
- self._reporting.table(self._provide.known(), level = TASKER, origin = self, title = "List of flags")
+ self._reporting.table(self._provide.known(), level = TASKER,
+ origin = self, title = "List of flags")
+
+ # For the list case
elif self._config.operation.mode == "list":
#get list of plugins
rep = []
for k in pluginSystem.list():
p = pluginSystem.getplugin(k)
- flowinfo = [ (f, p.getFlow(f).description) for f in p.getFlows() ]
- rep.append((k, p.name, p.version, p.author, p.description, p.default_flow, flowinfo))
- self._reporting.table(rep, level = TASKER, origin = self, title = "List of plugins")
+ flowinfo = [(f, p.getFlow(f).description) for f in p.getFlows()]
+ rep.append((k, p.name, p.version, p.author, p.description,
+ p.default_flow, flowinfo))
+ self._reporting.table(rep, level = TASKER, origin = self,
+ title = "List of plugins")
+
+ # For the info case
elif self._config.operation.mode == "info":
#get info about plugin
try:
p = pluginSystem.getplugin(self._config.operation.params)
except KeyError:
- Logger.error("No such plugin '%s'" % (self._config.operation.params,))
+ Logger.error("No such plugin '%s'" %
+ (self._config.operation.params,))
return False
flowinfo = [ (f, p.getFlow(f).description) for f in p.getFlows() ]
- rep = {"id": self._config.operation.params, "name": p.name,
- "version": p.version, "author": p.author,
- "description": p.description, "flow": p.default_flow, "flows": flowinfo}
- self._reporting.tree(rep, level = TASKER, origin = self,
- title = "Information about plugin %s" % (self._config.operation.params,))
+ rep = {"id": self._config.operation.params, "name": p.name,
+ "version": p.version, "author": p.author,
+ "description": p.description, "flow": p.default_flow,
+ "flows": flowinfo}
+ self._reporting.tree(rep, level = TASKER, origin = self,
+ title = "Information about plugin %s" % \
+ (self._config.operation.params,))
+
+ # Any other case
else:
Logger.error("Incorrect task specified")
self._reporting.stop(level = TASKER, origin = self)
return False
if self._config.operation.printinfo:
- print "--- Info section ---"
+ print("--- Info section ---")
Info.write(sys.stdout)
- print "--------------------"
+ print("--------------------")
self._reporting.stop(level = TASKER, origin = self)
return True
diff --git a/pyfirstaidkit/issue.py b/pyfirstaidkit/issue.py
index 2913943..e706fa4 100644
--- a/pyfirstaidkit/issue.py
+++ b/pyfirstaidkit/issue.py
@@ -31,8 +31,11 @@ class SimpleIssue(object):
self._happened = False
self._fixed = False
- def set(self, happened = None, fixed = None, checked = None, reporting = None, **kwreportingargs):
- """Set the state of this issue and send a report (if reporting is not None)"""
+ def set(self, happened = None, fixed = None, checked = None,
+ reporting = None, **kwreportingargs):
+ """Set the state of this issue and send a report
+
+ The report is set if reporting is not None"""
if happened:
self._happened = happened
if fixed:
@@ -44,6 +47,7 @@ class SimpleIssue(object):
def happened(self):
"""Get the 'issue happened' flag.
+
Return values:
True - YES it happened
False - NO, it is OK
@@ -53,9 +57,10 @@ Return values:
return None
else:
return self._happened
-
+
def fixed(self):
"""Get the 'issue fixed' flag.
+
Return values:
True - YES it is fixed
False - NO, it is still broken
@@ -91,7 +96,8 @@ Return values:
class Issue(SimpleIssue):
name = "Parent issue"
- description = "This happens when you use the wrong object in the issues list"
+ description = "This happens when you use the wrong object in the issues \
+ list"
def __init__(self, plugin, reporting = None):
SimpleIssue.__init__(self, self.name, self.description)
@@ -99,7 +105,9 @@ class Issue(SimpleIssue):
self._reporting = reporting
def detect(self):
- """Detect if this situation happened and store some information about it, so we can fix it
+ """Detect if situation happened and store some information about it.
+
+ This is done so we can fix it
Return values:
True - check OK
False - check Failed
@@ -110,10 +118,13 @@ Return values:
if self._checked or self._fixed:
return not self._fixed and self._checked
- return None #no error, please do the check (so the child-class knows to actually do something)
+ #no error, please do the check (so the child-class knows to actually
+ #do something)
+ return None
def fix(self):
"""Fix the situation if needed
+
Return values:
True - fix OK
False - fix Failed
@@ -123,6 +134,6 @@ Return values:
#if it was not checked, the check si needed too
if not self._checked or self._fixed:
return self._fixed and self._checked
-
- return None #no fix error, please do the fix (so the child-class knows to actually do something)
-
+ #no fix error, please do the fix (so the child-class knows to actually
+ #do something)
+ return None
diff --git a/pyfirstaidkit/plugins.py b/pyfirstaidkit/plugins.py
index 28b2221..5bd857f 100644
--- a/pyfirstaidkit/plugins.py
+++ b/pyfirstaidkit/plugins.py
@@ -1,16 +1,16 @@
# 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.
@@ -55,8 +55,8 @@ class Plugin(object):
# Dictionary that holds all the flows. The keys for each flow is its
# name. The flow will be addressed by this name. The plugin developer
# Can add as many flows as he wants. The developer must use the instance.
- # flows["name"] = SomeFlow. Be aware that you can overwirhte
- # previously added flows. This class attribute has to be initialized by
+ # flows["name"] = SomeFlow. Be aware that you can overwirhte
+ # previously added flows. This class attribute has to be initialized by
# each plugin using flows = Flow.init(ParentClass)
#
flows = {}
@@ -79,36 +79,46 @@ class Plugin(object):
# has to be named "diagnose"
#
flows["diagnose"] = Flow({
- initial : {Return: "prepare"},
- "prepare" : {ReturnSuccess: "diagnose", None: "clean"},
- "diagnose" : {ReturnSuccess: "clean", ReturnFailure: "clean", None: "clean"},
- "clean" : {ReturnSuccess: final, ReturnFailure: final, None: final}
- }, description="The default, fully automated, diagnose sequence")
+ initial : {Return: "prepare"},
+ "prepare" : {ReturnSuccess: "diagnose", None: "clean"},
+ "diagnose" : {ReturnSuccess: "clean", ReturnFailure: "clean",
+ None: "clean"},
+ "clean" : {ReturnSuccess: final, ReturnFailure: final, None: final}
+ }, description="The default, fully automated, diagnose sequence")
+
flows["fix"] = Flow({
- initial : {Return: "prepare"},
- "prepare" : {ReturnSuccess: "diagnose", None: "clean"},
- "diagnose" : {ReturnSuccess: "clean", ReturnFailure: "backup", None: "clean"},
- "backup" : {ReturnSuccess: "fix", ReturnFailure: "clean", None: "clean"},
- "fix" : {ReturnSuccess: "clean", ReturnFailure: "restore", None: "restore"},
- "restore" : {ReturnSuccess: "clean", ReturnFailure: "clean", None: "clean"},
- "clean" : {ReturnSuccess: final, ReturnFailure: final, None: final}
- }, description="The default, fully automated, fixing sequence")
-
- # By default, when no other parameters are passed, we use the diagnose flow as
- # the default flow to run. You can change this, BUT it MUST always be a non-changing
- # non-destructive and safe flow, which does the diagnostics
+ initial : {Return: "prepare"},
+ "prepare" : {ReturnSuccess: "diagnose", None: "clean"},
+ "diagnose" : {ReturnSuccess: "clean", ReturnFailure: "backup",
+ None: "clean"},
+ "backup" : {ReturnSuccess: "fix", ReturnFailure: "clean",
+ None: "clean"},
+ "fix" : {ReturnSuccess: "clean", ReturnFailure: "restore",
+ None: "restore"},
+ "restore" : {ReturnSuccess: "clean", ReturnFailure: "clean",
+ None: "clean"},
+ "clean" : {ReturnSuccess: final, ReturnFailure: final, None: final}
+ }, description="The default, fully automated, fixing sequence")
+
+ # By default, when no other parameters are passed, we use the diagnose
+ # flow as the default flow to run. You can change this, BUT it MUST always
+ # be a non-changing non-destructive and safe flow, which does the
+ # diagnostics
default_flow = "diagnose"
- def __init__(self, flow, reporting, dependencies, path = None, backups = None, info = None):
+ def __init__(self, flow, reporting, dependencies, path = None,
+ backups = None, info = None):
""" Initialize the instance.
flow -- Name of the flow to be used with this instance.
reporting -- object used to report information to the user
- dependencies -- object encapsulating the inter-plugin dependency API (require, provide)
+ dependencies -- object encapsulating the inter-plugin dependency API
+ (require, provide)
path -- directory from where was this plugin imported
- The flow is defined in the __init__ so we don't have to worry about changing it.
+ The flow is defined in the __init__ so we don't have to worry about
+ changing it.
"""
self._reporting = reporting
self._dependencies = dependencies
@@ -155,9 +165,10 @@ class Plugin(object):
"""Defines the current flow to name.
flow -- Name of the flow
- This function is to be called from the __init__ only. There will be the flows defined by the
- Plugin class and the flows defined by the actual plugin. We will first search the Plugin
- class and then the plugin itself for the name.
+ This function is to be called from the __init__ only. There will be the
+ flows defined by the Plugin class and the flows defined by the actual
+ plugin. We will first search the Plugin class and then the plugin
+ itself for the name.
"""
#
# The flow that will be used for the instance.
@@ -172,7 +183,7 @@ class Plugin(object):
"""Return a set with the names of all possible flows."""
fatherf = cls.flows.keys()
return set(fatherf)
-
+
@classmethod
def getFlow(cls, name):
"""Return a Flow object associated with provided name"""
@@ -184,31 +195,35 @@ class Plugin(object):
#dependency stuff
@classmethod
def getDeps(cls):
- """Return list of conditions required to be set before automated run can be done"""
+ """Return list of conditions required to be set before automated rune"""
return set()
-
+
@classmethod
def getConflicts(cls):
- """Return list of conditions required to be UNset before automated run can be done"""
+ """Return list of conditions required to be UNset before automated run"""
return set()
- #methods available only for instance, see interpreter.py and dependency stuff there
+ #methods available only for instance, see interpreter.py and dependency
+ #stuff there
#def require(self, id)
#def provide(self, id)
#list of all actions provided
def actions(self):
"""Returns list of available actions"""
- return set(["prepare", "backup", "diagnose", "describe", "fix", "restore", "clean"])
+ 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.
+ """Returns next state when analizing self.{_state,_result,cflow}.
+ This is relevant for automode.
state -- Name of hte function.
result -- The return value of the previous function
- We do not check for validity of the key in the self.cflow. If key is invalid, function will
- Traceback. When self._state = self.final the function will traceback. This situation must
- be handled outside this function. If an automatica iteration is needed that avoids the
+ We do not check for validity of the key in the self.cflow. If key is
+ invalid, function will Traceback. When self._state = self.final the
+ function will traceback. This situation must be handled outside this
+ function. If an automatica iteration is needed that avoids the
necesity to address the self.final state, use __iter__ and next.
"""
# If any of the vals are missing, we default to the current ones.
@@ -237,7 +252,8 @@ class Plugin(object):
def next(self):
"""Iteration function.
- Will return (self._state, self._result). The function that was executed and the return value.
+ Will return (self._state, self._result). The function that was executed
+ and the return value.
"""
func = self.nextstate()
@@ -248,8 +264,10 @@ class Plugin(object):
# Execute the function.
self.call(func)
except Exception, e: #fallback, when there is some error in plugin
- self._reporting.exception(level = TASK, origin = self, message = func+" raised "+str(e))
- self._reporting.stop(level = TASK, origin = self, message = func)
+ self._reporting.exception(level = TASK, origin = self,
+ message = func+" raised "+str(e))
+ self._reporting.stop(level = TASK, origin = self,
+ message = func)
pass
return (self._state, self._result)
@@ -260,55 +278,65 @@ class Plugin(object):
def prepare(self):
"""Initial actions.
- 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.
+ 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.
"""
#We want these functions to be overridden by the plugin developer.
if self.__class__ is Plugin:
- Logger.warning("Prepare is an abstract method, it should be used as such.")
+ Logger.warning("Prepare is an abstract method, it should be used \
+ as such.")
def clean(self):
"""Final actions.
- All the actions that must be done after the exection of all plugin functions.
- This function generaly addresses things that are global and need to be closed
- off, like file descriptos, or mounted partitions....
+ All the actions that must be done after the exection of all plugin
+ functions. This function generaly addresses things that are global
+ and need to be closed off, like file descriptos, or mounted
+ partitions....
"""
#We want these functions to be overridden by the plugin developer.
if self.__class__ is Plugin:
- Logger.warning("Clean is an abstract method, it should be used as such.")
+ Logger.warning("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:
- Logger.warning("Backup is an abstract method, it should be used as such.")
+ Logger.warning("Backup 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:
- Logger.warning("Restore is an abstract method, it should be used as such.")
+ Logger.warning("Restore 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:
- Logger.warning("Diagnose is an abstract method, it should be used as such.")
+ Logger.warning("Diagnose 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:
- Logger.warning("Fix is an abstract method, it should be used as such.")
+ Logger.warning("Fix is an abstract method, it should be used as \
+ such.")
class IssuesPlugin(Plugin):
- """Simple plugin which uses Issue classes to test more small and INDEPENDENT issues in the system.
-Just fill the issue_tests list with classes describing the tests and let it run."""
+ """Plugin which uses Issue classes to test smaller and INDEPENDENT issues.
+
+ Just fill the issue_tests list with classes describing the tests and let
+ it run."""
issue_tests = [] #List of Issue classes to check
set_flags = [] #flags to set when everything is OK
-
+
def __init__(self, *args, **kwargs):
Plugin.__init__(self, *args, **kwargs)
self.tests = []
@@ -316,7 +344,8 @@ Just fill the issue_tests list with classes describing the tests and let it run.
def prepare(self):
"""Prepare the issues list"""
for i in self.issue_tests:
- self._reporting.info(level = TASK, origin = self, message = "Preparing tests for '%s'" % (i.name,))
+ self._reporting.info(level = TASK, origin = self,
+ message = "Preparing tests for '%s'" % (i.name,))
issue = i(plugin = self)
self.tests.append(issue)
self._reporting.issue(level = TASK, origin = self, issue = issue)
@@ -328,12 +357,14 @@ Just fill the issue_tests list with classes describing the tests and let it run.
result = False
happened = False
for i in self.tests:
- self._reporting.info(level = TASK, origin = self, message = "Investigating '%s'" % (i.name,))
+ self._reporting.info(level = TASK, origin = self,
+ message = "Investigating '%s'" % (i.name,))
result = result or i.detect()
self._reporting.issue(level = TASK, origin = self, issue = i)
if i.happened():
happened = True
- self._reporting.info(level = TASK, origin = self, message = i.str())
+ self._reporting.info(level = TASK, origin = self,
+ message = i.str())
if result and not happened:
self._result=ReturnSuccess
@@ -350,7 +381,8 @@ Just fill the issue_tests list with classes describing the tests and let it run.
result = False
fixed = True
for i in self.tests:
- self._reporting.info(level = TASK, origin = self, message = "Fixing '%s'" % (i.name,))
+ self._reporting.info(level = TASK, origin = self,
+ message = "Fixing '%s'" % (i.name,))
result = result or i.fix()
self._reporting.issue(level = TASK, origin = self, issue = i)
if not i.fixed():
@@ -373,12 +405,12 @@ Just fill the issue_tests list with classes describing the tests and let it run.
class FlagTrackerPlugin(Plugin):
- """This kind of plugin monitores all the flags in the system and when certain flags
- are set, provides some kind of higher level flag.
+ """This kind of plugin monitores all the flags in the system and when
+ certain flags are set, provides some kind of higher level flag.
Example:
- monitor flags 'filesystem_drive', 'filesystem_lvm' and 'filesystem_ext3' and if
- everything is ok set the master flag 'filesystem'"""
+ monitor flags 'filesystem_drive', 'filesystem_lvm' and 'filesystem_ext3'
+ and if everything is ok set the master flag 'filesystem'"""
# Higher level master flag to set
#flag_decide = "x_decide"
@@ -414,10 +446,12 @@ class FlagTrackerPlugin(Plugin):
"""Decide about state of higher level flags."""
#We want these functions to be overridden by the plugin developer.
if self.__class__ is FlagTrackerPlugin:
- Logger.warning("Decide is an abstract method, it should be used as such.")
-
+ Logger.warning("Decide is an abstract method, it should be used \
+ as such.")
+
if self.flag_decide is None:
- Logger.warning("You have to specify flag to set when everything is ok.")
+ Logger.warning("You have to specify flag to set when everything \
+ is ok.")
return Return
for flag in self.flag_list:
@@ -433,7 +467,7 @@ class PluginSystem(object):
name = "Plugin System"
- def __init__(self, reporting, dependencies, config = Config, backups = None):
+ def __init__(self, reporting, dependencies, config=Config, backups=None):
self._paths = Config.paths.valueItems()
self._backups = backups
self._reporting = reporting
@@ -443,25 +477,32 @@ class PluginSystem(object):
for path in self._paths:
if not os.path.isdir(path):
- self._reporting.debug("The path %s does not exist" % path, level = PLUGINSYSTEM, origin = self)
+ self._reporting.debug("The path %s does not exist" % path,
+ level = PLUGINSYSTEM, origin = self)
continue
#create list of potential modules in the path
importlist = set()
for f in os.listdir(path):
fullpath = os.path.join(path, f)
- self._reporting.debug("Processing file: %s" % (f,), level = PLUGINSYSTEM, origin = self)
- if os.path.isdir(fullpath) and os.path.isfile(os.path.join(path, f, "__init__.py")):
+ self._reporting.debug("Processing file: %s" % (f,),
+ level = PLUGINSYSTEM, origin = self)
+ if os.path.isdir(fullpath) \
+ and os.path.isfile(os.path.join(path, f, "__init__.py")):
importlist.add(f)
- self._reporting.debug("Adding python module (directory): %s" % (f,),
- level = PLUGINSYSTEM, origin = self)
- elif os.path.isfile(fullpath) and (f[-3:]==".so" or f[-3:]==".py"):
+ self._reporting.debug("Adding python module (directory): %s"
+ % (f,), level = PLUGINSYSTEM, origin = self)
+
+ elif os.path.isfile(fullpath) and (f[-3:]==".so"
+ or f[-3:]==".py"):
importlist.add(f[:-3])
- self._reporting.debug("Adding python module (file): %s" % (f,),
- level = PLUGINSYSTEM, origin = self)
- elif os.path.isfile(fullpath) and (f[-4:]==".pyc" or f[-4:]==".pyo"):
+ self._reporting.debug("Adding python module (file): %s"
+ % (f,), level = PLUGINSYSTEM, origin = self)
+
+ elif os.path.isfile(fullpath) and (f[-4:]==".pyc"
+ or f[-4:]==".pyo"):
importlist.add(f[:-4])
- self._reporting.debug("Adding python module (compiled): %s" % (f,),
- level = PLUGINSYSTEM, origin = self)
+ self._reporting.debug("Adding python module (compiled): %s"
+ % (f,), level = PLUGINSYSTEM, origin = self)
#try to import the modules as FirstAidKit.plugins.modulename
for m in importlist:
@@ -470,18 +511,25 @@ class PluginSystem(object):
imp.acquire_lock()
try:
- self._reporting.debug("Importing module %s from %s" % (m, path),
- level = PLUGINSYSTEM, origin = self)
+ self._reporting.debug("Importing module %s from %s"
+ % (m, path), level = PLUGINSYSTEM, origin = self)
moduleinfo = imp.find_module(m, [path])
- module = imp.load_module(".".join([FirstAidKit.__name__, m]), *moduleinfo)
- self._deps.introduce(module.get_plugin().getDeps()) #notify the dependency system about all used dependencies
- self._deps.introduce(module.get_plugin().getConflicts()) #notify the dependency system about all used reverse-dependencies
+ module = imp.load_module(".".join([FirstAidKit.__name__,m]),
+ *moduleinfo)
+ #notify the dependency system about all used dependencies
+ self._deps.introduce(module.get_plugin().getDeps())
+ #notify the dependency system about all used
+ #reverse-dependencies
+ self._deps.introduce(module.get_plugin().getConflicts())
self._plugins[m] = module
- self._reporting.debug("Module %s successfully imported with basedir %s" %
- (m, os.path.dirname(module.__file__)), level = PLUGINSYSTEM, origin = self)
+ self._reporting.debug("Module %s successfully imported \
+ with basedir %s" %
+ (m, os.path.dirname(module.__file__)),
+ level = PLUGINSYSTEM, origin = self)
except Exception, e:
- self._reporting.error(message = "Module %s was NOT imported, because of %s" %
- (m, str(e)), level = PLUGINSYSTEM, origin = self)
+ self._reporting.error(message = "Module %s was NOT \
+ imported, because of %s" %
+ (m, str(e)), level = PLUGINSYSTEM, origin = self)
finally:
imp.release_lock()
@@ -500,11 +548,12 @@ class PluginSystem(object):
self._reporting.start(level = PLUGIN, origin = self, message = plugin)
if plugin in self._plugins.keys():
- pklass = self._plugins[plugin].get_plugin() #get top level class of plugin
+ #get top level class of plugin
+ pklass = self._plugins[plugin].get_plugin()
else:
- self._reporting.exception(message = "Plugin %s was not found" % plugin,
- level = PLUGINSYSTEM, origin = self)
- self._reporting.stop(level = PLUGIN, origin = self, message = plugin)
+ self._reporting.exception(message = "Plugin %s was not found" %
+ plugin, level = PLUGINSYSTEM, origin = self)
+ self._reporting.stop(level=PLUGIN, origin=self, message=plugin)
raise InvalidPluginNameException(plugin)
plugindir = os.path.dirname(self._plugins[plugin].__file__)
@@ -520,9 +569,10 @@ class PluginSystem(object):
Logger.info("Using %s flow" % flowName)
if flowName not in flows:
- self._reporting.exception(message = "Flow %s does not exist in plugin %s" %
- (flowName, plugin), level = PLUGINSYSTEM, origin = self)
- self._reporting.stop(level = PLUGIN, origin = self, message = plugin)
+ self._reporting.exception(message = "Flow %s does not exist in \
+ plugin %s" % (flowName, plugin), level = PLUGINSYSTEM,
+ origin = self)
+ self._reporting.stop(level=PLUGIN, origin=self, message=plugin)
raise InvalidFlowNameException(flowName)
if dependencies:
@@ -531,29 +581,38 @@ class PluginSystem(object):
Logger.info("depends on: %s" % (", ".join(deps),))
for d in deps:
if not self._deps.require(d):
- Logger.info("depends on usatisfied condition: %s" % (d,))
- self._reporting.stop(level = PLUGIN, origin = self, message = plugin)
+ Logger.info("depends on usatisfied condition: %s" %
+ (d,))
+ self._reporting.stop(level = PLUGIN, origin = self,
+ message = plugin)
return False
deps = pklass.getConflicts()
if len(deps)>0:
- Logger.info("depends on flags to be unset: %s" % (", ".join(deps),))
+ Logger.info("depends on flags to be unset: %s" %
+ (", ".join(deps),))
for d in deps:
if self._deps.require(d):
- Logger.info("depends on condition to be UNset: %s" % (d,))
- self._reporting.stop(level = PLUGIN, origin = self, message = plugin)
+ Logger.info("depends on condition to be UNset: %s" %
+ (d,))
+ self._reporting.stop(level = PLUGIN, origin = self,
+ message = plugin)
return False
infosection = getattr(Info, plugin)
infosection.unlock()
- p = pklass(flowName, reporting = self._reporting, dependencies = self._deps, backups = self._backups, path = plugindir, info = infosection)
+ p = pklass(flowName, reporting = self._reporting,
+ dependencies = self._deps, backups = self._backups,
+ path = plugindir, info = infosection)
for (step, rv) in p: #autorun all the needed steps
Logger.info("Running step %s in plugin %s ...", step, plugin)
- Logger.info("%s is current step and %s is result of that step." % (step, rv))
+ Logger.info("%s is current step and %s is result of that step." %
+ (step, rv))
self._reporting.stop(level = PLUGIN, origin = self, message = plugin)
return True
def getplugin(self, plugin):
- """Get top level class of plugin, so we can create the instance and call the steps manually"""
+ """Get top level class of plugin, so we can create the instance and
+ call the steps manually"""
return self._plugins[plugin].get_plugin()
diff --git a/pyfirstaidkit/reporting.py b/pyfirstaidkit/reporting.py
index 8a19a07..0743ee9 100644
--- a/pyfirstaidkit/reporting.py
+++ b/pyfirstaidkit/reporting.py
@@ -1,16 +1,16 @@
# 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.
@@ -45,7 +45,8 @@ QUESTION = 999 #type of message which contains respond-to field
END = 1000 #End of operations, final message
class Origin(object):
- """Class which defines mandatory interface for origin, when using the reporting system"""
+ """Class which defines mandatory interface for origin,
+ when using the reporting system"""
name = "Origin:Unknown"
def __init__(self, name):
@@ -82,12 +83,17 @@ class Reports(object):
self._notify = []
def notify(self, cb, *args, **kwargs):
- """When putting anything new into the Queue, run notifications callbacks. Usefull for Gui and single-thread reporting.
- The notification function has parameters: message recorded to the queue, any parameters provided when registering"""
+ """When putting anything new into the Queue, run notifications
+ callbacks. Usefull for Gui and single-thread reporting.
+ The notification function has parameters: message recorded to the
+ queue, any parameters provided when registering"""
return self._notify.append((cb, args, kwargs))
- def put(self, message, level, origin, action, importance = logging.INFO, reply = None, title = "", destination = None):
- data = {"level": level, "origin": origin, "action": action, "importance": importance, "message": message, "reply": reply, "title": title}
+ def put(self, message, level, origin, action, importance = logging.INFO,
+ reply = None, title = "", destination = None):
+ data = {"level": level, "origin": origin, "action": action,
+ "importance": importance, "message": message,
+ "reply": reply, "title": title}
if destination is not None:
return destination.put(data)
@@ -99,7 +105,9 @@ class Reports(object):
except Queue.Full, e:
if not self._round:
raise
- destination.get() #Queue is full and it is a round buffer.. remove the oldest item and use the free space to put the new item
+ #Queue is full and it is a round buffer.. remove the oldest item
+ #and use the free space to put the new item
+ destination.get()
ret=destination.put(data)
finally:
self._queue_lock.release()
@@ -137,15 +145,20 @@ class Reports(object):
def error(self, message, level, origin, action = INFO):
Logger.error(origin.name+": "+message)
- return self.put(message, level, origin, action, importance = logging.ERROR)
+ return self.put(message, level, origin, action,
+ importance = logging.ERROR)
def start(self, level, origin, message = ""):
- return self.put(message, level, origin, START, importance = logging.DEBUG)
+ return self.put(message, level, origin, START,
+ importance = logging.DEBUG)
def stop(self, level, origin, message = ""):
- return self.put(message, level, origin, STOP, importance = logging.DEBUG)
+ return self.put(message, level, origin, STOP,
+ importance = logging.DEBUG)
- def progress(self, position, maximum, level, origin, importance = logging.INFO):
- return self.put((position, maximum), level, origin, PROGRESS, importance = importance)
+ def progress(self, position, maximum, level, origin,
+ importance = logging.INFO):
+ return self.put((position, maximum), level, origin, PROGRESS,
+ importance = importance)
def issue(self, issue, level, origin, importance = logging.INFO):
Logger.debug(origin.name+": issue changed state to "+str(issue))
@@ -158,14 +171,19 @@ class Reports(object):
Logger.debug(origin.name+": "+message)
return self.put(message, level, origin, INFO, importance = importance)
- def tree(self, message, level, origin, importance = logging.INFO, title = ""):
- return self.put(message, level, origin, TREE, importance = importance, title = title)
- def table(self, message, level, origin, importance = logging.INFO, title = ""):
- return self.put(message, level, origin, TABLE, importance = importance, title = title)
+ def tree(self, message, level, origin, importance = logging.INFO,
+ title = ""):
+ return self.put(message, level, origin, TREE, importance = importance,
+ title = title)
+ def table(self, message, level, origin, importance = logging.INFO,
+ title = ""):
+ return self.put(message, level, origin, TABLE,
+ importance = importance, title = title)
def alert(self, message, level, origin, importance = logging.WARNING):
return self.put(message, level, origin, ALERT, importance = importance)
def exception(self, message, level, origin, importance = logging.ERROR):
Logger.error(origin.name+": "+message)
- return self.put(message, level, origin, EXCEPTION, importance = importance)
+ return self.put(message, level, origin, EXCEPTION,
+ importance = importance)
diff --git a/pyfirstaidkit/returns.py b/pyfirstaidkit/returns.py
index 614e7a3..4757977 100644
--- a/pyfirstaidkit/returns.py
+++ b/pyfirstaidkit/returns.py
@@ -1,16 +1,16 @@
# 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.
@@ -51,7 +51,8 @@ class ReturnNone(Return):
# 3. If the plugin is in fix stage and the problem was not fixed, the return
# 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
+# Remember that the actual values of the classes is not checked, what is
+# checked
# is that the return value be the specific class.
#
diff --git a/pyfirstaidkit/utils/__init__.py b/pyfirstaidkit/utils/__init__.py
index a6a1086..035de46 100644
--- a/pyfirstaidkit/utils/__init__.py
+++ b/pyfirstaidkit/utils/__init__.py
@@ -1,16 +1,16 @@
# 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.
diff --git a/pyfirstaidkit/utils/backup.py b/pyfirstaidkit/utils/backup.py
index f2edd03..5271cd6 100644
--- a/pyfirstaidkit/utils/backup.py
+++ b/pyfirstaidkit/utils/backup.py
@@ -208,7 +208,7 @@ class FileBackupStore(BackupStoreInterface):
else:
os.makedirs(self._path)
self.__class__._singleton = weakref.proxy(self)
- print "Backup system initialized"
+ print("Backup system initialized")
def getBackup(self, id):
if not self._backups.has_key(id):
@@ -228,7 +228,7 @@ class FileBackupStore(BackupStoreInterface):
for id,backup in self._backups.iteritems():
backup.cleanup()
os.rmdir(self._path)
- print "Backup closed"
+ print("Backup closed")
@classmethod
def get(cls, path):
diff --git a/test b/test
index e80c303..cc302b5 100755
--- a/test
+++ b/test
@@ -1,17 +1,17 @@
#!/usr/bin/python -tt
# First Aid Kit - diagnostic and repair tool for Linux
# Copyright (C) 2008 Joel Granados <jgranado@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.
@@ -37,15 +37,15 @@ for modname in modnames:
else:
flawless = False
if len(result.failures) > 0:
- print "-"*20 + " Failures " + "-"*20
+ print("-"*20 + " Failures " + "-"*20)
for failure in result.failures:
- print "\n%s" % failure[1]
- print "-"*50
+ print("\n%s" % failure[1])
+ print("-"*50)
if len(result.errors) > 0:
print "-"*20 + " Errors " + "-"*20
for error in result.errors:
- print "\n%s" % error[1]
- print "-"*48
+ print("\n%s" % error[1])
+ print("-"*48)
if flawless:
sys.exit(0)
diff --git a/testsuite/__init__.py b/testsuite/__init__.py
index d302cc0..a809d90 100644
--- a/testsuite/__init__.py
+++ b/testsuite/__init__.py
@@ -1,16 +1,16 @@
# First Aid Kit - diagnostic and repair tool for Linux
# Copyright (C) 2008 Joel Granados <jgranado@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.
diff --git a/testsuite/initialization.py b/testsuite/initialization.py
index 81e3b52..9b62c30 100644
--- a/testsuite/initialization.py
+++ b/testsuite/initialization.py
@@ -29,9 +29,11 @@ class Initialization(unittest.TestCase):
self.confPath = self.contentdir+"/initialization.conf"
Config.read(self.confPath)
initLogger(Config)
- self.pluginSystem = PluginSystem(reporting=Reports(), dependencies=Dependencies())
+ self.pluginSystem = PluginSystem(reporting=Reports(),
+ dependencies=Dependencies())
self.plugin = self.pluginSystem.getplugin("pluginInfo")
- py_compile.compile("%s/pycFile" % self.contentdir, cfile="%s/pycFile.pyc" % self.contentdir)
+ py_compile.compile("%s/pycFile" % self.contentdir,
+ cfile="%s/pycFile.pyc" % self.contentdir)
def tearDown(self):
if(os.path.isfile(Config.log.filename)):
@@ -41,13 +43,16 @@ class Imports(Initialization):
"""Tests the capability of importing 3 typs of files."""
def testImportsPy(self):
- self.assert_('pyFile' in self.pluginSystem.list(), "Firstaidkit failed to import a 'py' file.")
+ self.assert_('pyFile' in self.pluginSystem.list(),
+ "Firstaidkit failed to import a 'py' file.")
def testImportsPyc(self):
- self.assert_('pycFile' in self.pluginSystem.list(), "Firstaidkit failed to import a 'pyc' file.")
+ self.assert_('pycFile' in self.pluginSystem.list(),
+ "Firstaidkit failed to import a 'pyc' file.")
def testImportsDir(self):
- self.assert_('directory' in self.pluginSystem.list(), "Firstaidkit failed to import from a directory.")
+ self.assert_('directory' in self.pluginSystem.list(),
+ "Firstaidkit failed to import from a directory.")
class Info(Initialization):
"""Test the infomration from the plugins."""
@@ -61,8 +66,11 @@ class Info(Initialization):
self.assertEqual(self.plugin.version, "3.4.5")
def testInfoFlowName(self):
- self.assert_('newflow' in self.plugin.getFlows(), "Firstaidkit failed to show access the flow name")
+ self.assert_('newflow' in self.plugin.getFlows(),
+ "Firstaidkit failed to show access the flow name")
def testInfoFlowDescription(self):
- self.assert_('This is the newflow' == self.plugin.getFlow("newflow").description, "Firstaidkit failed to show access the flow name")
+ self.assert_('This is the newflow' == \
+ self.plugin.getFlow("newflow").description,
+ "Firstaidkit failed to show access the flow name")
diff --git a/testsuite/initialization/pluginInfo.py b/testsuite/initialization/pluginInfo.py
index 8b2d80f..1b29a4f 100644
--- a/testsuite/initialization/pluginInfo.py
+++ b/testsuite/initialization/pluginInfo.py
@@ -24,11 +24,11 @@ class PluginInfo(Plugin):
author = "John Galt"
flows={}
flows["newflow"] = Flow({
- Plugin.initial: {Return: "prepare"},
- "prepare" : {ReturnSuccess: "fix"},
- "fix" : {ReturnSuccess: "clean", ReturnFailure: "clean"},
- "clean" : {ReturnSuccess: Plugin.final}
- }, description="This is the newflow")
+ Plugin.initial: {Return: "prepare"},
+ "prepare" : {ReturnSuccess: "fix"},
+ "fix" : {ReturnSuccess: "clean", ReturnFailure: "clean"},
+ "clean" : {ReturnSuccess: Plugin.final}
+ }, description="This is the newflow")
def __init__(self, *args, **kwargs):
Plugin.__init__(self, *args, **kwargs)