Skip to content

Commit 8328aed

Browse files
committed
Refactor browser example
1 parent 49af263 commit 8328aed

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

examples/browser.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
from __future__ import absolute_import, division, print_function, unicode_literals
23

34
""" Example of browsing for a service (in this case, HTTP) """
45

@@ -10,11 +11,10 @@
1011
class MyListener(object):
1112

1213
def removeService(self, zeroconf, type, name):
13-
print()
1414
print("Service %s removed" % (name,))
15+
print('\n')
1516

1617
def addService(self, zeroconf, type, name):
17-
print()
1818
print("Service %s added" % (name,))
1919
print(" Type is %s" % (type,))
2020
info = zeroconf.getServiceInfo(type, name)
@@ -29,14 +29,16 @@ def addService(self, zeroconf, type, name):
2929
print(" Properties are")
3030
for key, value in prop.items():
3131
print(" %s: %s" % (key, value))
32+
else:
33+
print(" No info")
34+
print('\n')
3235

3336
if __name__ == '__main__':
34-
print("Multicast DNS Service Discovery for Python Browser test")
3537
zeroconf = Zeroconf()
36-
print("Testing browsing for a service...")
38+
print("Browsing services...")
3739
listener = MyListener()
3840
browser = ServiceBrowser(zeroconf, "_http._tcp.local.", listener)
3941
try:
40-
raw_input("Waiting (press Enter to exit)...")
42+
raw_input("Waiting (press Enter to exit)...\n\n")
4143
finally:
4244
zeroconf.close()

0 commit comments

Comments
 (0)