Mercurial > hg
comparison hgext/zeroconf/__init__.py @ 7295:66d0fc108044
zeroconf: Don't break serve if no internet connection is present.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Wed, 29 Oct 2008 18:54:46 -0500 |
parents | 6541696b5f66 |
children | e86ca711544d |
comparison
equal
deleted
inserted
replaced
7294:f933076a19fc | 7295:66d0fc108044 |
---|---|
44 return dumbip | 44 return dumbip |
45 | 45 |
46 def publish(name, desc, path, port): | 46 def publish(name, desc, path, port): |
47 global server, localip | 47 global server, localip |
48 if not server: | 48 if not server: |
49 server = Zeroconf.Zeroconf() | 49 try: |
50 server = Zeroconf.Zeroconf() | |
51 except socket.gaierror: | |
52 # if we have no internet connection, this can happen. | |
53 return | |
50 ip = getip() | 54 ip = getip() |
51 localip = socket.inet_aton(ip) | 55 localip = socket.inet_aton(ip) |
52 | 56 |
53 parts = socket.gethostname().split('.') | 57 parts = socket.gethostname().split('.') |
54 host = parts[0] + ".local" | 58 host = parts[0] + ".local" |