def test_05_get_public_ip_using_preferred_checker_dyndns(self): """ Test get IP using preferred checker `dyndns.com`. """ res = get_public_ip('dyndns.com', verbose=True) assert res return res
def test_04_get_public_ip_using_preferred_checker_ident(self): """ Test get IP using preferred checker `ident.me`. """ res = get_public_ip('ident.me', verbose=True) assert res return res
def test_03_get_public_ip_using_preferred_checker_whatismyip(self): """ Test get IP using preferred checker `whatismyip.com`. """ res = get_public_ip('whatismyip.com', verbose=True) assert res return res
def test_02_get_public_ip(self): """ Test get IP. """ res = get_public_ip(verbose=True) assert res return res
def main(): """ Get public IP. :example: $ python src/pif/get_public_ip.py -pc user """ parser = argparse.ArgumentParser(description=""" Get public IP. """) parser.add_argument("-c", "--checker", dest="preferred_checker", type=str, help="`preferred_checker` value", metavar="PREFERRED_CHECKER") parser.add_argument("-v", "--verbose", dest="verbose", type=str, help="`verbose` value", metavar="VERBOSE") args = parser.parse_args() kwargs = {} if args.preferred_checker: kwargs.update({'preferred_checker': args.preferred_checker}) verbose = None try: verbose = bool(int(args.preferred_checker)) kwargs.update({'verbose': verbose}) except: pass try: public_ip = get_public_ip(**kwargs) print(public_ip) except Exception as e: print(e)
def main(): """Get public IP. :example: $ python src/pif/get_public_ip.py -pc user """ parser = argparse.ArgumentParser(description="""Get public IP.""") parser.add_argument("-c", "--checker", dest="preferred_checker", type=str, help="`preferred_checker` value", metavar="PREFERRED_CHECKER") parser.add_argument("-v", "--verbose", dest="verbose", type=str, help="`verbose` value", metavar="VERBOSE") args = parser.parse_args() kwargs = {} if args.preferred_checker: kwargs.update({'preferred_checker': args.preferred_checker}) verbose = None try: verbose = bool(int(args.verbose)) kwargs.update({'verbose': verbose}) except Exception as err: pass try: public_ip = get_public_ip(**kwargs) print(public_ip) except Exception as err: print(err)