[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [oonib/master] Make the 'content' field in the report creation optional
commit 1a77b236eb63b65496166b3814b2cda15da9c146
Author: Arturo Filastò <art@xxxxxxxxx>
Date: Tue Jan 28 18:41:10 2014 +0100
Make the 'content' field in the report creation optional
(as per oonib specification)
---
oonib/report/handlers.py | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/oonib/report/handlers.py b/oonib/report/handlers.py
index a970f4d..43c7499 100644
--- a/oonib/report/handlers.py
+++ b/oonib/report/handlers.py
@@ -258,17 +258,27 @@ class NewReportHandlerFile(OONIBHandler, UpdateReportMixin):
raise e.InputHashNotProvided
self.checkPolicy()
- content = yaml.safe_load(report_data['content'])
- content['backend_version'] = config.backend_version
+ if 'content' in report_data:
+ content = yaml.safe_load(report_data['content'])
+ try:
+ report_header = validate_report_header(content)
- try:
- report_header = validate_report_header(content)
+ except MissingReportHeaderKey, key:
+ raise e.MissingReportHeaderKey(key)
- except MissingReportHeaderKey, key:
- raise e.MissingReportHeaderKey(key)
+ except InvalidReportHeader, key:
+ raise e.InvalidReportHeader(key)
+ else:
+ content = {
+ 'software_name': software_name,
+ 'software_version': software_version,
+ 'probe_asn': probe_asn,
+ 'test_name': self.testName,
+ 'test_version': self.testVersion,
+ 'input_hashes': self.inputHashes
+ }
- except InvalidReportHeader, key:
- raise e.InvalidReportHeader(key)
+ content['backend_version'] = config.backend_version
report_header = yaml.dump(report_header)
content = "---\n" + report_header + '...\n'
@@ -289,7 +299,6 @@ class NewReportHandlerFile(OONIBHandler, UpdateReportMixin):
'report_id': report_id
}
-
try:
requested_helper = report_data['test_helper']
except KeyError:
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits