Same changes
Made the same changes in speedtest-cli-3 to support Python 3.
This commit is contained in:
parent
b3c8a568a2
commit
dacd474ac7
|
@ -196,11 +196,20 @@ def closestServers(client):
|
||||||
for server in root[0]:
|
for server in root[0]:
|
||||||
d = distance([float(client['lat']), float(client['lon'])],
|
d = distance([float(client['lat']), float(client['lon'])],
|
||||||
[float(server.get('lat')), float(server.get('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 = []
|
closest = []
|
||||||
for d in sorted(servers.keys())[0:4]:
|
for d in sorted(servers.keys()):
|
||||||
closest.append(servers[d])
|
for s in servers[d]:
|
||||||
|
closest.append(s)
|
||||||
|
if(len(closest) == 5):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
break
|
||||||
|
|
||||||
del servers
|
del servers
|
||||||
del root
|
del root
|
||||||
|
@ -229,8 +238,9 @@ def getBestServer(servers):
|
||||||
avg = round((cum / 3) * 1000000, 3)
|
avg = round((cum / 3) * 1000000, 3)
|
||||||
results[avg] = server
|
results[avg] = server
|
||||||
|
|
||||||
best = results[sorted(results.keys())[0]]
|
fastest = sorted(results.keys())[0]
|
||||||
best['latency'] = avg
|
best = results[fastest]
|
||||||
|
best['latency'] = fastest
|
||||||
|
|
||||||
return best
|
return best
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue