Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Public IP address checker.

Project Description

Discovers your public IP address using pre-defined checkers (external services).

Prerequisites

  • Python 2.7, 3.4, 3.5, PyPy

Installation

Install with latest stable version from PyPI:

pip install pif

or install the latest stable version from source:

pip install https://bitbucket.org/barseghyanartur/pif/get/stable.tar.gz

or install into python path:

python setup.py install

That’s all. See the Usage and examples section for more.

Usage and examples

Basic usage

Get public IP:

from pif import get_public_ip
get_public_ip()

Get public IP using preferred checker:

get_public_ip('v4.ident.me')

List available checkers:

from pif.utils import list_checkers
list_checkers()

Registering a custom IP checker

pif ships with a number of pre-defined public IP checkers. But you may extend it by defining your own ones as follows.

from pif.base import BaseIPChecker, registry

class MyPublicIPChecker(BaseIPChecker):

    uid = 'mypublicipchecker' # UID of the checker

    def get_public_ip(self):
        # TODO: Implement your logic


# Register the checker
registry.register(MyPublicIPChecker)

# Get public IP using the preferred checker
get_public_ip('mypublicipchecker')

Command line usage

It’s possible to get your public IP address from command line using the pif.commands.get_public_ip module.

optional arguments:
  -h, --help            show this help message and exit
  -c PREFERRED_CHECKER, --checker PREFERRED_CHECKER
                        `preferred_checker` value
  -v VERBOSE, --verbose VERBOSE
                    `verbose` value
Example:(simple)
get-public-ip
Example:(with preferred checked and verbose output)
get-public-ip -c v4.ident.me -v 1

Testing

Simply type:

./runtests.py

or use tox:

tox

or use tox to check specific env:

tox -e py35

License

GPL 2.0/LGPL 2.1

Support

For any issues contact me at the e-mail given in the Author section.

Author

Artur Barseghyan <artur.barseghyan@gmail.com>

Release History

Release History

This version
History Node

0.8.2

History Node

0.8.1

History Node

0.8

History Node

0.7.4

History Node

0.7.3

History Node

0.7.2

History Node

0.7.1

History Node

0.7

History Node

0.6

History Node

0.5

History Node

0.4

History Node

0.3

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pif-0.8.2-py2.py3-none-any.whl (19.8 kB) Copy SHA256 Checksum SHA256 any Wheel Dec 22, 2016
pif-0.8.2.tar.gz (21.1 kB) Copy SHA256 Checksum SHA256 Source Dec 22, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting