You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
769 B

4 years ago
  1. """Command line tool to print discocvered devices or dump raw data."""
  2. from pprint import pprint
  3. import sys
  4. from netdisco.discovery import NetworkDiscovery
  5. def main():
  6. """Handle command line execution."""
  7. netdisco = NetworkDiscovery()
  8. netdisco.scan()
  9. print("Discovered devices:")
  10. count = 0
  11. for dev in netdisco.discover():
  12. count += 1
  13. print('{}:'.format(dev))
  14. pprint(netdisco.get_info(dev))
  15. print()
  16. print("Discovered {} devices".format(count))
  17. # Pass in command line argument dump to get the raw data
  18. if sys.argv[-1] == 'dump':
  19. print()
  20. print()
  21. print("Raw Data")
  22. print()
  23. netdisco.print_raw_data()
  24. netdisco.stop()
  25. if __name__ == '__main__':
  26. main()