[tor-commits] [ooni-probe/master] When we don't find the report inside of reporting.yaml upload to the canonical bouncer.
art at torproject.org
art at torproject.org
Fri Jun 3 09:35:02 UTC 2016
commit de75b701f0b5d25e4362cdaacb7c20815a41928d
Author: Arturo Filastò <arturo at filasto.net>
Date: Tue May 31 13:57:07 2016 +0200
When we don't find the report inside of reporting.yaml upload to the canonical bouncer.
* This fixes #515
---
ooni/__init__.py | 14 +++++++++++---
ooni/oonicli.py | 11 ++++-------
ooni/report/tool.py | 45 +++++++++++++++++++++++++++------------------
3 files changed, 42 insertions(+), 28 deletions(-)
diff --git a/ooni/__init__.py b/ooni/__init__.py
index 70d56cf..c416dee 100644
--- a/ooni/__init__.py
+++ b/ooni/__init__.py
@@ -5,7 +5,15 @@ __version__ = "1.5.1.dev0"
# This is the version number of resources to be downloaded
# when a release is made it should be aligned to __version__
__resources_version__ = "1.4.2"
+canonical_bouncer = 'httpo://nkvphnp3p6agi5qq.onion'
-__all__ = ['config', 'inputunit', 'kit',
- 'lib', 'nettest', 'oonicli', 'report', 'reporter',
- 'templates', 'utils']
+
+__all__ = [
+ 'common',
+ 'deckgen',
+ 'nettest',
+ 'report',
+ 'resources',
+ 'templates',
+ 'utils'
+]
diff --git a/ooni/oonicli.py b/ooni/oonicli.py
index 47c26b2..5aa538c 100644
--- a/ooni/oonicli.py
+++ b/ooni/oonicli.py
@@ -10,7 +10,7 @@ import urlparse
from twisted.python import usage
from twisted.internet import defer
-from ooni import errors, __version__
+from ooni import errors, __version__, canonical_bouncer
from ooni.settings import config
from ooni.utils import log
from backend_client import CollectorClient
@@ -44,12 +44,9 @@ class Options(usage.Options):
["collector", "c", None, "Specify the address of the collector for "
"test results. In most cases a user will "
"prefer to specify a bouncer over this."],
- ["bouncer", "b", 'httpo://nkvphnp3p6agi5qq.onion', "Specify the "
- "bouncer used to "
- "obtain the "
- "address of the "
- "collector and "
- "test helpers."],
+ ["bouncer", "b", canonical_bouncer, "Specify the bouncer used to "
+ "obtain the address of the "
+ "collector and test helpers."],
["logfile", "l", None, "Write to this logs to this filename."],
["pcapfile", "O", None, "Write a PCAP of the ooniprobe session to "
"this filename."],
diff --git a/ooni/report/tool.py b/ooni/report/tool.py
index d80a8e0..faa407f 100644
--- a/ooni/report/tool.py
+++ b/ooni/report/tool.py
@@ -4,6 +4,7 @@ import sys
from twisted.internet import defer
+from ooni import canonical_bouncer
from ooni.reporter import OONIBReporter, OONIBReportLog
from ooni.utils import log
@@ -11,6 +12,22 @@ from ooni.report import parser
from ooni.settings import config
from ooni.backend_client import BouncerClient, CollectorClient
+ at defer.inlineCallbacks
+def lookup_collector_client(report_header, bouncer):
+ oonib_client = BouncerClient(bouncer)
+ net_tests = [{
+ 'test-helpers': [],
+ 'input-hashes': report_header['input_hashes'],
+ 'name': report_header['test_name'],
+ 'version': report_header['test_version'],
+ }]
+ result = yield oonib_client.lookupTestCollector(
+ net_tests
+ )
+ collector_client = CollectorClient(
+ address=result['net-tests'][0]['collector']
+ )
+ defer.returnValue(collector_client)
@defer.inlineCallbacks
def upload(report_file, collector=None, bouncer=None):
@@ -26,34 +43,26 @@ def upload(report_file, collector=None, bouncer=None):
report = parser.ReportLoader(report_file)
if bouncer and collector_client is None:
- oonib_client = BouncerClient(bouncer)
- net_tests = [{
- 'test-helpers': [],
- 'input-hashes': report.header['input_hashes'],
- 'name': report.header['test_name'],
- 'version': report.header['test_version'],
- }]
- result = yield oonib_client.lookupTestCollector(
- net_tests
- )
- collector_client = CollectorClient(
- address=result['net-tests'][0]['collector']
- )
+ collector_client = yield lookup_collector_client(report.header,
+ bouncer)
if collector_client is None:
try:
collector_settings = report_log[report_file]['collector']
if collector_settings is None:
- raise KeyError
+ log.msg("Skipping uploading of %s since this measurement "
+ "was run by specifying no collector." %
+ report_file)
+ defer.returnValue(None)
elif isinstance(collector_settings, dict):
collector_client = CollectorClient(settings=collector_settings)
elif isinstance(collector_settings, str):
collector_client = CollectorClient(address=collector_settings)
except KeyError:
- raise Exception(
- "No collector or bouncer specified"
- " and collector not in report log."
- )
+ log.msg("Could not find %s in reporting.yaml. Looking up "
+ "collector with canonical bouncer." % report_file)
+ collector_client = yield lookup_collector_client(report.header,
+ canonical_bouncer)
oonib_reporter = OONIBReporter(report.header, collector_client)
log.msg("Creating report for %s with %s" % (report_file,
More information about the tor-commits
mailing list