still making both branches closer
[nepi.git] / examples / ccn_emu_live / planetlab.py
index b2548f3..fc16560 100644 (file)
@@ -166,15 +166,14 @@ def avg_interests(ec, run):
 
     ### Compute metric: Avg number of Interests seen per content name
     ###                 normalized by the number of nodes in the shortest path
-    content_name_count = len(content_names.values())
+    content_name_count = len(content_names)
     nodes_in_shortest_path = len(shortest_path) - 1
     metric = interest_count / (float(content_name_count) * float(nodes_in_shortest_path))
 
     # TODO: DUMP RESULTS TO FILE
     # TODO: DUMP GRAPH DELAYS!
-    f = open("/tmp/metric", "a+")
-    f.write("%.2f\n" % metric)
-    f.close()
+    with open("/tmp/metric", "a+") as f:
+        f.write("%.2f\n" % metric)
     print(" METRIC", metric)
 
     return metric