[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] change the way HTTP request errors are handled
commit 6da1e0e2dd98aaeafe31b6f2241d92223738551d
Author: juga0 <juga>
Date: Thu Sep 24 23:03:30 2015 +0000
change the way HTTP request errors are handled
* eliminate addFailureToReport because the errors are handled by HTTPTest
errback and addToReport
* add ConnectionDone exception to handleAllErrors, so that an HTTP request
to a domain that is not reachable is reported
---
ooni/errors.py | 8 ++++++--
ooni/nettests/third_party/psiphon.py | 16 ++--------------
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/ooni/errors.py b/ooni/errors.py
index 1368f45..cb18fe9 100644
--- a/ooni/errors.py
+++ b/ooni/errors.py
@@ -6,7 +6,7 @@ from twisted.web.error import Error
from twisted.internet.error import ConnectionRefusedError, TCPTimedOutError
from twisted.internet.error import DNSLookupError, ConnectError, ConnectionLost
from twisted.internet.error import TimeoutError as GenericTimeoutError
-from twisted.internet.error import ProcessDone
+from twisted.internet.error import ProcessDone, ConnectionDone
from twisted.python import usage
@@ -50,7 +50,8 @@ def handleAllFailures(failure):
CommandNotSupported,
ConnectError,
ConnectionLost,
- CancelledError)
+ CancelledError,
+ ConnectionDone)
return failureToString(failure)
@@ -148,6 +149,9 @@ def failureToString(failure):
elif isinstance(failure.value, ProcessDone):
string = 'process_done'
+ elif isinstance(failure.value, ConnectionDone):
+ string = 'connection_done'
+
else:
# log.err("Unknown failure type: %s" % type(failure.value))
string = 'unknown_failure %s' % str(failure.value)
diff --git a/ooni/nettests/third_party/psiphon.py b/ooni/nettests/third_party/psiphon.py
index f8cb82a..8ac287d 100644
--- a/ooni/nettests/third_party/psiphon.py
+++ b/ooni/nettests/third_party/psiphon.py
@@ -60,7 +60,7 @@ class PsiphonTest(httpt.HTTPTest, process.ProcessTest):
else:
# FIXME: use http://google.com?
# self.url = 'https://wtfismyip.com/text'
- self.url = 'https://check.torproject.orggg'
+ self.url = 'https://check.torproject.org'
if self.localOptions['psiphonpath']:
self.psiphonpath = self.localOptions['psiphonpath']
@@ -112,17 +112,6 @@ connect(False)
path=self.psiphonpath,
usePTY=1)
-
- def addFailureToReport(failure):
- log.debug("PsiphonTest.test_psiphon.addFailureToReport")
- log.debug(repr(failure ))
- self.report['failure'] = handleAllFailures(failure)
- self.report['success'] = False
- log.debug("Adding %s to report" % self.report)
- # FIXME: these keys are not being wroten in the report
- # probably because report is being defined in NetTestCase as
- # a class attribute that is initialized again in NetTescase._setUp
-
def callDoRequest(_):
return self.doRequest(self.url)
self.bootstrapped.addCallback(callDoRequest)
@@ -132,8 +121,7 @@ connect(False)
self.processDirector.transport.signalProcess('INT')
os.remove(self.command[0])
return finished
-
- self.bootstrapped.addErrback(addFailureToReport)
+
self.bootstrapped.addBoth(cleanup)
return self.bootstrapped
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits