use USCS for US-based IPs (fixes #229 #162)

This commit is contained in:
Igor Chubin 2018-10-27 17:14:33 +02:00
parent 45b9b74163
commit e6687abf13
2 changed files with 3 additions and 4 deletions

View File

@ -210,11 +210,10 @@ def location_processing(location, ip_addr):
else:
location = NOT_FOUND_LOCATION #location[1:]
query_source_location = None, None
query_source_location = get_location(ip_addr)
country = None
if location is None or location == 'MyLocation':
query_source_location = get_location(ip_addr)
location, country = query_source_location
if is_ip(location):
@ -224,7 +223,7 @@ def location_processing(location, ip_addr):
try:
location, country = get_location(socket.gethostbyname(location[1:]))
except:
query_source_location = NOT_FOUND_LOCATION, None
location, country = NOT_FOUND_LOCATION, None
location = location_canonical_name(location)

View File

@ -167,7 +167,7 @@ def wttr(location, request):
location, override_location_name, full_address, country, query_source_location = \
location_processing(location, ip_addr)
us_ip = query_source_location[1] == 'US' and 'slack' not in user_agent
us_ip = query_source_location[1] == 'United States' and 'slack' not in user_agent
query = parse_query.metric_or_imperial(query, lang, us_ip=us_ip)
# logging query