File: __main__.py

package info (click to toggle)
python-netdisco 2.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 516 kB
  • sloc: python: 1,550; xml: 247; sh: 10; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 769 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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()