From f14c79b84fb7a5a3f46b2a8267fdc216e3f3d906 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Tue, 10 Apr 2012 23:54:47 -0700 Subject: [PATCH] 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 --- cmdline.py | 15 ++++++++++----- main.py | 12 ++++++++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/cmdline.py b/cmdline.py index ef5c836..cdcfcf2 100755 --- a/cmdline.py +++ b/cmdline.py @@ -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 diff --git a/main.py b/main.py index 02fd05d..3e15fa2 100755 --- a/main.py +++ b/main.py @@ -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