[tor-commits] [ooni-probe/master] Fixed an error with the test_timeout callback taking the wrong parameters, and
isis at torproject.org
isis at torproject.org
Tue Dec 18 05:53:46 UTC 2012
commit 623eeca5b719be980c8ddb0444c89eecaf5cadd6
Author: Isis Lovecruft <isis at torproject.org>
Date: Tue Dec 18 05:18:44 2012 +0000
Fixed an error with the test_timeout callback taking the wrong parameters, and
cleaned up a couple things due to the ooni logger formatting changes.
---
ooni/oonicli.py | 2 +-
ooni/runner.py | 11 +++++++----
ooni/utils/log.py | 15 +++++++--------
ooniprobe.conf.sample | 8 +++++---
4 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/ooni/oonicli.py b/ooni/oonicli.py
index 6afc453..582a6ae 100644
--- a/ooni/oonicli.py
+++ b/ooni/oonicli.py
@@ -215,5 +215,5 @@ def run():
d.addErrback(errorRunningTests)
# XXX I believe we don't actually need this:
- reactor.run()
+ #reactor.run()
diff --git a/ooni/runner.py b/ooni/runner.py
index 4bb3e9f..a0710cd 100644
--- a/ooni/runner.py
+++ b/ooni/runner.py
@@ -248,10 +248,10 @@ def runTestCasesWithInput(test_cases, test_input, yaml_reporter,
# This is used to store a copy of all the test reports
tests_report = {}
- def test_timeout(d):
+ def test_timeout(d, test_instance):
timeout_error = defer.TimeoutError(
"%s test for %s timed out after %s seconds"
- % (test_name, test_instance.input, test_instance.timeout))
+ % (test_instance.name, test_instance.input, test_instance.timeout))
timeout_fail = failure.Failure(err)
try:
d.errback(timeout_fail)
@@ -323,8 +323,10 @@ def runTestCasesWithInput(test_cases, test_input, yaml_reporter,
# call setups on the test
test_instance._setUp()
test_instance.setUp()
+
# get the timeout and _parents, in case it was set in setUp()
test_instance.timeout = getTestTimeout(test_instance, test_method)
+ test_instance.timedOut = False
test = getattr(test_instance, test_method)
test_instance._testMethod = test
@@ -332,7 +334,8 @@ def runTestCasesWithInput(test_cases, test_input, yaml_reporter,
d = defer.maybeDeferred(test)
# register the timer with the reactor
- call_timeout = reactor.callLater(test_instance.timeout, test_timeout, d)
+ call_timeout = reactor.callLater(test_instance.timeout, test_timeout, d,
+ test_instance)
d.addBoth(lambda x: call_timeout.active() and call_timeout.cancel() or x)
# check if anything has been aborted or marked as 'skip'
@@ -678,7 +681,7 @@ def loadTest(cmd_line_options):
test_cases, options = loadTestsAndOptions(classes, cmd_line_options)
return test_cases, options, cmd_line_options
except NoTestCasesFound, ntcf:
- log.warn(ntcf)
+ log.err(ntcf)
if not 'testdeck' in cmd_line_options: # exit if this was this only test
sys.exit(1) # file and there aren't any tests
else:
diff --git a/ooni/utils/log.py b/ooni/utils/log.py
index 70543ce..95163f3 100644
--- a/ooni/utils/log.py
+++ b/ooni/utils/log.py
@@ -50,17 +50,16 @@ def stop():
def msg(msg, *arg, **kw):
print "%s" % msg
-def debug(msg, *arg, **kw):
+def debug(message, *arg, **kw):
if config.advanced.debug:
- print "[D] %s" % msg
+ print "[D] %s" % message
-def warn(msg, *arg, **kw):
- txlog.logging.captureWarnings('true')
- txlog.logging.warn(msg)
- #txlog.showwarning()
+def warn(message, *arg, **kw):
+ if config.advanced.show_warnings:
+ print "[W] %s" % message
-def err(msg, *arg, **kw):
- print "[!] %s" % msg
+def err(message, *arg, **kw):
+ print "[!] %s" % message
def exception(error):
"""
diff --git a/ooniprobe.conf.sample b/ooniprobe.conf.sample
index 2d6ef47..99faa4b 100644
--- a/ooniprobe.conf.sample
+++ b/ooniprobe.conf.sample
@@ -21,15 +21,17 @@ advanced:
# GeoIP database file. This should be the directory in which OONI is
# installed /path/to/ooni-probe/data/
geoip_data_dir: /usr/share/GeoIP/
- # Should we display debug messages:
+ # Should we display debug messages?:
debug: true
+ # Should we display warning messages?:
+ show_warnings: true
# How many seconds should we wait for connections before timing out?:
default_timeout: 30
# Location where Tor is installed:
tor_binary: '/usr/sbin/tor'
- # For auto detection
+ # To automatically detect the system default networking interface, use:
interface: auto
- # Of specify a specific interface
+ # Or specify a specific interface:
#interface: wlan0
# If you do not specify start_tor, you will have to have Tor running and
# explicitly set the control port and orport.
More information about the tor-commits
mailing list