[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [metrics-tasks/master] pickle output



commit 9d02762d4e1cef6b24e5915d46a386fd0fee0f20
Author: Sathyanarayanan Gunasekaran <gsathya.ceg@xxxxxxxxx>
Date:   Sat Nov 24 00:03:32 2012 +0530

    pickle output
---
 task-1854/pylinf.py |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/task-1854/pylinf.py b/task-1854/pylinf.py
index 91ea2f8..9ccac13 100644
--- a/task-1854/pylinf.py
+++ b/task-1854/pylinf.py
@@ -13,6 +13,7 @@ import math
 import os
 import pygeoip
 import tarfile
+import pickle
 import StringIO
 import stem.descriptor.server_descriptor as server_descriptor
 
@@ -25,8 +26,8 @@ class Router:
     def __init__(self):
         self.prob = None
         self.bandwidth = None
-	self.hex_digest = None
         self.advertised_bw = None
+        self.hex_digest = None
         self.country = None
         self.as_no = None
         self.is_exit = None
@@ -56,7 +57,7 @@ class Router:
             return ""
 
     def get_advertised_bw(self, hex_digest):
-        return descriptors[self.hex_digest]
+        return descriptors[self.hex_digest.upper()]
 
 def parse_bw_weights(values):
     data = {}
@@ -219,6 +220,10 @@ if __name__ == "__main__":
         server_desc_files.append(os.path.join(options.server_desc, file_name))
     load_server_desc(server_desc_files)
 
+    # Pickle descriptors
+    with open('data.pkl', 'wb') as output:
+        pickle.dump(descriptors, output)
+
     with open(options.output, 'w') as out_fh:
         for file_name in os.listdir(options.consensus):
             file_path = os.path.join(options.consensus, file_name)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits