Author: gnichols
Date: 2011-03-16 00:07:25 +0000 (Wed, 16 Mar 2011)
New Revision: 817
Modified:
trunk/v7/command.py
Log:
682115 - RHEL 6.1 fv tests fail on spuriou stderr output of virt-install and kpartx
Modified: trunk/v7/command.py
===================================================================
--- trunk/v7/command.py 2011-03-16 00:07:15 UTC (rev 816)
+++ trunk/v7/command.py 2011-03-16 00:07:25 UTC (rev 817)
@@ -66,7 +66,7 @@
def _checkErrors(self):
if self.errors and len(self.errors) > 0:
- raise V7CommandException(self, "has output on stderr")
+ raise V7CommandErrorOutput(self)
if self.returnValue != 0 or self.signal != 0:
# if error returned, show stdout whether echo or run was called
if self.output:
@@ -75,9 +75,9 @@
sys.stdout.write("\n")
sys.stdout.flush()
if self.returnValue != 0:
- raise V7CommandException(self, "returned %d" %
self.returnValue)
+ raise V7CommandErrorReturned(self, self.returnValue)
if self.signal != 0:
- raise V7CommandException(self, "was killed, signal %d" %
self.signal)
+ raise V7CommandErrorKilled(self, self.signal)
def run(self):
""" This method runs the command to produce an action. Any output
@@ -234,6 +234,17 @@
# otherwise, command never started
raise V7CommandException(self.command, "call to poll() before
start()")
+
+# V7 Command Exceptions:
+# These exceptions are organized in a type hierarch to allow different levels of
exceptions
+# to be caught and handled:
+#
+# V7CommandException - all exceptions raised by Command
+# V7CommandError - commands that either returned non-zero, or were
killed
+# V7CommandErrorReturned - commands that returned non-zero
+# V7CommandErrorKilled - commands that were killed via signal
+# V7CommandErrorOutput - commands that had output on stderr
+
class V7CommandException(Exception):
def __init__(self, command, message):
@@ -250,8 +261,23 @@
def _set_message(self, value): self.__message = value
message = property(_get_message, _set_message)
-
+class V7CommandErrorOutput(V7CommandException):
+ def __init__(self, command):
+ V7CommandException.__init__(self, command, "has output on stderr")
+
+class V7CommandError(V7CommandException):
+ def __init__(self, command, message):
+ V7CommandException.__init__(self, command, message)
+
+class V7CommandErrorReturned(V7CommandError):
+ def __init__(self, command, returnValue):
+ V7CommandError.__init__(self, command, "returned %d" % returnValue)
+
+class V7CommandErrorKilled(V7CommandError):
+ def __init__(self, command, signal):
+ V7CommandError.__init__(self, command, "signal %d" % signal)
+
def unitTest():
result = True
try:
Show replies by date