Show More
@@ -51,9 +51,12 b' def getip():' | |||||
51 | pass |
|
51 | pass | |
52 |
|
52 | |||
53 | # Generic method, sometimes gives useless results |
|
53 | # Generic method, sometimes gives useless results | |
54 | dumbip = socket.gethostbyaddr(socket.gethostname())[2][0] |
|
54 | try: | |
55 | if not dumbip.startswith('127.') and ':' not in dumbip: |
|
55 | dumbip = socket.gethostbyaddr(socket.gethostname())[2][0] | |
56 | return dumbip |
|
56 | if not dumbip.startswith('127.') and ':' not in dumbip: | |
|
57 | return dumbip | |||
|
58 | except socket.gaierror: | |||
|
59 | dumbip = '127.0.0.1' | |||
57 |
|
60 | |||
58 | # works elsewhere, but actually sends a packet |
|
61 | # works elsewhere, but actually sends a packet | |
59 | try: |
|
62 | try: | |
@@ -69,13 +72,12 b' def getip():' | |||||
69 | def publish(name, desc, path, port): |
|
72 | def publish(name, desc, path, port): | |
70 | global server, localip |
|
73 | global server, localip | |
71 | if not server: |
|
74 | if not server: | |
72 | try: |
|
75 | ip = getip() | |
73 | server = Zeroconf.Zeroconf() |
|
76 | if ip.startswith('127.'): | |
74 | except socket.gaierror: |
|
|||
75 | # if we have no internet connection, this can happen. |
|
77 | # if we have no internet connection, this can happen. | |
76 | return |
|
78 | return | |
77 | ip = getip() |
|
|||
78 | localip = socket.inet_aton(ip) |
|
79 | localip = socket.inet_aton(ip) | |
|
80 | server = Zeroconf.Zeroconf(ip) | |||
79 |
|
81 | |||
80 | hostname = socket.gethostname().split('.')[0] |
|
82 | hostname = socket.gethostname().split('.')[0] | |
81 | host = hostname + ".local" |
|
83 | host = hostname + ".local" | |
@@ -129,7 +131,10 b' class listener(object):' | |||||
129 | self.found[repr(name)] = server.getServiceInfo(type, name) |
|
131 | self.found[repr(name)] = server.getServiceInfo(type, name) | |
130 |
|
132 | |||
131 | def getzcpaths(): |
|
133 | def getzcpaths(): | |
132 | server = Zeroconf.Zeroconf() |
|
134 | ip = getip() | |
|
135 | if ip.startswith('127.'): | |||
|
136 | return | |||
|
137 | server = Zeroconf.Zeroconf(ip) | |||
133 | l = listener() |
|
138 | l = listener() | |
134 | Zeroconf.ServiceBrowser(server, "_hg._tcp.local.", l) |
|
139 | Zeroconf.ServiceBrowser(server, "_hg._tcp.local.", l) | |
135 | time.sleep(1) |
|
140 | time.sleep(1) |
General Comments 0
You need to be logged in to leave comments.
Login now