def main():
    try:
        signal.signal(signal.SIGTSTP, signal.SIG_IGN)  # ignore CTRL+Z
        signal.signal(signal.SIGINT, signal_handler)  # ignore CTRL+C
    except AttributeError: # Some systems may not support all signals
        pass

    if len(sys.argv) == 1:
        usage()

    dnsrecord = 'A'
    count = 10
    waittime = 5
    inputfilename = None
    fromfile = False
    hostname = 'wikipedia.org'

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hf:c:t:w:",
                                   ["help", "file=", "count=", "type=", "wait="])
    except getopt.GetoptError as err:
        print(err)
        usage()

    if args and len(args) == 1:
        hostname = args[0]
    else:
        usage()

    for o, a in opts:
        if o in ("-h", "--help"):
            usage()
        elif o in ("-c", "--count"):
            count = int(a)
        elif o in ("-f", "--file"):
            inputfilename = a
            fromfile = True
        elif o in ("-w", "--wait"):
            waittime = int(a)
        elif o in ("-t", "--type"):
            dnsrecord = a
        else:
            print("Invalid option: %s" % o)
            usage()

    try:
        if fromfile:
            with open(inputfilename, 'rt') as flist:
                f = flist.read().splitlines()
        else:
            f = resolvers
        if len(f) == 0:
            print("No nameserver specified")

        f = [ name.strip() for name in f]
        width = maxlen(f)
        blanks = (width - 5) * ' '
        print('server ', blanks, ' avg(ms)     min(ms)     max(ms)     stddev(ms)  lost(%)')
        print((60 + width) * '-')
        for server in f:
            if not server:
                continue
            (server, r_avg, r_min, r_max, r_stddev, r_lost_percent) = dnsping(hostname, server, dnsrecord, waittime, count)

            server = server.ljust(width + 1)
            print("%s    %-8.3f    %-8.3f    %-8.3f    %-8.3f    %%%d" % (
                server, r_avg, r_min, r_max, r_stddev, r_lost_percent))

    except Exception as e:
        print('error: %s' % e)
        exit(1)
dataset/ETHPy150Open farrokhi/dnstools/dnseval.py/main/original