===
pif
===
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:
.. 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.1
Support
=======
For any issues contact me at the e-mail given in the `Author` section.
Author
======
Artur Barseghyan <artur.barseghyan@gmail.com>
Raw data
{
"_id": null,
"home_page": "https://github.com/barseghyanartur/pif",
"name": "pif",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "public ip checker,ip",
"author": "Artur Barseghyan",
"author_email": "artur.barseghyan@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/be/92/77fec5e8eded1e3c53d43e36a0a8c5463cdaa4af991c65e4dc6cc14a2fb4/pif-0.8.2.tar.gz",
"platform": "UNKNOWN",
"description": "===\npif\n===\nDiscovers your public IP address using pre-defined checkers (external services).\n\nPrerequisites\n=============\n- Python 2.7, 3.4, 3.5, PyPy\n\nInstallation\n============\nInstall with latest stable version from PyPI:\n\n.. code-block:: sh\n\n pip install pif\n\nor install the latest stable version from source:\n\n.. code-block:: sh\n\n pip install https://bitbucket.org/barseghyanartur/pif/get/stable.tar.gz\n\nor install into python path:\n\n.. code-block:: sh\n\n python setup.py install\n\nThat's all. See the `Usage and examples`_ section for more.\n\nUsage and examples\n==================\nBasic usage\n-----------\nGet public IP:\n\n.. code-block:: python\n\n from pif import get_public_ip\n get_public_ip()\n\nGet public IP using preferred checker:\n\n.. code-block:: python\n\n get_public_ip('v4.ident.me')\n\nList available checkers:\n\n.. code-block:: python\n\n from pif.utils import list_checkers\n list_checkers()\n\nRegistering a custom IP checker\n-------------------------------\n`pif` ships with a number of pre-defined public IP checkers. But you may extend\nit by defining your own ones as follows.\n\n.. code-block:: python\n\n from pif.base import BaseIPChecker, registry\n\n class MyPublicIPChecker(BaseIPChecker):\n\n uid = 'mypublicipchecker' # UID of the checker\n\n def get_public_ip(self):\n # TODO: Implement your logic\n\n\n # Register the checker\n registry.register(MyPublicIPChecker)\n\n # Get public IP using the preferred checker\n get_public_ip('mypublicipchecker')\n\nCommand line usage\n------------------\nIt's possible to get your public IP address from command line using the\n`pif.commands.get_public_ip` module.\n\n.. code-block:: text\n\n optional arguments:\n -h, --help show this help message and exit\n -c PREFERRED_CHECKER, --checker PREFERRED_CHECKER\n `preferred_checker` value\n -v VERBOSE, --verbose VERBOSE\n `verbose` value\n\n:Example: (simple)\n\n.. code-block:: sh\n\n get-public-ip\n\n:Example: (with preferred checked and verbose output)\n\n.. code-block:: sh\n\n get-public-ip -c v4.ident.me -v 1\n\nTesting\n=======\nSimply type:\n\n.. code-block:: sh\n\n ./runtests.py\n\nor use tox:\n\n.. code-block:: sh\n\n tox\n\nor use tox to check specific env:\n\n.. code-block:: sh\n\n tox -e py35\n\nLicense\n=======\nGPL 2.0/LGPL 2.1\n\nSupport\n=======\nFor any issues contact me at the e-mail given in the `Author` section.\n\nAuthor\n======\nArtur Barseghyan <artur.barseghyan@gmail.com>",
"bugtrack_url": null,
"license": "GPL 2.0/LGPL 2.1",
"summary": "Public IP address checker.",
"version": "0.8.2",
"project_urls": {
"Homepage": "https://github.com/barseghyanartur/pif"
},
"split_keywords": [
"public ip checker",
"ip"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "204211a03f86acb097f2a1ec329524eecae806cc76ed9fe496bd127e198d895a",
"md5": "e4f3a34146f032f313992228fdbffdd7",
"sha256": "dbd3a5032ed8417780d3632e226ea67438751939adbb95e90f471a4565fe95fb"
},
"downloads": -1,
"filename": "pif-0.8.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "e4f3a34146f032f313992228fdbffdd7",
"packagetype": "bdist_wheel",
"python_version": "any",
"requires_python": null,
"size": 19838,
"upload_time": "2016-12-22T15:28:50",
"upload_time_iso_8601": "2016-12-22T15:28:50.659203Z",
"url": "https://files.pythonhosted.org/packages/20/42/11a03f86acb097f2a1ec329524eecae806cc76ed9fe496bd127e198d895a/pif-0.8.2-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "be9277fec5e8eded1e3c53d43e36a0a8c5463cdaa4af991c65e4dc6cc14a2fb4",
"md5": "7349c994f8601ab3796d26900fd845dc",
"sha256": "5ee4a13a52a6facefb510c4740a28bc33f16ae7fe3b2cc523080102dfddf5bbb"
},
"downloads": -1,
"filename": "pif-0.8.2.tar.gz",
"has_sig": false,
"md5_digest": "7349c994f8601ab3796d26900fd845dc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 21052,
"upload_time": "2016-12-22T15:28:35",
"upload_time_iso_8601": "2016-12-22T15:28:35.730626Z",
"url": "https://files.pythonhosted.org/packages/be/92/77fec5e8eded1e3c53d43e36a0a8c5463cdaa4af991c65e4dc6cc14a2fb4/pif-0.8.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2016-12-22 15:28:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "barseghyanartur",
"github_project": "pif",
"travis_ci": false,
"coveralls": true,
"github_actions": false,
"tox": true,
"lcname": "pif"
}