summaryrefslogtreecommitdiffstats
path: root/plugins/xserver.py
diff options
context:
space:
mode:
authorJoel Andres Granados <jgranado@redhat.com>2008-03-18 16:35:19 +0100
committerJoel Andres Granados <jgranado@redhat.com>2008-03-18 16:35:54 +0100
commit37213f2e0d8d30fc1467472723a81bb5febf32c1 (patch)
tree5ce1697df7278c167cd3d7577d9908a2e5dd8b4f /plugins/xserver.py
parent39e696915bd0c88efd1401eb4317b6347cb70961 (diff)
downloadfirstaidkit-37213f2e0d8d30fc1467472723a81bb5febf32c1.tar.gz
firstaidkit-37213f2e0d8d30fc1467472723a81bb5febf32c1.tar.xz
firstaidkit-37213f2e0d8d30fc1467472723a81bb5febf32c1.zip
Squashed commit of the following:
commit 810d6bd770533a8504a64983a4d7e2db406595df Author: Joel Andres Granados <jgranado@redhat.com> Date: Tue Mar 18 14:45:50 2008 +0100 fix some dependancy issues commit f4bc1ffdb49fadc9fb3de735e06729a40e7641ac Author: Joel Andres Granados <jgranado@redhat.com> Date: Tue Mar 18 14:42:20 2008 +0100 Include the utils package commit afaaf4dadbe0fb8137576059c3da1cdf62a318e8 Author: Joel Andres Granados <jgranado@redhat.com> Date: Tue Mar 18 14:27:33 2008 +0100 Fix license in setup.py commit 25442d8c09941126fde5b5d71d5287d0814d712f Author: Joel Andres Granados <jgranado@redhat.com> Date: Tue Mar 18 14:00:46 2008 +0100 Create the rpm subpackage for the xserver plugin
Diffstat (limited to 'plugins/xserver.py')
-rw-r--r--plugins/xserver.py37
1 files changed, 22 insertions, 15 deletions
diff --git a/plugins/xserver.py b/plugins/xserver.py
index c25e06c..b06fa2e 100644
--- a/plugins/xserver.py
+++ b/plugins/xserver.py
@@ -17,16 +17,18 @@
from pyfirstaidkit.plugins import Plugin,Flow
from pyfirstaidkit.returns import *
+from pyfirstaidkit.utils import *
from pyfirstaidkit.reporting import PLUGIN
from pyfirstaidkit import Config
import rhpxl.xserver
import rhpl.keyboard
-import temp
+import tempfile
import subprocess
import time
import signal
import os
+import os.path
import shutil
class Xserver(Plugin):
@@ -40,7 +42,7 @@ class Xserver(Plugin):
# Arbitrary test display
self.display = ":10"
# For when we need a temporary log.
- (self.tmpLogfd, self.tmpLogPath) = temp.mktemp()
+ (self.tmpLogfd, self.tmpLogPath) = tempfile.mkstemp()
self.confPath = "/etc/X11/xorg.conf"
def prepare(self):
@@ -58,12 +60,17 @@ class Xserver(Plugin):
# FIXME:Must change this when the backup utils is done.
def backup(self):
- if os.isfile(self.confPath):
+ if os.path.isfile(self.confPath):
self._reporting.info("Making copy of %s"%self.confPath, level = PLUGIN , origin = self)
- shutil.copyfile(self.confPath, "%s.FAK-backup"%self.confPath)
+ try:
+ shutil.copyfile(self.confPath, "%s.FAK-backup"%self.confPath)
+ self._result = ReturnSuccess
+ except:
+ self._result = ReturnFailure
else:
self._reporting.info("Expected path to configuration file seems to be nonexistent (%s)"%
self.confPath, level = PLUGIN, origin = self)
+ self._result = ReturnSuccess
def fix(self):
self._reporting.info("Starting the fix task.", level = PLUGIN, origin = self)
@@ -73,11 +80,11 @@ class Xserver(Plugin):
xserver.setHWState()
xserver.keyboard = rhpl.keyboard.Keyboard()
self._reporting.info("Generating configuration file.", level = PLUGIN, origin = self)
- xserver.generateCconfig()
+ xserver.generateConfig()
self._reporting.info("Writing configuration file to %s."%self.confPath, level = PLUGIN, origin = self)
xserver.writeConfig(self.confPath)
- self._reporting.info("Testing created file", leve = PLUGIN, origin = self)
+ self._reporting.info("Testing created file", level = PLUGIN, origin = self)
if self.serverStart():
self._reporting.info("X server started successfully with new file.", level = PLUGIN, origin = self)
self._result = ReturnSuccess
@@ -86,23 +93,23 @@ class Xserver(Plugin):
self._result = ReturnFailure
def restore(self):
- if os.isfile("%.FAK-backup"%self.confPath):
+ if os.path.isfile("%s.FAK-backup"%self.confPath):
self._reporting.info("Restoring original file.", level = PLUGIN , origin = self)
shutil.copyfile("%s.FAK-backup"%self.confPath, self.confPath)
else:
- self._reporting.info("The backed up file was not present, something strange is going on."%
- self.confPath, level = PLUGIN, origin = self)
+ self._reporting.info("The backedup file was not present, something strange is going on.",
+ level = PLUGIN, origin = self)
def clean(self):
- self._reporting.info("Cleaning the backed up file.", level = PLUGIN, origin = self)
- if os.isfile("%.FAK-backup"%self.confPath):
- os.rmfile("%.FAK-backup"%self.confPath)
+ self._reporting.info("Cleaning the backedup file.", level = PLUGIN, origin = self)
+ if os.path.isfile("%s.FAK-backup"%self.confPath):
+ os.remove("%s.FAK-backup"%self.confPath)
def serverStart(self):
self._reporting.info("Trying to start X server", level = PLUGIN, origin = self)
- xorgargs = ["--logfile", self.tmpLogPath, self.display]
+ xorgargs = ["-logfile", self.tmpLogPath, 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)
@@ -114,10 +121,10 @@ class Xserver(Plugin):
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)
- os.kill(proc.pid, signal.SIG_INT)
+ os.kill(proc.pid, signal.SIGINT)
return True
def get_plugin():
- return Xserver()
+ return Xserver