[tor-commits] [ooni-probe/master] Place the annotations inside of the report headers.
art at torproject.org
art at torproject.org
Mon May 26 16:47:37 UTC 2014
commit 5a283100c38a56221683f2dc73c57aceafb0cf36
Author: Arturo Filastò <art at fuffa.org>
Date: Mon May 26 18:45:44 2014 +0200
Place the annotations inside of the report headers.
Store annotations as dict, not list.
---
ooni/director.py | 4 ++--
ooni/nettest.py | 13 +------------
ooni/oonicli.py | 15 +++++++++++++++
3 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/ooni/director.py b/ooni/director.py
index 1a00f08..4f0d4a1 100644
--- a/ooni/director.py
+++ b/ooni/director.py
@@ -129,8 +129,8 @@ class Director(object):
if config.global_options['no-geoip']:
aux = [False]
- if 'annotations' in config.global_options and config.global_options['annotations'] is not None:
- annotations = config.global_options['annotations'].lower()
+ if config.global_options.get('annotations') is not None:
+ annotations = [k.lower() for k in config.global_options['annotations'].keys()]
aux = map(lambda x: x in annotations, ["city", "country", "asn"])
if not all(aux):
log.msg("You should add annotations for the country, city and ASN")
diff --git a/ooni/nettest.py b/ooni/nettest.py
index 16e65f5..866e2d2 100644
--- a/ooni/nettest.py
+++ b/ooni/nettest.py
@@ -613,19 +613,8 @@ class NetTestCase(object):
This is the internal setup method to be overwritten by templates.
"""
self.report = {}
- if "annotations" in config.global_options and config.global_options["annotations"] is not None:
- annotations = []
- for annotation in config.global_options["annotations"].split(","):
- pair = annotation.split(":")
- if len(pair) == 2:
- key = pair[0].strip()
- value = pair[1].strip()
- annotations.append({key: value})
- else:
- log.err("Invalid annotation: %s" % annotation)
- self.report["annotations"] = annotations
self.inputs = None
-
+
def requirements(self):
"""
Place in here logic that will be executed before the test is to be run.
diff --git a/ooni/oonicli.py b/ooni/oonicli.py
index 37f514e..ec1ed9a 100644
--- a/ooni/oonicli.py
+++ b/ooni/oonicli.py
@@ -147,6 +147,19 @@ def runWithDirector(logging=True, start_tor=True):
sys.exit(0)
+ if global_options.get('annotations') is not None:
+ annotations = {}
+ for annotation in global_options["annotations"].split(","):
+ pair = annotation.split(":")
+ if len(pair) == 2:
+ key = pair[0].strip()
+ value = pair[1].strip()
+ annotations[key] = value
+ else:
+ log.err("Invalid annotation: %s" % annotation)
+ sys.exit(1)
+ global_options["annotations"] = annotations
+
#XXX: This should mean no bouncer either!
if global_options['no-collector']:
log.msg("Not reporting using a collector")
@@ -261,6 +274,8 @@ def runWithDirector(logging=True, start_tor=True):
raise errors.TorNotRunning
test_details = net_test_loader.testDetails
+ test_details['annotations'] = global_options['annotations']
+
yaml_reporter = YAMLReporter(test_details,
report_filename=global_options['reportfile'])
reporters = [yaml_reporter]
More information about the tor-commits
mailing list