commit a1cf2789966b9550e3a044a0d3df7393328a7dee Author: Arturo Filastò arturo@filasto.net Date: Tue May 17 17:36:47 2016 +0200
Clean up the output of ooniprobe
* Make OneShotFactory not be noisy
* Don't log an error when we are just connecting to a backend to check if it's up. --- ooni/backend_client.py | 2 +- ooni/utils/net.py | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/ooni/backend_client.py b/ooni/backend_client.py index ae376e4..3b551d4 100644 --- a/ooni/backend_client.py +++ b/ooni/backend_client.py @@ -143,7 +143,7 @@ class OONIBClient(object): except ValueError: raise e.get_error(None) if 'error' in response: - log.err("Got this backend error message %s" % response) + log.debug("Got this backend error message %s" % response) raise e.get_error(response['error']) return response
diff --git a/ooni/utils/net.py b/ooni/utils/net.py index 1f87101..ad5454e 100644 --- a/ooni/utils/net.py +++ b/ooni/utils/net.py @@ -3,21 +3,21 @@ import socket from random import randint
from zope.interface import implements -from twisted.internet import protocol, defer +from twisted.internet import defer +from twisted.internet.protocol import Factory, Protocol from twisted.web.iweb import IBodyProducer
from scapy.config import conf
from ooni.errors import IfaceError
-try: - from twisted.internet.endpoints import connectProtocol -except ImportError: - def connectProtocol(endpoint, protocol): - class OneShotFactory(protocol.Factory): - def buildProtocol(self, addr): - return protocol - return endpoint.connect(OneShotFactory()) +# This is our own connectProtocol to avoid noisy twisted cluttering our logs +def connectProtocol(endpoint, protocol): + class OneShotFactory(Factory): + noisy = False + def buildProtocol(self, addr): + return protocol + return endpoint.connect(OneShotFactory())
# if sys.platform.system() == 'Windows': # import _winreg as winreg @@ -68,7 +68,7 @@ class StringProducer(object): pass
-class BodyReceiver(protocol.Protocol): +class BodyReceiver(Protocol): def __init__(self, finished, content_length=None, body_processor=None): self.finished = finished self.data = "" @@ -92,7 +92,7 @@ class BodyReceiver(protocol.Protocol): self.finished.errback(exc)
-class Downloader(protocol.Protocol): +class Downloader(Protocol): def __init__(self, download_path, finished, content_length=None): self.finished = finished @@ -113,7 +113,7 @@ class Downloader(protocol.Protocol): self.finished.callback(None)
-class ConnectAndCloseProtocol(protocol.Protocol): +class ConnectAndCloseProtocol(Protocol): def connectionMade(self): self.transport.loseConnection()
tor-commits@lists.torproject.org