summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2008-08-08 15:57:41 -0400
committerPeter Jones <pjones@pjones2.localdomain>2008-08-08 15:57:41 -0400
commita9e04cc7ee472112259eb0868c43d118c2f09a92 (patch)
tree758452a1455980dc744e31bb0591c30ca54098c7
parent7a3f0f3e612c28dfd1df1ee81365c8a56c14c735 (diff)
downloadanaconda-a9e04cc7ee472112259eb0868c43d118c2f09a92.tar.gz
anaconda-a9e04cc7ee472112259eb0868c43d118c2f09a92.tar.xz
anaconda-a9e04cc7ee472112259eb0868c43d118c2f09a92.zip
Fix LVM error handling so the exceptions actually get into the namespace.
-rw-r--r--constants.py2
-rw-r--r--errors.py7
-rw-r--r--lvm.py10
3 files changed, 11 insertions, 8 deletions
diff --git a/constants.py b/constants.py
index 19bde3c1e..9c4fbb12c 100644
--- a/constants.py
+++ b/constants.py
@@ -69,6 +69,8 @@ productArch = product.productArch
productPath = product.productPath
bugzillaUrl = product.bugUrl
+lvmErrorOutput = "/tmp/lvmout"
+
exceptionText = _("An unhandled exception has occurred. This "
"is most likely a bug. Please save a copy of "
"the detailed exception and file a bug report")
diff --git a/errors.py b/errors.py
index b0f663c4d..e7bc3ce5f 100644
--- a/errors.py
+++ b/errors.py
@@ -24,7 +24,8 @@
#
import string
-from lvm import output
+import os
+from constants import lvmErrorOutput
"""Exceptions for use in lvm operations."""
@@ -36,7 +37,9 @@ class LvmError(Exception):
self.log = self.getLvmOutput()
def getLvmOutput(self):
- f = open(output, "r")
+ if not os.access(lvmErrorOutput, os.R_OK):
+ return ""
+ f = open(lvmErrorOutput, "r")
lines = reduce(lambda x,y: x + [string.strip(y),], f.readlines(), [])
lines = string.join(reduce(lambda x,y: x + [" %s" % (y,)], \
lines, []), "\n")
diff --git a/lvm.py b/lvm.py
index 6d8e7cc2b..70d510809 100644
--- a/lvm.py
+++ b/lvm.py
@@ -34,8 +34,6 @@ from constants import *
MAX_LV_SLOTS=256
-output = "/tmp/lvmout"
-
lvmDevicePresent = 0
from errors import *
@@ -65,15 +63,15 @@ has_lvm()
def lvmExec(*args):
try:
- return iutil.execWithRedirect("lvm", args, stdout = output,
- stderr = output, searchPath = 1)
+ return iutil.execWithRedirect("lvm", args, stdout = lvmErrorOutput,
+ stderr = lvmErrorOutput, searchPath = 1)
except Exception, e:
log.error("error running lvm command: %s" %(e,))
raise LvmError, args[0]
def lvmCapture(*args):
try:
- lvmout = iutil.execWithCapture("lvm", args, stderr = output)
+ lvmout = iutil.execWithCapture("lvm", args, stderr = lvmErrorOutput)
lines = []
for line in lvmout.split("\n"):
lines.append(line.strip().split(':'))
@@ -326,7 +324,7 @@ def pvcreate(node):
except:
rc = 1
if rc:
- raise PVCreateError(node)
+ raise PVCreateError, node
unlinkConf()
wipeOtherMetadataFromPV(node)