Coverage for mfutil/cli_tools/get_ip_for_hostname.py: 0%
16 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-13 15:33 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-13 15:33 +0000
1import argparse
2import sys
3from mfutil.net import get_ip_for_hostname, get_real_ip
5DESCRIPTION = "returns the IP address of the given HOSTNAME (current real IP "\
6 " if no hostname is given)"
9def main():
10 parser = argparse.ArgumentParser(description=DESCRIPTION)
11 parser.add_argument("hostname", nargs='?',
12 help="hostname to resolve as ip (can be empty)")
13 args = parser.parse_args()
14 if args.hostname is None:
15 res = get_real_ip()
16 else:
17 res = get_ip_for_hostname(args.hostname)
18 if res is not None:
19 print(res)
20 else:
21 sys.exit(1)
24if __name__ == '__main__':
25 main()