From aaa01e8051d40c4b6660e565f737170e94668504 Mon Sep 17 00:00:00 2001 From: EUcancER Date: Wed, 4 Jan 2012 01:23:12 +0100 Subject: //retiolum/scripts/adv_graphgen/parse_tinc_stats: parsing availability correctly --- retiolum/scripts/adv_graphgen/parse_tinc_stats.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'retiolum/scripts/adv_graphgen/parse_tinc_stats.py') diff --git a/retiolum/scripts/adv_graphgen/parse_tinc_stats.py b/retiolum/scripts/adv_graphgen/parse_tinc_stats.py index b8054b0d..54dcc4ab 100755 --- a/retiolum/scripts/adv_graphgen/parse_tinc_stats.py +++ b/retiolum/scripts/adv_graphgen/parse_tinc_stats.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf8 -*- - +from BackwardsReader import BackwardsReader import sys,json supernodes= [ "kaah","supernode","euer","pa_sharepoint","oxberg" ] """ TODO: Refactoring needed to pull the edges out of the node structures again, @@ -51,12 +51,19 @@ def generate_stats(nodes): """ jlines = [] try: - f = open(DUMP_FILE,'r') - for line in f: - jlines.append(json.loads(line)) - f.close() + f = BackwardsReader(DUMP_FILE) + lines_to_use = 1000 + while True: + if lines_to_use == 0: break + line = f.readline() + if not line: break + jline = json.loads(line) + if not jline['nodes']: continue + + jlines.append(jline) + lines_to_use -=1 except Exception,e: - pass + sys.stderr.write(str(e)) for k,v in nodes.iteritems(): conns = v.get('to',[]) for c in conns: #sanitize weights -- cgit v1.2.3