From d9bc7eb9a1941b7e50b7ec2693e8dfe6a312d02d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20R=C3=BCttgers?= Date: Wed, 2 Sep 2015 23:16:06 +0200 Subject: [PATCH] Fixes a type error (nodes is no dict any longer, error was: AttributeError: 'list' object has no attribute 'items') --- lib/rrddb.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/rrddb.py b/lib/rrddb.py index f1678f5..f215fd9 100644 --- a/lib/rrddb.py +++ b/lib/rrddb.py @@ -28,15 +28,15 @@ class RRD(object): os.mkdir(self.imagePath) def update_database(self, nodes): - online_nodes = dict(filter( - lambda d: d[1]['flags']['online'], nodes.items())) - client_count = sum(map( - lambda d: d['statistics']['clients'], online_nodes.values())) - - self.globalDb.update(len(online_nodes), client_count) - for node_id, node in online_nodes.items(): - rrd = NodeRRD(os.path.join(self.dbPath, node_id + '.rrd'), node) - rrd.update() + node_count = 0 + client_count = 0 + for node in nodes: + if node['flags']['online']: + node_count += 1 + client_count += node['statistics']['clients'] + rrd = NodeRRD(os.path.join(self.dbPath, node['nodeinfo']['node_id'] + '.rrd'), node) + rrd.update() + self.globalDb.update(node_count, client_count) def update_images(self): self.globalDb.graph(os.path.join(self.imagePath, "globalGraph.png"),