Same changes

Made the same changes in speedtest-cli-3 to support Python 3.
This commit is contained in:
Andrew Parker 2013-01-24 16:35:22 -07:00 committed by Matt Martz
parent b3c8a568a2
commit dacd474ac7
1 changed files with 15 additions and 5 deletions

View File

@ -196,11 +196,20 @@ def closestServers(client):
for server in root[0]:
d = distance([float(client['lat']), float(client['lon'])],
[float(server.get('lat')), float(server.get('lon'))])
servers[d] = server.attrib
if d not in servers:
servers[d] = [server.attrib]
else:
servers[d].append(server.attrib)
closest = []
for d in sorted(servers.keys())[0:4]:
closest.append(servers[d])
for d in sorted(servers.keys()):
for s in servers[d]:
closest.append(s)
if(len(closest) == 5):
break
else:
continue
break
del servers
del root
@ -229,8 +238,9 @@ def getBestServer(servers):
avg = round((cum / 3) * 1000000, 3)
results[avg] = server
best = results[sorted(results.keys())[0]]
best['latency'] = avg
fastest = sorted(results.keys())[0]
best = results[fastest]
best['latency'] = fastest
return best