Browse Source

Fix bug in geoip resolution

pull/583/head
Igor Chubin 5 years ago
parent
commit
2141bdb944
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      lib/location.py

+ 6
- 0
lib/location.py View File

@ -217,6 +217,12 @@ def _geoip(ip_addr):
# print(response.subdivisions)
city, region, country, ccode, lat, long = response.city.name, response.subdivisions[0].names["en"], response.country.name, response.country.iso_code, response.location.latitude, response.location.longitude
_debug_log("[_geoip] %s found" % ip_addr)
except IndexError:
# Tuple error
try:
city, region, country, ccode, lat, long = response.city.name, None, response.country.name, response.country.iso_code, response.location.latitude, response.location.longitude
except IndexError:
return None
except (geoip2.errors.AddressNotFoundError):
return None
return [city, region, country, ccode, lat, long]


Loading…
Cancel
Save