summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEUcancER <root@euer.krebsco.de>2012-01-04 01:23:12 +0100
committerEUcancER <root@euer.krebsco.de>2012-01-04 01:23:12 +0100
commitaaa01e8051d40c4b6660e565f737170e94668504 (patch)
tree8f6be4b2c055d561d9435e4183af248e8c8255be
parent1994d3402f10a2c3534cb2c5cd4820d7f535ac81 (diff)
//retiolum/scripts/adv_graphgen/parse_tinc_stats: parsing availability correctly
-rwxr-xr-xretiolum/scripts/adv_graphgen/parse_tinc_stats.py19
1 files changed, 13 insertions, 6 deletions
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