Skip to content

Instantly share code, notes, and snippets.

@ppa-odoo
Last active January 30, 2023 06:56
Show Gist options
  • Save ppa-odoo/e7a45697cb87e5d34e3027f53fd5d56e to your computer and use it in GitHub Desktop.
Save ppa-odoo/e7a45697cb87e5d34e3027f53fd5d56e to your computer and use it in GitHub Desktop.

Revisions

  1. PRASHANT revised this gist Mar 29, 2018. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion GeoIP.txt
    Original file line number Diff line number Diff line change
    @@ -18,4 +18,12 @@ from odoo.tools import config
    import os

    geofile = config.get('geoip_database')
    gio_data = GeoIP.open(geofile, GeoIP.GEOIP_STANDARD).record_by_addr('127.0.0.1')
    gio_data = GeoIP.open(geofile, GeoIP.GEOIP_STANDARD).record_by_addr('127.0.0.1')
    ================================================================================
    https://www.whatismyip.com/what-is-my-public-ip-address/
    https://github.com/odoo/iap-apps/blob/master-reveal-iap-dep/reveal_service/controllers/main.py
    https://packages.ubuntu.com/trusty/geoip-database-contrib
    https://github.com/maxmind/geoip-api-python/issues/20
    https://pypi.python.org/pypi/geoip2
    https://github.com/maxmind/geoip-api-python
    https://github.com/Xifax/goip-sms-bank/blob/master/manage.py
  2. PRASHANT created this gist Mar 29, 2018.
    21 changes: 21 additions & 0 deletions GeoIP.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    sudo add-apt-repository ppa:maxmind/ppa
    sudo apt update
    sudo apt install libgeoip1 libgeoip-dev geoip-bin
    sudo pip3 install GeoIP # For Python 3
    sudo apt-get install geoip-database-contrib
    ==================================================
    import GeoIP
    geofile = config.get('geoip_database')
    gio_data = GeoIP.open(geofile, GeoIP.GEOIP_STANDARD).record_by_addr(ip)
    return gio_data
    Database Update : geoip-database-contrib_update
    -----------------------------------------------------------------------------------------------
    import urllib
    import json

    import GeoIP
    from odoo.tools import config
    import os

    geofile = config.get('geoip_database')
    gio_data = GeoIP.open(geofile, GeoIP.GEOIP_STANDARD).record_by_addr('127.0.0.1')