modified to consume new daemon data structure

-client works and now handles multiple cpus
-GUI is now broken but has code in place to be fixed, but I can't test, sorry
This commit is contained in:
Dan Ballard 2012-04-10 23:54:47 -07:00
parent 4a4eb6008d
commit f14c79b84f
2 changed files with 20 additions and 7 deletions

View File

@ -12,16 +12,21 @@ while True:
sock.close()
#print data
stats = json.loads(data)
for stat in stats["Stats"]:
print "%s: %f" % (stat["type"] ,stat["value"])
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 "----"
time.sleep(1)
except KeyboardInterrupt:
print "\nExiting..."
break
except:
print "\nError..."
break
# except Exception as err:
# print "\nError ", type(err), ': ', err, "..."
# break

12
main.py
View File

@ -55,8 +55,16 @@ class MenuExampleWindow(Gtk.Window):
sock.close()
#print data
stats = json.loads(data)
for stat in stats["Stats"]:
self.stats[stat["type"]].set_label("%f"%stat["value"])
#for stat in stats["Stats"]:
# self.stats[stat["type"]].set_label("%f"%stat["value"])
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'])
return True