Opened 12 years ago
Last modified 12 years ago
#19168 closed Bug
GeoIP does not work properly under os X — at Initial Version
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | GIS | Version: | 1.4 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
django.contrib.gis.geoip.GeoIP does not read the city/country databases when called without any parameters. But when passing the city/country database files path explicitly to the init method, it works fine.
Here is example:
# Settings
GEOIP_PATH = os.path.join(PROJECT_DIR, 'bin', 'GeoIP')
GEOIP_COUNTRY = 'GeoIP.dat'
GEOIP_CITY = 'GeoLiteCity.dat'
In [1]: from django.contrib.gis.geoip import GeoIP
In [2]: geo = GeoIP()
In [3]: geo.info
Out[3]: 'GeoIP Library:\n\t1.4.8\nCountry:\n\t\nCity:\n\t'
In [4]: geo._city_file
Out[4]: Path(u'/Users/tejindersingh/Projects/kyb/bin/GeoIP/GeoLiteCity.dat')
In [5]: geo._country_file
Out[5]: Path(u'/Users/tejindersingh/Projects/kyb/bin/GeoIP/GeoIP.dat')
In [6]: geo.city('8.8.8.8')
Invalid database type GeoIP Country Edition, expected GeoIP City Edition, Rev 1
Doing same thing passing the path as parameters:
In [7]: geo = GeoIP(city='/Users/tejindersingh/Projects/kyb/bin/GeoIP/GeoLiteCity.dat', country='/Users/tejindersingh/Projects/kyb/bin/GeoIP/GeoIP.dat')
In [8]: geo.info
Out[8]: 'GeoIP Library:\n\t1.4.8\nCountry:\n\tGEO-106FREE 20120207 Build 1 Copyright (c) 2011 MaxMind Inc All Rights Reserved\nCity:\n\tGEO-533LITE 20121002 Build 1 Copyright (c) 2012 MaxMind Inc All Rights Reserved'
In [9]: geo._city_file
Out[9]: '/Users/tejindersingh/Projects/kyb/bin/GeoIP/GeoLiteCity.dat'
In [10]: geo._country_file
Out[10]: '/Users/tejindersingh/Projects/kyb/bin/GeoIP/GeoIP.dat'
In [11]: geo.city('8.8.8.8')
Out[11]:
{'area_code': 650,
'charset': 0,
'city': u'Mountain View',
'continent_code': u'NA',
'country_code': u'US',
'country_code3': u'USA',
'country_name': u'United States',
'dma_code': 807,
'latitude': 37.4192008972168,
'longitude': -122.05740356445312,
'postal_code': u'94043',
'region': u'CA'}
This happens under ox X mountain lion and with kyngchaos gis/gdal binary packages as well as self compile brews.