1
1
#!/usr/bin/env python
2
+ from __future__ import absolute_import , division , print_function , unicode_literals
2
3
3
4
""" Example of browsing for a service (in this case, HTTP) """
4
5
10
11
class MyListener (object ):
11
12
12
13
def removeService (self , zeroconf , type , name ):
13
- print ()
14
14
print ("Service %s removed" % (name ,))
15
+ print ('\n ' )
15
16
16
17
def addService (self , zeroconf , type , name ):
17
- print ()
18
18
print ("Service %s added" % (name ,))
19
19
print (" Type is %s" % (type ,))
20
20
info = zeroconf .getServiceInfo (type , name )
@@ -29,14 +29,16 @@ def addService(self, zeroconf, type, name):
29
29
print (" Properties are" )
30
30
for key , value in prop .items ():
31
31
print (" %s: %s" % (key , value ))
32
+ else :
33
+ print (" No info" )
34
+ print ('\n ' )
32
35
33
36
if __name__ == '__main__' :
34
- print ("Multicast DNS Service Discovery for Python Browser test" )
35
37
zeroconf = Zeroconf ()
36
- print ("Testing browsing for a service ..." )
38
+ print ("Browsing services ..." )
37
39
listener = MyListener ()
38
40
browser = ServiceBrowser (zeroconf , "_http._tcp.local." , listener )
39
41
try :
40
- raw_input ("Waiting (press Enter to exit)..." )
42
+ raw_input ("Waiting (press Enter to exit)...\n \n " )
41
43
finally :
42
44
zeroconf .close ()
0 commit comments