You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
606 B

import socket
import json
import time
while True:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('', 6000))
data = sock.recv(10000)
#print data
stats = json.loads(data)
for k in stats:
v = stats[k]
if type(v) is list:
for i in range(0,len(v)):
print "%s[%d]: %f" % (k, i, v[i]['percent'])
else :
print "%s: %f" % (k,v['percent'])
print "----"
except KeyboardInterrupt:
print "\nExiting..."
# except Exception as err:
# print "\nError ", type(err), ': ', err, "..."
# break