[tor-commits] [ooni-probe/master] Fix report header in order to fix issue https://github.com/TheTorProject/ooni-probe/issues/223

art at torproject.org art at torproject.org
Sat Nov 23 11:11:41 UTC 2013


commit 72728414754c6df8defc133992788ba43af53615
Author: Arturo Filastò <art at fuffa.org>
Date:   Wed Nov 6 12:42:35 2013 +0100

    Fix report header in order to fix issue https://github.com/TheTorProject/ooni-probe/issues/223
---
 ooni/deck.py    |    5 ++++-
 ooni/nettest.py |    5 +++--
 ooni/oonicli.py |    2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/ooni/deck.py b/ooni/deck.py
index 7b8a8c4..9054f25 100644
--- a/ooni/deck.py
+++ b/ooni/deck.py
@@ -108,6 +108,9 @@ class Deck(InputFile):
             self.deckHash = sha256(f.read())
             f.seek(0)
             test_deck = yaml.safe_load(f)
+        
+        if isinstance(test_deck, dict):
+            test_deck = [test_deck]
 
         for test in test_deck:
             try:
@@ -117,7 +120,7 @@ class Deck(InputFile):
                 log.msg("Skipping...")
                 continue
             net_test_loader = NetTestLoader(test['options']['subargs'],
-                    test_file=nettest_path)
+                    test_file=nettest_path, global_options=test['options'])
             #XXX: If the deck specifies the collector, we use the specified collector
             # And it should also specify the test helper address to use
             # net_test_loader.collector = test['options']['collector']
diff --git a/ooni/nettest.py b/ooni/nettest.py
index 9304f2b..f4ce3be 100644
--- a/ooni/nettest.py
+++ b/ooni/nettest.py
@@ -174,9 +174,10 @@ class NetTestLoader(object):
     method_prefix = 'test'
     collector = None
 
-    def __init__(self, options, test_file=None, test_string=None):
+    def __init__(self, options, test_file=None, test_string=None, global_options={}):
         self.onionInputRegex =  re.compile("(httpo://[a-z0-9]{16}\.onion)/input/([a-z0-9]{64})$")
         self.options = options
+        self.globalOptions = global_options
         self.testCases, test_cases = None, None
 
         if test_file:
@@ -287,7 +288,7 @@ class NetTestLoader(object):
             'test_version': self.testVersion,
             'software_name': 'ooniprobe',
             'software_version': software_version,
-            'options': self.options,
+            'options': self.globalOptions,
             'input_hashes': input_file_hashes
         }
         return test_details
diff --git a/ooni/oonicli.py b/ooni/oonicli.py
index 8622e09..a19c4ef 100644
--- a/ooni/oonicli.py
+++ b/ooni/oonicli.py
@@ -143,7 +143,7 @@ def runWithDirector():
             log.debug("No test deck detected")
             test_file = nettest_to_path(global_options['test_file'])
             net_test_loader = NetTestLoader(global_options['subargs'],
-                    test_file=test_file)
+                    test_file=test_file, global_options=global_options)
             deck.insert(net_test_loader)
     except errors.MissingRequiredOption, option_name:
         log.err('Missing required option: "%s"' % option_name)





More information about the tor-commits mailing list