Advertisement
rfmonk

query_zc.py

Apr 18th, 2014
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # Thank you Charlie Miller
  3. # and thank you http://sourceforge.net/projects/pyzeroconf/
  4. # This url will get you the Zeroconf module.
  5.  
  6. import Zeroconf
  7.  
  8. class MyListener(object):
  9.     def removeService(self, server, type, name):
  10.         print "Service", repr(name), "removed"
  11.  
  12.     def addService(self, server, type, name):
  13.         print "Service", repr(name), "added"
  14.         # request more information from the service
  15.         try:
  16.             info = server.getServiceInfo(type, name)
  17.             print 'Additional info:', info
  18.         except:
  19.             pass
  20.  
  21. if __name__ == '__main__':
  22.     server = Zeroconf.Zeroconf()
  23.     listener = MyListener()
  24.     browser = Zeroconf.ServiceBrowser(server, "_ssh._tcp.local.", listener)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement