[tor-commits] [ooni-probe/master] Fail gracefully when twisted is <= 10.x and we attempt to import RedirectAgent

art at torproject.org art at torproject.org
Sat Oct 6 09:49:31 UTC 2012


commit 302dd54259fc6e69d3f276bcb458350344552887
Author: Arturo Filastò <arturo at filasto.net>
Date:   Sat Oct 6 09:49:01 2012 +0000

    Fail gracefully when twisted is <= 10.x and we attempt to import RedirectAgent
---
 ooni/nettest.py         |    3 +++
 ooni/templates/httpt.py |   11 +++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ooni/nettest.py b/ooni/nettest.py
index d7188c6..d88c044 100644
--- a/ooni/nettest.py
+++ b/ooni/nettest.py
@@ -77,6 +77,9 @@ class TestCase(unittest.TestCase):
     inputFile = None
     inputProcessor = lineByLine
 
+    report = {}
+    report['errors'] = []
+
     def getOptions(self):
         if self.inputFile:
             fp = open(self.inputFile)
diff --git a/ooni/templates/httpt.py b/ooni/templates/httpt.py
index 4b8fa9b..963189a 100644
--- a/ooni/templates/httpt.py
+++ b/ooni/templates/httpt.py
@@ -65,8 +65,15 @@ class HTTPTest(TestCase):
         self.agent = Agent(reactor)
 
         if self.followRedirects:
-            from twisted.web.client import RedirectAgent
-            self.agent = RedirectAgent(self.agent)
+            try:
+                from twisted.web.client import RedirectAgent
+                self.agent = RedirectAgent(self.agent)
+            except:
+                log.err("Warning! You are running an old version of twisted"\
+                        "(<= 10.1). I will not be able to follow redirects."\
+                        "This may make the testing less precise.")
+                self.report['errors'].append("Could not import RedirectAgent")
+
         self.request = {}
         self.response = {}
 



More information about the tor-commits mailing list