diff options
author | Joel Andres Granados <jgranado@redhat.com> | 2008-07-11 16:40:04 +0200 |
---|---|---|
committer | Joel Andres Granados <jgranado@redhat.com> | 2008-07-14 11:33:13 +0200 |
commit | fdf629196062319bba60fa13c606ed4ba80a41ff (patch) | |
tree | 696d0fc36119b954a0d82bc1f20e665e765b7a2a /plugins | |
parent | c5c3e6cae831bd2d88358bcb1df63f6bab3c66e6 (diff) | |
download | firstaidkit-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/
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/plugin_mdadmconf.py | 6 | ||||
-rw-r--r-- | plugins/plugin_undelete_partitions/Makefile | 6 | ||||
-rw-r--r-- | plugins/plugin_undelete_partitions/__init__.py | 6 | ||||
-rw-r--r-- | plugins/plugin_undelete_partitions/undeletePartition.py | 10 | ||||
-rw-r--r-- | plugins/xserver.py | 107 |
5 files changed, 82 insertions, 53 deletions
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 |