summaryrefslogtreecommitdiffstats
path: root/plugins/xserver.py
diff options
context:
space:
mode:
authorJoel Andres Granados <jgranado@redhat.com>2008-06-04 14:46:22 +0200
committerJoel Andres Granados <jgranado@redhat.com>2008-06-04 14:46:22 +0200
commit097b8fe4772cc9ec501cf72edf094a3ac061fcd7 (patch)
tree06a23924ca8d838721d24fd256dd5837d27ef1d5 /plugins/xserver.py
parenta7f824fdc70b35561ba33b6c3306fe790b9d8a5a (diff)
downloadfirstaidkit-097b8fe4772cc9ec501cf72edf094a3ac061fcd7.tar.gz
firstaidkit-097b8fe4772cc9ec501cf72edf094a3ac061fcd7.tar.xz
firstaidkit-097b8fe4772cc9ec501cf72edf094a3ac061fcd7.zip
Have xserver plugin use the backup system.
Diffstat (limited to 'plugins/xserver.py')
-rw-r--r--plugins/xserver.py35
1 files changed, 21 insertions, 14 deletions
diff --git a/plugins/xserver.py b/plugins/xserver.py
index 6f5854d..21319a7 100644
--- a/plugins/xserver.py
+++ b/plugins/xserver.py
@@ -21,6 +21,7 @@ from pyfirstaidkit.utils import *
from pyfirstaidkit.reporting import PLUGIN
from pyfirstaidkit.issue import SimpleIssue
from pyfirstaidkit import Config
+from pyfirstaidkit.errors import *
import rhpxl.xserver
import rhpl.keyboard
@@ -57,6 +58,7 @@ class Xserver(Plugin):
# Arbitrary test display
self.display = ":10"
self.confPath = "/etc/X11/xorg.conf"
+ self.backupName = None
self._issue = SimpleIssue(self.name, "X server didn't start")
def prepare(self):
@@ -107,19 +109,17 @@ class Xserver(Plugin):
self._issue.set(checked = True, happened = (self._result == ReturnFailure), reporting = self._reporting, level = PLUGIN, origin = self)
-
- # FIXME:Must change this when the backup utils is done.
def backup(self):
if os.path.isfile(self.confPath):
- self._reporting.info("Making copy of %s"%self.confPath, level = PLUGIN , origin = self)
try:
- shutil.copyfile(self.confPath, "%s.FAK-backup"%self.confPath)
- self._result = ReturnSuccess
- except:
- self._result = ReturnFailure
+ self.backupName = "Xconfig"
+ self._backups.backupPath(self.confPath, self.backupName)
+ except BackupException:
+ self.backupName = "Xconfig"+os.getpid()
+ self._backups.backupPath(self.confPath, self.backupName)
+ self._result = ReturnSuccess
else:
- self._reporting.info("Expected path to configuration file seems to be nonexistent (%s)"%
- 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):
@@ -138,12 +138,19 @@ class Xserver(Plugin):
self._issue.set(fixed = (self._result == ReturnSuccess), reporting = self._reporting, level = PLUGIN, origin = self)
def restore(self):
- if os.path.isfile("%s.FAK-backup"%self.confPath):
+ if self.backupName is None:
+ # 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._result = ReturnSuccess
+ return
+
+ try:
self._reporting.info("Restoring original file.", level = PLUGIN , origin = self)
- shutil.copyfile("%s.FAK-backup"%self.confPath, self.confPath)
- else:
- self._reporting.info("The backedup file was not present, something strange is going on.",
- level = PLUGIN, origin = self)
+ self._backups.restoreName(self.backupName)
+ self._result = ReturnSuccess
+ except BackupException:
+ # This means that the backed up file was lost somewhere.
+ raise GeneralPluginException(self, "Very ugly inconsistency with the backup files.")
def clean(self):
self._reporting.info("Cleaning the backedup file.", level = PLUGIN, origin = self)