commit 64715a714170b9175d07ea9420ef8b3dcf177c83 Author: Arturo Filastò art@fuffa.org Date: Wed Feb 27 18:11:30 2013 +0100
Change how we pass arguments to the nettest loader
* Explicit the passing of the nettest file argument --- ooni/errors.py | 4 ++++ ooni/nettest.py | 12 ++++++------ ooni/oonicli.py | 6 ++++-- 3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/ooni/errors.py b/ooni/errors.py index 2023dbf..a194b96 100644 --- a/ooni/errors.py +++ b/ooni/errors.py @@ -126,3 +126,7 @@ class InvalidOONIBCollectorAddress(Exception): class AllReportersFailed(Exception): pass
+class GeoIPDataFilesNotFound(Exception): + pass + + diff --git a/ooni/nettest.py b/ooni/nettest.py index 6323989..0b3e69c 100644 --- a/ooni/nettest.py +++ b/ooni/nettest.py @@ -10,7 +10,7 @@ from ooni.utils import log, checkForRoot, NotRootError, geodata from ooni import config from ooni import otime
-from ooni.errors import AllReportersFailed +from ooni import errors as e
from inspect import getmembers from StringIO import StringIO @@ -21,12 +21,12 @@ class NoTestCasesFound(Exception): class NetTestLoader(object): method_prefix = 'test'
- def __init__(self, options): + def __init__(self, options, test_file=None, test_string=None): self.options = options - if 'test_file' in options: - self.loadNetTestFile(options['test_file']) - elif 'test_string' in options: - self.loadNetTestString(options['test_string']) + if test_file: + self.loadNetTestFile(test_file) + elif test_string: + self.loadNetTestString(test_string)
@property def testDetails(self): diff --git a/ooni/oonicli.py b/ooni/oonicli.py index 243b90c..73d7709 100644 --- a/ooni/oonicli.py +++ b/ooni/oonicli.py @@ -107,10 +107,12 @@ def runWithDirector(): if global_options['testdeck']: test_deck = yaml.safe_load(open(global_options['testdeck'])) for test in test_deck: - test_list.append(NetTestLoader(test['options'])) + test_list.append(NetTestLoader(test['options'], + test_file=global_options['test_file'])) else: log.debug("No test deck detected") - test_list.append(NetTestLoader(global_options)) + test_list.append(NetTestLoader(global_options['subargs'], + test_file=global_options['test_file']))
# check each test's usageOptions for net_test_loader in test_list: