[or-cvs] r18509: {torflow} Minor changes to analysis scripts. (torflow/trunk/NetworkScanners)

mikeperry at seul.org mikeperry at seul.org
Thu Feb 12 17:12:10 UTC 2009


Author: mikeperry
Date: 2009-02-12 12:12:10 -0500 (Thu, 12 Feb 2009)
New Revision: 18509

Modified:
   torflow/trunk/NetworkScanners/libsoat.py
   torflow/trunk/NetworkScanners/snakeinspector.py
   torflow/trunk/NetworkScanners/soat.py
   torflow/trunk/NetworkScanners/soatstats.py
Log:

Minor changes to analysis scripts.



Modified: torflow/trunk/NetworkScanners/libsoat.py
===================================================================
--- torflow/trunk/NetworkScanners/libsoat.py	2009-02-12 16:21:20 UTC (rev 18508)
+++ torflow/trunk/NetworkScanners/libsoat.py	2009-02-12 17:12:10 UTC (rev 18509)
@@ -872,13 +872,13 @@
         new.append(str(node))
     if missing:
       ret += "\nMissing: "
-      for node in missing: ret += node
+      for node in missing: ret += node+" "
     if new:
       ret += "\nNew: "
-      for node in new: ret += node
+      for node in new: ret += node+" "
     if miscount:
       ret += "\nMiscount: "
-      for node in miscount: ret += node
+      for node in miscount: ret += node+" "
     return ret
 
   def prune_differences(self, other_string):

Modified: torflow/trunk/NetworkScanners/snakeinspector.py
===================================================================
--- torflow/trunk/NetworkScanners/snakeinspector.py	2009-02-12 16:21:20 UTC (rev 18508)
+++ torflow/trunk/NetworkScanners/snakeinspector.py	2009-02-12 17:12:10 UTC (rev 18509)
@@ -22,9 +22,16 @@
 
 TorCtl.TorUtil.loglevel="NOTICE"
 
-def usage():
-  # TODO: Don't be a jerk.
-  print "Use teh src, luke."
+def usage(argv):
+  print "Usage: "+argv[0]+" with 0 or more of the following filters: "
+  print "  --dir <datadir>"
+  print "  --file <.result file>"
+  print "  --exit <idhex>"
+  print "  --reason <soat failure reason>"
+  print "  --proto <protocol>"
+  print "  --resultfilter <TestResult class name>"
+  print "  --statuscode <'Failure' or 'Inconclusive'>"
+  print "  --verbose"
   sys.exit(1)
 
 def getargs(argv):
@@ -34,7 +41,7 @@
               "verbose", "statuscode="])
   except getopt.GetoptError,err:
     print str(err)
-    usage()
+    usage(argv)
   use_dir="./data/"
   use_file=None
   node=None
@@ -83,7 +90,10 @@
        (not reason or r.reason == reason) and \
        (not proto or r.proto == proto) and \
        (not resultfilter or r.__class__.__name__ == resultfilter):
-      print r
+      try:
+        print r
+      except IOError, e:
+        traceback.print_exc()
       print "\n-----------------------------\n"
 
 if __name__ == "__main__":

Modified: torflow/trunk/NetworkScanners/soat.py
===================================================================
--- torflow/trunk/NetworkScanners/soat.py	2009-02-12 16:21:20 UTC (rev 18508)
+++ torflow/trunk/NetworkScanners/soat.py	2009-02-12 17:12:10 UTC (rev 18509)
@@ -946,8 +946,7 @@
       content_prefix = http_content_dir+address_file
       failed_prefix = http_failed_dir+address_file
 
-      exit_content_file = open(DataHandler.uniqueFilename(failed_prefix+'.'+exit_node[1:]+'.dyn-content'),
-                                'w')
+      exit_content_file = open(DataHandler.uniqueFilename(failed_prefix+'.'+exit_node[1:]+'.dyn-content'), 'w')
       exit_content_file.write(tor_js)
       exit_content_file.close()
 

Modified: torflow/trunk/NetworkScanners/soatstats.py
===================================================================
--- torflow/trunk/NetworkScanners/soatstats.py	2009-02-12 16:21:20 UTC (rev 18508)
+++ torflow/trunk/NetworkScanners/soatstats.py	2009-02-12 17:12:10 UTC (rev 18509)
@@ -35,6 +35,7 @@
   dh = DataHandler()
   data = dh.getAll()
 
+  reason_counts = {}
   nodeResults = {}
   tests = Set([])
 
@@ -60,6 +61,10 @@
     elif result.status == TEST_FAILURE:
       rn.total.bad += 1
       rn.counts[result.__class__.__name__].bad += 1
+      if result.reason not in reason_counts:
+        reason_counts[result.reason] = 1
+      else:
+        reason_counts[result.reason] += 1
     
   # Sort by total counts, print out nodes with highest counts first
   failed_nodes = nodeResults.values()
@@ -82,10 +87,10 @@
     if node.total.bad != 0:
       print `node.idhex` + "\t" + `node.total.bad`
 
-  print "\nInconclusive test results"
-  for node in inconclusive_nodes:
-    if node.total.inconclusive != 0:
-      print `node.idhex` + "\t" + `node.total.inconclusive`
+  #print "\nInconclusive test results"
+  #for node in inconclusive_nodes:
+  #  if node.total.inconclusive != 0:
+  #    print `node.idhex` + "\t" + `node.total.inconclusive`
 
   for test in tests:
     print "\n" + test[:(-6)] + " failures"
@@ -93,13 +98,19 @@
       if node.counts[test].bad != 0:
         print `node.idhex` + "\t" + `node.counts[test].bad`
 
-  for test in tests:
-    print "\n" + test[:(-6)] + " inconclusive results"
-    for node in inconclusive_nodes_specific[test]:
-      if node.counts[test].inconclusive != 0:
-        print `node.idhex` + "\t" + `node.counts[test].inconclusive`
+  #for test in tests:
+  #  print "\n" + test[:(-6)] + " inconclusive results"
+  #  for node in inconclusive_nodes_specific[test]:
+  #    if node.counts[test].inconclusive != 0:
+  #      print `node.idhex` + "\t" + `node.counts[test].inconclusive`
 
   print ""
 
+  reasons = sorted(reason_counts.iterkeys(), lambda x, y:
+cmp(reason_counts[x], reason_counts[y]))
+
+  for r in reasons:
+    print r+": "+str(reason_counts[r])
+
 if __name__ == "__main__":
   main(sys.argv)



More information about the tor-commits mailing list