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

12
main.py
View File

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