diff --git a/lib/location.py b/lib/location.py index 925bc70..fde49ee 100644 --- a/lib/location.py +++ b/lib/location.py @@ -116,9 +116,13 @@ def get_location(ip_addr): Return location pair (CITY, COUNTRY) for `ip_addr` """ - response = GEOIP_READER.city(ip_addr) - country = response.country.name - city = response.city.name + try: + response = GEOIP_READER.city(ip_addr) + country = response.country.name + city = response.city.name + except geoip2.errors.AddressNotFoundError: + country = None + city = None # # temporary disabled it because of geoip services capcacity diff --git a/lib/wttr_line.py b/lib/wttr_line.py index 4690779..e7e75d0 100644 --- a/lib/wttr_line.py +++ b/lib/wttr_line.py @@ -72,7 +72,7 @@ def render_location(data): location (l) """ - return data['location'] + return data['location'].title() FORMAT_SYMBOL = { 'c': render_condition,