commit d9ff0d3b1c8412a1254a91128ec6f423ce41361c Author: Arturo Filastò art@fuffa.org Date: Wed Nov 21 11:26:32 2012 +0100
Make the reporting directory of the collector configurable --- oonib/config.py | 1 + oonib/report/api.py | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/oonib/config.py b/oonib/config.py index 1a70b85..e07dc98 100644 --- a/oonib/config.py +++ b/oonib/config.py @@ -10,6 +10,7 @@ def get_root_path(): # XXX convert this to something that is a proper config file main = Storage() main.collector_port = 8888 +main.report_dir = os.path.join(get_root_path(), 'oonib', 'reports')
# XXX make this be the server name that is of main.database_uri = "sqlite:"+get_root_path()+"oonib_test_db.db" diff --git a/oonib/report/api.py b/oonib/report/api.py index bd409b0..1a81e68 100644 --- a/oonib/report/api.py +++ b/oonib/report/api.py @@ -10,13 +10,14 @@ import random import string import json import re -from ooni.utils import randomStr +import os
from twisted.internet import reactor, defer
from cyclone import web
-from oonib import models +from ooni.utils import randomStr +from oonib import models, config
backend_version = '0.0.1'
@@ -75,7 +76,7 @@ def parseUpdateReportRequest(request): report_id = parsed_request['report_id'] except KeyError: raise MissingField('report_id') - + if not re.match(report_id_regexp, report_id): raise InvalidRequestField('report_id')
@@ -131,7 +132,7 @@ class NewReportHandlerFile(web.RequestHandler): # report_data['test_name'], # report_data['test_version']))
- report_filename = report_id + report_filename = os.path.join(config.main.report_dir, report_id) report_filename += '.yamloo'
response = {'backend_version': backend_version, @@ -155,7 +156,7 @@ class NewReportHandlerFile(web.RequestHandler): report_id = parsed_request['report_id'] print "Got this request %s" % parsed_request
- report_filename = report_id + report_filename = os.path.join(config.main.report_dir, report_id) report_filename += '.yamloo' try: with open(report_filename, 'a+') as f:
tor-commits@lists.torproject.org