commit 5bf37ab039a64937cdd97959069145148d5d36d2 Author: Arturo Filastò art@fuffa.org Date: Fri Jan 18 00:24:20 2013 +0100
Move the instancing of the t.i.w.Agent into createReport
Add XXX about possible cleaner solutions to the problem --- ooni/reporter.py | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/ooni/reporter.py b/ooni/reporter.py index bfd2330..c9fb61d 100644 --- a/ooni/reporter.py +++ b/ooni/reporter.py @@ -242,14 +242,6 @@ class OONIBReporter(OReporter):
self.reportID = None
- from ooni.utils.txagentwithsocks import Agent - from twisted.internet import reactor - try: - self.agent = Agent(reactor, sockshost="127.0.0.1", - socksport=int(config.tor.socks_port)) - except Exception, e: - log.exception(e) - OReporter.__init__(self, test_details)
def validateCollectorAddress(self): @@ -293,6 +285,20 @@ class OONIBReporter(OReporter): """ Creates a report on the oonib collector. """ + # XXX we should probably be setting this inside of the constructor, + # however config.tor.socks_port is not set until Tor is started and the + # reporter is instantiated before Tor is started. We probably want to + # do this with some deferred kung foo or instantiate the reporter after + # tor is started. + + from ooni.utils.txagentwithsocks import Agent + from twisted.internet import reactor + try: + self.agent = Agent(reactor, sockshost="127.0.0.1", + socksport=int(config.tor.socks_port)) + except Exception, e: + log.exception(e) + url = self.collectorAddress + '/report'
content = '---\n'