[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Fix bug in TCP connect test that made it not properly log errors



commit bcfa5d0785934d000fb78a54697281e86fd4f074
Author: Arturo Filastò <art@xxxxxxxxx>
Date:   Sun Dec 23 23:27:36 2012 +0100

    Fix bug in TCP connect test that made it not properly log errors
---
 nettests/blocking/tcpconnect.py |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/nettests/blocking/tcpconnect.py b/nettests/blocking/tcpconnect.py
index d0a53f8..b444c3b 100644
--- a/nettests/blocking/tcpconnect.py
+++ b/nettests/blocking/tcpconnect.py
@@ -3,9 +3,10 @@ from twisted.internet.protocol import Factory, Protocol
 from twisted.internet.endpoints import TCP4ClientEndpoint
 
 from twisted.internet.error import ConnectionRefusedError
-from twisted.internet.error import TCPTimedOutError 
+from twisted.internet.error import TCPTimedOutError, TimeoutError
 
 from ooni import nettest
+from ooni.nettest import handleAllFailures
 from ooni.utils import log
 
 class TCPFactory(Factory):
@@ -33,14 +34,7 @@ class TCPConnectTest(nettest.NetTestCase):
             self.report["connection"] = 'success'
 
         def connectionFailed(failure):
-            failure.trap(ConnectionRefusedError, TCPTimedOutError)
-            log.debug("Unable to connect to %s" % self.input)
-            if isinstance(failure, ConnectionRefusedError):
-                self.report["connection"] = 'refused'
-            elif isinstance(failure, TCPTimedOutError):
-                self.report["connection"] = 'timeout'
-            else:
-                self.report["connection"] = 'failed'
+            self.report['connection'] = handleAllFailures(failure)
 
         from twisted.internet import reactor
         point = TCP4ClientEndpoint(reactor, host, int(port))

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits