SHOW:
|
|
- or go back to the newest paste.
1 | #! /usr/bin/env python | |
2 | ||
3 | import pygeoip | |
4 | gi = pygeoip.GeoIP('/opt/GeoIP/Geo.dat') | |
5 | def printRecord(tgt): | |
6 | rec = gi.record_by_name(tgt) | |
7 | city = rec['city'] | |
8 | region = rec['region_name'] | |
9 | country = rec['country_name'] | |
10 | long = rec['longitude'] | |
11 | lat = rec['latitude'] | |
12 | print '[*] Target: ' + tgt + 'Geo-located. ' | |
13 | print '[+] '+str(city)+', '+str(region)+', '+str(country) | |
14 | print '[+] Latitude: '+str(lat)+ ', Longitude: '+ str(long) | |
15 | ||
16 | tgt = '50.19.217.109' | |
17 | - | printRecord(tgt) |
17 | + | printRecord(tgt) |
18 | ||
19 | """ When I run this I get Traceback (most recent call last): | |
20 | File "./geoip.py", line 17, in <module> | |
21 | printRecord(tgt) | |
22 | File "./geoip.py", line 8, in printRecord | |
23 | region = rec['region_name'] | |
24 | KeyError: 'region_name' | |
25 | ||
26 | I googled this error and come up with this https://code.google.com/p/pygeoip/issues/attachmentText?id=21&aid=210001000&name=__init__.py.patch&token=AQEwNUdjh1w6Tvx_pQvMUlaLMmA%3A1385844481406 | |
27 | ||
28 | which looks like this https://pastebin.com/0BinS7r5 | |
29 | I read this because I don't recall ever installing a patch locally into a dist-package | |
30 | http://stackoverflow.com/questions/16738175/applying-patch-to-standard-python-file-locally | |
31 | but thought I'd wait to hear if that looked correct. | |
32 | file location: | |
33 | /usr/local/lib/python2.7/dist-packages/pygeoip-0.3.0-py2.7.egg/pygeoip/__init__.py | |
34 | """ |