fix: random_choice -> random.choice
authorThomasV <thomasv@gitorious>
Sat, 20 Oct 2012 15:21:12 +0000 (17:21 +0200)
committerThomasV <thomasv@gitorious>
Sat, 20 Oct 2012 15:21:12 +0000 (17:21 +0200)
lib/interface.py
scripts/servers

index 9edfff0..227723a 100644 (file)
@@ -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
index 8297135..69c0ade 100755 (executable)
@@ -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"