diff options
Diffstat (limited to 'netdisco/__main__.py')
-rw-r--r-- | netdisco/__main__.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/netdisco/__main__.py b/netdisco/__main__.py new file mode 100644 index 0000000..64037f0 --- /dev/null +++ b/netdisco/__main__.py @@ -0,0 +1,35 @@ +"""Command line tool to print discocvered devices or dump raw data.""" +from pprint import pprint +import sys + +from netdisco.discovery import NetworkDiscovery + + +def main(): + """Handle command line execution.""" + netdisco = NetworkDiscovery() + + netdisco.scan() + + print("Discovered devices:") + count = 0 + for dev in netdisco.discover(): + count += 1 + print('{}:'.format(dev)) + pprint(netdisco.get_info(dev)) + print() + print("Discovered {} devices".format(count)) + + # Pass in command line argument dump to get the raw data + if sys.argv[-1] == 'dump': + print() + print() + print("Raw Data") + print() + netdisco.print_raw_data() + + netdisco.stop() + + +if __name__ == '__main__': + main() |