[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [metrics-tasks/master] Parse bandweight-weights better
commit 960327bfd58eb506aea3df9d34f97a4c14469e4c
Author: Sathyanarayanan Gunasekaran <gsathya.ceg@xxxxxxxxx>
Date: Tue Jul 24 01:01:17 2012 +0530
Parse bandweight-weights better
Instead of depending on position, depend
on keys
---
task-6232/pyentropy.py | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/task-6232/pyentropy.py b/task-6232/pyentropy.py
index 6bd5132..e782974 100644
--- a/task-6232/pyentropy.py
+++ b/task-6232/pyentropy.py
@@ -85,6 +85,16 @@ class Router:
except:
return None
+def parse_bw_weights(values):
+ data = {}
+ try:
+ for value in values:
+ key, value = value.split("=")
+ data[key] = float(value) / 10000
+ return data
+ except:
+ return None
+
def run(file_name):
routers = []
router = None
@@ -102,10 +112,14 @@ def run(file_name):
elif key == 'valid-after':
valid_after = ' '.join(values)
elif key == 'bandwidth-weights':
- Wed = float(values[6].split('=')[1]) / 10000
- Wee = float(values[7].split('=')[1]) / 10000
- Wgd = float(values[11].split('=')[1]) / 10000
- Wgg = float(values[12].split('=')[1]) / 10000
+ data = parse_bw_weights(values)
+ try:
+ Wed = data['Wed']
+ Wee = data['Wee']
+ Wgd = data['Wgd']
+ Wgg = data['Wgg']
+ except:
+ pass
elif key in KEYS:
router.add(key, values)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits