[tor-commits] [ooni-probe/master] Add a very simple example on how to securely parse the ooniprobe reports

art at torproject.org art at torproject.org
Fri Dec 7 02:08:32 UTC 2012


commit 83b0a8e394f281ac41abe0be52c7560e285e0967
Author: Arturo Filastò <art at fuffa.org>
Date:   Fri Dec 7 03:08:08 2012 +0100

    Add a very simple example on how to securely parse the ooniprobe reports
---
 scripts/example_parser.py |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/scripts/example_parser.py b/scripts/example_parser.py
new file mode 100644
index 0000000..6c0dfab
--- /dev/null
+++ b/scripts/example_parser.py
@@ -0,0 +1,22 @@
+# This is an example of how to parse ooniprobe reports
+
+import yaml
+import sys
+print "Opening %s" % sys.argv[1]
+f = open(sys.argv[1])
+yamloo = yaml.safe_load_all(f)
+
+report_header = yamloo.next()
+print "ASN: %s" % report_header['probe_asn']
+print "CC: %s" % report_header['probe_cc']
+print "IP: %s" % report_header['probe_ip']
+print "Start Time: %s" % report_header['start_time']
+print "Test name: %s" % report_header['test_name']
+print "Test version: %s" % report_header['test_version']
+
+for report_entry in yamloo:
+    print "Test: %s" % report_entry['test']
+    print "Input: %s" % report_entry['input']
+    print "Report: %s" % report_entry['report']
+
+f.close()



More information about the tor-commits mailing list