Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/barseghyanartur/pif
Public IP address checker.
https://github.com/barseghyanartur/pif
ip ip-address ip-lookup python
Last synced: 13 days ago
JSON representation
Public IP address checker.
- Host: GitHub
- URL: https://github.com/barseghyanartur/pif
- Owner: barseghyanartur
- Created: 2013-08-31T10:25:20.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-11-29T21:26:12.000Z (12 months ago)
- Last Synced: 2024-10-13T07:45:30.388Z (28 days ago)
- Topics: ip, ip-address, ip-lookup, python
- Language: Python
- Homepage: https://pypi.python.org/pypi/pif
- Size: 113 KB
- Stars: 10
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE_GPL2.0.txt
Awesome Lists containing this project
README
===
pif
===
Discovers your public IP address using pre-defined checkers (external services).Prerequisites
=============
- Python 2.7, 3.4, 3.5, PyPyInstallation
============
Install with latest stable version from PyPI:.. code-block:: sh
pip install pif
or install the latest stable version from source:
.. code-block:: sh
pip install https://bitbucket.org/barseghyanartur/pif/get/stable.tar.gz
or install into python path:
.. code-block:: sh
python setup.py install
That's all. See the `Usage and examples`_ section for more.
Usage and examples
==================
Basic usage
-----------
Get public IP:.. code-block:: python
from pif import get_public_ip
get_public_ip()Get public IP using preferred checker:
.. code-block:: python
get_public_ip('v4.ident.me')
List available checkers:
.. code-block:: python
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... code-block:: python
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... code-block:: text
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)
.. code-block:: sh
get-public-ip
:Example: (with preferred checked and verbose output)
.. code-block:: sh
get-public-ip -c v4.ident.me -v 1
Testing
=======
Simply type:.. code-block:: sh
./runtests.py
or use tox:
.. code-block:: sh
tox
or use tox to check specific env:
.. code-block:: sh
tox -e py35
License
=======
GPL 2.0/LGPL 2.1Support
=======
For any issues contact me at the e-mail given in the `Author`_ section.Author
======
Artur Barseghyan