Пример #1
0
 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
Пример #2
0
 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
Пример #3
0
 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
Пример #4
0
 def test_02_get_public_ip(self):
     """
     Test get IP.
     """
     res = get_public_ip(verbose=True)
     assert res
     return res
Пример #5
0
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)
Пример #6
0
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)