Browse Source

fix: random_choice -> random.choice

283
ThomasV 12 years ago
parent
commit
fff922b5d7
  1. 2
      lib/interface.py
  2. 7
      scripts/servers

2
lib/interface.py

@ -40,7 +40,7 @@ proxy_modes = ['socks4', 'socks5', 'http']
def pick_random_server():
return random_choice( DEFAULT_SERVERS )
return random.choice( DEFAULT_SERVERS )
def pick_random_interface():
servers = DEFAULT_SERVERS

7
scripts/servers

@ -13,6 +13,7 @@ for i in interfaces:
i.send([('blockchain.numblocks.subscribe',[])])
else:
servers.remove(i.server)
i.status = "unreachable"
for i in interfaces:
while True:
@ -23,11 +24,12 @@ for i in interfaces:
if r.get('method') == 'blockchain.numblocks.subscribe':
results.append((i.host, r.get('result')))
i.status = "ok"
servers.remove(i.server)
break
for s in servers:
print "%30s "%s, "timed out"
i.status = "timed out"
from collections import defaultdict
d = defaultdict(int)
@ -36,6 +38,9 @@ for e in results:
v = d.values()
numblocks = d.keys()[v.index(max(v))]
for i in interfaces:
print i.host, i.status
for s,n in results:
print "%30s %d "%(s, n), "ok" if abs(n-numblocks)<2 else "lagging"

Loading…
Cancel
Save