Make bonjour errors in the wireless driver non-fatal.

This commit is contained in:
Charles Haley 2012-09-28 17:37:41 +02:00
parent 8bbfc19472
commit b2ec03c7d5

View File

@ -1276,35 +1276,33 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
'_calibresmartdeviceapp._tcp', port, {}, '_calibresmartdeviceapp._tcp', port, {},
use_ip_address=ip_addr) use_ip_address=ip_addr)
except: except:
message = 'registration with bonjour failed' self._debug('registration with bonjour failed')
self._debug(message) traceback.print_exc()
self._close_listen_socket()
return message
self._debug('listening on port', port) self._debug('listening on port', port)
self.port = port self.port = port
# Now try to open a UDP socket to receive broadcasts on # Now try to open a UDP socket to receive broadcasts on
message = None
try: try:
self.broadcast_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.broadcast_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
except: except:
message = 'creation of broadcast socket failed. This is not fatal.' message = 'creation of broadcast socket failed. This is not fatal.'
self._debug(message) self._debug(message)
return message
for p in self.BROADCAST_PORTS:
port = self._attach_to_port(self.broadcast_socket, p)
if port != 0:
self._debug('broadcast socket listening on port', port)
break
message = None
if port == 0:
self.broadcast_socket.close()
self.broadcast_socket = None self.broadcast_socket = None
message = 'attaching port to broadcast socket failed. This is not fatal.' else:
self._debug(message) for p in self.BROADCAST_PORTS:
port = self._attach_to_port(self.broadcast_socket, p)
if port != 0:
self._debug('broadcast socket listening on port', port)
break
if port == 0:
self.broadcast_socket.close()
self.broadcast_socket = None
message = 'attaching port to broadcast socket failed. This is not fatal.'
self._debug(message)
self.connection_queue = Queue.Queue(1) self.connection_queue = Queue.Queue(1)
self.connection_listener = ConnectionListener(self) self.connection_listener = ConnectionListener(self)