From d6bbb4fec4c4de78de05ea4ebd10b02dd850829a Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Fri, 23 Oct 2020 14:03:03 +0300 Subject: Ignore failed geo lookups --- iss/geo.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/iss/geo.py b/iss/geo.py index 5413913..50aec0c 100644 --- a/iss/geo.py +++ b/iss/geo.py @@ -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 -- cgit v1.3.1