diff mbox

[KVM-AUTOTEST,16/26] KVM test: kvm_monitor: make MonitorSocketError.__init__() receive a socket.error

Message ID 1294751618-21631-16-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Jan. 11, 2011, 1:13 p.m. UTC
None
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_monitor.py b/client/tests/kvm/kvm_monitor.py
index 48d627f..8cf2441 100644
--- a/client/tests/kvm/kvm_monitor.py
+++ b/client/tests/kvm/kvm_monitor.py
@@ -22,7 +22,13 @@  class MonitorConnectError(MonitorError):
 
 
 class MonitorSocketError(MonitorError):
-    pass
+    def __init__(self, msg, e):
+        Exception.__init__(self, msg, e)
+        self.msg = msg
+        self.e = e
+
+    def __str__(self):
+        return "%s    (%s)" % (self.msg, self.e)
 
 
 class MonitorLockError(MonitorError):
@@ -120,8 +126,8 @@  class Monitor:
             try:
                 data = self._socket.recv(1024)
             except socket.error, e:
-                raise MonitorSocketError("Could not receive data from monitor "
-                                         "(%s)" % e)
+                raise MonitorSocketError("Could not receive data from monitor",
+                                         e)
             if not data:
                 break
             s += data
@@ -213,8 +219,8 @@  class HumanMonitor(Monitor):
             try:
                 self._socket.sendall(cmd + "\n")
             except socket.error, e:
-                raise MonitorSocketError("Could not send monitor command %r "
-                                         "(%s)" % (cmd, e))
+                raise MonitorSocketError("Could not send monitor command %r" %
+                                         cmd, e)
 
         finally:
             self._lock.release()
@@ -485,8 +491,7 @@  class QMPMonitor(Monitor):
         try:
             self._socket.sendall(data)
         except socket.error, e:
-            raise MonitorSocketError("Could not send data: %r (%s)" %
-                                     (data, e))
+            raise MonitorSocketError("Could not send data: %r" % data, e)
 
 
     def _get_response(self, id=None, timeout=20):