commit d98ea4c4fee6699b8be8462e71503e98be2e24d3 Author: Arturo Filastò art@fuffa.org Date: Fri Jun 7 22:13:20 2013 +0200
Add support for closing reports in ooni-probe --- ooni/director.py | 9 +++++---- ooni/reporter.py | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/ooni/director.py b/ooni/director.py index 809eae4..00ec039 100644 --- a/ooni/director.py +++ b/ooni/director.py @@ -171,7 +171,7 @@ class Director(object): """ pass
- def netTestDone(self, result, net_test): + def netTestDone(self, net_test): self.activeNetTests.remove(net_test) if len(self.activeNetTests) == 0: self.allTestsDone.callback(None) @@ -206,10 +206,11 @@ class Director(object):
self.activeNetTests.append(net_test)
- net_test.done.addBoth(report.close) - net_test.done.addBoth(self.netTestDone, net_test) - yield net_test.done + yield report.close() + + self.netTestDone(net_test) +
def startSniffing(self): """ Start sniffing with Scapy. Exits if required privileges (root) are not diff --git a/ooni/reporter.py b/ooni/reporter.py index b80a2a3..38519f7 100644 --- a/ooni/reporter.py +++ b/ooni/reporter.py @@ -242,8 +242,7 @@ class OONIBReporter(OReporter): if the oonib reporter is not valid. """ regexp = '^(http|httpo)://[a-zA-Z0-9-.]+(:\d+)?$' - if not re.match(regexp, self.collectorAddress) or \ - len(self.collectorAddress) < 30: + if not re.match(regexp, self.collectorAddress): raise errors.InvalidOONIBCollectorAddress
@defer.inlineCallbacks @@ -353,9 +352,11 @@ class OONIBReporter(OReporter): self.backendVersion = parsed_response['backend_version'] log.debug("Created report with id %s" % parsed_response['report_id'])
+ @defer.inlineCallbacks def finish(self): url = self.collectorAddress + '/report/' + self.reportID + '/close' - response = yield self.agent.request("POST", url) + log.debug("Closing the report %s" % url) + response = yield self.agent.request("POST", str(url))
class ReportClosed(Exception): pass @@ -464,7 +465,7 @@ class Report(object): raise errors.NoMoreReporters return
- def close(self, _): + def close(self): """ Close the report by calling it's finish method.
tor-commits@lists.torproject.org