commit 50b7b702be664795fb1c5699c52f1f0d9322e58e Author: aagbsn aagbsn@extc.org Date: Fri Nov 22 17:39:37 2013 +0000
Move exceptions into ooni/errors.py --- ooni/errors.py | 9 +++++++++ ooni/nettest.py | 23 +++++++---------------- ooni/oonicli.py | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/ooni/errors.py b/ooni/errors.py index a124487..c167bbe 100644 --- a/ooni/errors.py +++ b/ooni/errors.py @@ -195,6 +195,15 @@ class NetTestNotFound(Exception): class MissingRequiredOption(Exception): pass
+class FailureToLoadNetTest(Exception): + pass + +class NoPostProcessor(Exception): + pass + +class InvalidOption(Exception): + pass + def get_error(error_key): if error_key == 'test-helpers-key-missing': return CouldNotFindTestHelper diff --git a/ooni/nettest.py b/ooni/nettest.py index b6dac29..c813c37 100644 --- a/ooni/nettest.py +++ b/ooni/nettest.py @@ -58,7 +58,7 @@ def loadNetTestString(net_test_string): test_cases.extend(get_test_methods(item))
if not test_cases: - raise NoTestCasesFound + raise e.NoTestCasesFound
return test_cases
@@ -72,7 +72,7 @@ def loadNetTestFile(net_test_file): test_cases.extend(get_test_methods(item))
if not test_cases: - raise NoTestCasesFound + raise e.NoTestCasesFound
return test_cases
@@ -351,7 +351,7 @@ class NetTestLoader(object): test_cases.extend(self._get_test_methods(item))
if not test_cases: - raise NoTestCasesFound + raise e.NoTestCasesFound
self.setupTestCases(test_cases)
@@ -365,7 +365,7 @@ class NetTestLoader(object): test_cases.extend(self._get_test_methods(item))
if not test_cases: - raise NoTestCasesFound + raise e.NoTestCasesFound
self.setupTestCases(test_cases)
@@ -678,7 +678,7 @@ class NetTestCase(object): anything that gets written to the object self.report[] will be added to the final test report. """ - raise NoPostProcessor + raise e.NoPostProcessor
def inputProcessor(self, filename): """ @@ -758,23 +758,14 @@ class NetTestCase(object): for option in self.localOptions: if option not in self.usageOptions(): if not self.inputFile or option not in self.inputFile: - raise InvalidOption + raise e.InvalidOption
def _checkRequiredOptions(self): for required_option in self.requiredOptions: log.debug("Checking if %s is present" % required_option) if required_option not in self.localOptions or \ self.localOptions[required_option] == None: - raise MissingRequiredOption(required_option) + raise e.MissingRequiredOption(required_option)
def __repr__(self): return "<%s inputs=%s>" % (self.__class__, self.inputs) - -class FailureToLoadNetTest(Exception): - pass -class NoPostProcessor(Exception): - pass -class InvalidOption(Exception): - pass -class MissingRequiredOption(Exception): - pass diff --git a/ooni/oonicli.py b/ooni/oonicli.py index 8622e09..c722c52 100644 --- a/ooni/oonicli.py +++ b/ooni/oonicli.py @@ -16,7 +16,7 @@ from ooni.settings import config from ooni.director import Director from ooni.deck import Deck, nettest_to_path from ooni.reporter import YAMLReporter, OONIBReporter -from ooni.nettest import NetTestLoader, MissingRequiredOption +from ooni.nettest import NetTestLoader
from ooni.utils import log, checkForRoot
tor-commits@lists.torproject.org