diff options
| author | Yuval Adam <_@yuv.al> | 2020-10-23 14:03:03 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2020-10-23 14:03:03 +0300 |
| commit | d6bbb4fec4c4de78de05ea4ebd10b02dd850829a (patch) | |
| tree | 4096dbf22e273f2f12a34d3dd7f071568444e9d1 /iss/geo.py | |
| parent | 67910b97c6b2446130da88e780d6f0dcb21dcf92 (diff) | |
Ignore failed geo lookupszappa
Diffstat (limited to 'iss/geo.py')
| -rw-r--r-- | iss/geo.py | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -16,9 +16,12 @@ default_location = namedtuple("Location", DEFAULT_LOCATION.keys())( def get_location(ip): - with geoip2.database.Reader(GEOIP_GEOLITE2_CITY_PATH) as reader: - try: - res = reader.city(ip) - return res.location - except geoip2.errors.AddressNotFoundError: - return default_location + try: + with geoip2.database.Reader(GEOIP_GEOLITE2_CITY_PATH) as reader: + try: + res = reader.city(ip) + return res.location + except geoip2.errors.AddressNotFoundError: + return default_location + except TypeError: + return default_location |
