Skip to content

Commit

Permalink
Prevent IndexError with --area at random occasions #64
Browse files Browse the repository at this point in the history
  • Loading branch information
jotyGill committed Jan 23, 2018
1 parent 3121296 commit e72f06f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions openpyn/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def get_unique_locations(list_of_servers):
# print(unique_locations)
for eachLocation in unique_locations:
geo_address_list = get_location_name(eachLocation)
time.sleep(random.randrange(1, 5, 1)*0.1)
time.sleep(random.randrange(1, 5, 1) * 0.1)
# geo_address_list = get_location_name(latitude=latitude, longitude=longitude)
resolved_locations.append(geo_address_list)
# print(resolved_locations)
Expand All @@ -36,7 +36,8 @@ def get_location_name(location_dic):
geo_address_list = []
name_list = []
try:
results = r.json()['results'][0]['address_components']
response = r.json()
results = response['results'][0]['address_components']
# print(results)
except IndexError:
print("IndexError: Looks like you have reached Google maps API's daily \
Expand Down

0 comments on commit e72f06f

Please sign in to comment.