[tor-commits] [ooni-probe/master] Fix bug in tests that do not have usageOptions

art at torproject.org art at torproject.org
Sat Nov 24 20:35:50 UTC 2012


commit 18a6cde20774311de552fcae966d847b5eb9f187
Author: Arturo Filastò <art at fuffa.org>
Date:   Sat Nov 24 20:43:23 2012 +0100

    Fix bug in tests that do not have usageOptions
---
 nettests/core/traceroute.py |    1 +
 ooni/runner.py              |    5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/nettests/core/traceroute.py b/nettests/core/traceroute.py
index 6a443d9..45bbb67 100644
--- a/nettests/core/traceroute.py
+++ b/nettests/core/traceroute.py
@@ -19,6 +19,7 @@ class UsageOptions(usage.Options):
                     ['maxttl', 'm', 30, 'The maximum value of ttl to set on packets'],
                     ['srcport', 'p', None, 'Set the source port to a specific value (only applies to TCP and UDP)']
                     ]
+
     optFlags = [['randomize','r', 'Randomize the source port']]
 
 class TracerouteTest(scapyt.BaseScapyTest):
diff --git a/ooni/runner.py b/ooni/runner.py
index f5ab651..92aa406 100644
--- a/ooni/runner.py
+++ b/ooni/runner.py
@@ -39,12 +39,13 @@ def processTest(obj, cmd_line_options):
         A configured and instantiated :class:`twisted.python.usage.Options`
         class.
     """
+    if not hasattr(obj.usageOptions, 'optParameters'):
+        obj.usageOptions.optParameters = []
+
     if obj.inputFile:
         obj.usageOptions.optParameters.append(obj.inputFile)
 
     if obj.baseParameters:
-        if not hasattr(obj.usageOptions, 'optParameters'):
-            obj.usageOptions.optParameters = []
         for parameter in obj.baseParameters:
             obj.usageOptions.optParameters.append(parameter)
 





More information about the tor-commits mailing list