Update ips_to_maps.py

This commit is contained in:
blacktwin 2017-07-29 15:48:50 -04:00 committed by GitHub
parent 3fd41aaf4d
commit 738d45c881

View File

@ -187,11 +187,12 @@ def get_geo_dict(length, users):
geo_dict = {SERVER_FRIENDLY: [{'lon': SERVER_LON, 'lat': SERVER_LAT, 'city': SERVER_CITY, 'region': SERVER_STATE, geo_dict = {SERVER_FRIENDLY: [{'lon': SERVER_LON, 'lat': SERVER_LAT, 'city': SERVER_CITY, 'region': SERVER_STATE,
'ip': REPLACEMENT_WAN_IP, 'play_count': 0, 'platform': SERVER_PLATFORM, 'ip': REPLACEMENT_WAN_IP, 'play_count': 0, 'platform': SERVER_PLATFORM,
'location_count': 0}]} 'location_count': 0}]}
try:
for i in get_get_users_tables(users): for i in get_get_users_tables(users):
user_ip = get_get_users_ips(user_id=i, length=length) user_ip = get_get_users_ips(user_id=i, length=length)
city_cnt = 0 city_cnt = 0
for a in user_ip: for a in user_ip:
try:
ip = a.ip_address ip = a.ip_address
if ip.startswith(LAN_SUBNET) and REPLACEMENT_WAN_IP: if ip.startswith(LAN_SUBNET) and REPLACEMENT_WAN_IP:
ip = REPLACEMENT_WAN_IP ip = REPLACEMENT_WAN_IP
@ -202,13 +203,12 @@ def get_geo_dict(length, users):
'city': str(g.city), 'region': str(g.region), 'city': str(g.city), 'region': str(g.region),
'ip': ip, 'play_count': a.play_count, 'ip': ip, 'play_count': a.play_count,
'platform':a.platform, 'location_count': city_cnt}) 'platform':a.platform, 'location_count': city_cnt})
except AttributeError:
except AttributeError: print('User: {} IP: {} caused error in geo_dict.'.format(a.friendly_name, a.ip_address))
print('User: {} IP: {} caused error in geo_dict.'.format(a.friendly_name, a.ip_address)) pass
pass except Exception as e:
except Exception as e: print('Error here: {}'.format(e))
print(e) pass
pass
return geo_dict return geo_dict
def get_geojson_dict(user_locations): def get_geojson_dict(user_locations):