Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8328aed

Browse filesBrowse files
committed
Refactor browser example
1 parent 49af263 commit 8328aed
Copy full SHA for 8328aed

File tree

Expand file treeCollapse file tree

1 file changed

+7
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-5
lines changed

‎examples/browser.py

Copy file name to clipboardExpand all lines: examples/browser.py
+7-5Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.