Bug 734715 - Improve devicemanagerSUT socket diagnostics. r=jmaher

This commit is contained in:
Geoff Brown 2012-04-03 20:08:27 -04:00
parent 4adff58654
commit 36079426b2

View File

@ -199,17 +199,17 @@ class DeviceManagerSUT(DeviceManager):
if self.debug >= 1:
print "reconnecting socket"
self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except:
except socket.error, msg:
self._sock = None
raise AgentError("unable to create socket")
raise AgentError("unable to create socket: "+str(msg))
try:
self._sock.connect((self.host, int(self.port)))
self._sock.recv(1024)
except:
except socket.error, msg:
self._sock.close()
self._sock = None
raise AgentError("unable to connect socket")
raise AgentError("unable to connect socket: "+str(msg))
for cmd in cmdlist:
if newline: cmd += '\r\n'
@ -220,9 +220,11 @@ class DeviceManagerSUT(DeviceManager):
raise AgentError("ERROR: our cmd was %s bytes and we only sent %s" % (len(cmd),
numbytes))
if (self.debug >= 4): print "send cmd: " + str(cmd)
except:
except socket.error, msg:
self._sock.close()
self._sock = None
if self.debug >= 1:
print "Error sending data to socket. cmd="+str(cmd)+"; err="+str(msg)
return False
# Check if the command should close the socket
@ -242,10 +244,10 @@ class DeviceManagerSUT(DeviceManager):
try:
temp = self._sock.recv(1024)
if (self.debug >= 4): print "response: " + str(temp)
except:
except socket.error, msg:
self._sock.close()
self._sock = None
raise AgentError("Error receiving data from socket")
raise AgentError("Error receiving data from socket. cmd="+str(cmd)+"; err="+str(msg))
data += temp