diff options
author | Yann Leboulanger <asterix@lagaule.org> | 2008-04-15 19:58:07 +0400 |
---|---|---|
committer | Yann Leboulanger <asterix@lagaule.org> | 2008-04-15 19:58:07 +0400 |
commit | 1a2f60186acf507b5d1a57973e3a6665bd9eada0 (patch) | |
tree | 9fd96a4efb50e721aa2f3e94ff387db3c34e9ac2 /src | |
parent | edb5910c1db2232b31a616b979cda8306c1b06f6 (diff) |
Don't fail on windows if bonjour is not installed. fixes #3861
socket module doesn't have AI_ADDRCONFIG attribute under windows
Diffstat (limited to 'src')
-rw-r--r-- | src/common/zeroconf/client_zeroconf.py | 7 | ||||
-rw-r--r-- | src/common/zeroconf/connection_zeroconf.py | 2 | ||||
-rw-r--r-- | src/common/zeroconf/zeroconf.py | 2 |
3 files changed, 8 insertions, 3 deletions
diff --git a/src/common/zeroconf/client_zeroconf.py b/src/common/zeroconf/client_zeroconf.py index c60834525..2599ca141 100644 --- a/src/common/zeroconf/client_zeroconf.py +++ b/src/common/zeroconf/client_zeroconf.py @@ -58,9 +58,12 @@ class ZeroconfListener(IdleObject): self.caller = conn_holder.caller self.conn_holder = conn_holder - def bind(self): + def bind(self):
+ flags = socket.AI_PASSIVE
+ if hasattr(socket, 'AI_ADDRCONFIG'):
+ flags |= socket.AI_ADDRCONFIG) ai = socket.getaddrinfo(None, self.port, socket.AF_UNSPEC, - socket.SOCK_STREAM, 0, socket.AI_PASSIVE | socket.AI_ADDRCONFIG)[0] + socket.SOCK_STREAM, 0, flags)[0] self._serv = socket.socket(ai[0], ai[1]) self._serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self._serv.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) diff --git a/src/common/zeroconf/connection_zeroconf.py b/src/common/zeroconf/connection_zeroconf.py index b0bab07c8..f57338403 100644 --- a/src/common/zeroconf/connection_zeroconf.py +++ b/src/common/zeroconf/connection_zeroconf.py @@ -246,7 +246,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): self.status = 'offline' self.dispatch('CONNECTION_LOST', (_('Could not connect to "%s"') % self.name, - _('Please check if Avahi is installed.'))) + _('Please check if Avahi or Bonjour is installed.'))) self.disconnect() return result = self.connection.connect(show, msg) diff --git a/src/common/zeroconf/zeroconf.py b/src/common/zeroconf/zeroconf.py index 8d8e70185..c33ff48c3 100644 --- a/src/common/zeroconf/zeroconf.py +++ b/src/common/zeroconf/zeroconf.py @@ -31,6 +31,8 @@ def test_bonjour(): try: import pybonjour except ImportError: + return False
+ except WindowsError:
return False return True |