diff options
-rw-r--r-- | constants.py | 2 | ||||
-rw-r--r-- | errors.py | 7 | ||||
-rw-r--r-- | lvm.py | 10 |
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") @@ -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") @@ -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) |