summaryrefslogtreecommitdiff
path: root/iss
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2020-10-23 14:03:03 +0300
committerYuval Adam <_@yuv.al>2020-10-23 14:03:03 +0300
commitd6bbb4fec4c4de78de05ea4ebd10b02dd850829a (patch)
tree4096dbf22e273f2f12a34d3dd7f071568444e9d1 /iss
parent67910b97c6b2446130da88e780d6f0dcb21dcf92 (diff)
Ignore failed geo lookupszappa
Diffstat (limited to 'iss')
-rw-r--r--iss/geo.py15
1 files 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