[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Add config file option for setting the location of the report_log



commit a923800d13c0e2161692717114fa9103fd556e3b
Author: Arturo Filastò <art@xxxxxxxxx>
Date:   Wed Jan 21 12:23:10 2015 +0100

    Add config file option for setting the location of the report_log
---
 data/ooniprobe.conf.sample |    1 +
 ooni/report/tool.py        |   12 ++++++++----
 ooni/reporter.py           |    4 +++-
 ooni/settings.py           |    9 +++++++--
 4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/data/ooniprobe.conf.sample b/data/ooniprobe.conf.sample
index 3c9cea9..6c8f7f3 100644
--- a/data/ooniprobe.conf.sample
+++ b/data/ooniprobe.conf.sample
@@ -46,6 +46,7 @@ advanced:
     # How many reports to perform concurrently
     reporting_concurrency: 15
     oonid_api_port: 8042
+    report_log_file: null
 tor:
     #socks_port: 8801
     #control_port: 8802
diff --git a/ooni/report/tool.py b/ooni/report/tool.py
index e86626e..11dbeda 100644
--- a/ooni/report/tool.py
+++ b/ooni/report/tool.py
@@ -10,11 +10,10 @@ from ooni.settings import config
 from ooni.oonibclient import OONIBClient
 
 
-oonib_report_log = OONIBReportLog()
-
-
 @defer.inlineCallbacks
 def upload(report_file, collector=None, bouncer=None):
+    oonib_report_log = OONIBReportLog()
+
     print "Attempting to upload %s" % report_file
 
     with open(config.report_log_file) as f:
@@ -34,7 +33,8 @@ def upload(report_file, collector=None, bouncer=None):
                 raise KeyError
         except KeyError:
             raise Exception(
-                "No collector or bouncer specified and collector not in report log."
+                "No collector or bouncer specified"
+                " and collector not in report log."
             )
 
     oonib_reporter = OONIBReporter(report.header, collector)
@@ -51,6 +51,8 @@ def upload(report_file, collector=None, bouncer=None):
 
 @defer.inlineCallbacks
 def upload_all(collector=None, bouncer=None):
+    oonib_report_log = OONIBReportLog()
+
     for report_file, value in oonib_report_log.reports_to_upload:
         try:
             yield upload(report_file, collector, bouncer)
@@ -64,6 +66,8 @@ def print_report(report_file, value):
 
 
 def status():
+    oonib_report_log = OONIBReportLog()
+
     print "Reports to be uploaded"
     print "----------------------"
     for report_file, value in oonib_report_log.reports_to_upload:
diff --git a/ooni/reporter.py b/ooni/reporter.py
index cbea9f7..34ff333 100644
--- a/ooni/reporter.py
+++ b/ooni/reporter.py
@@ -386,7 +386,9 @@ class OONIBReportLog(object):
     Used to keep track of report creation on a collector backend.
     """
 
-    def __init__(self, file_name=config.report_log_file):
+    def __init__(self, file_name=None):
+        if file_name is None:
+            file_name = config.report_log_file
         self.file_name = file_name
         self.create_report_log()
 
diff --git a/ooni/settings.py b/ooni/settings.py
index 4dc2221..b0b032c 100644
--- a/ooni/settings.py
+++ b/ooni/settings.py
@@ -98,9 +98,14 @@ class OConfig(object):
 
         self.inputs_directory = os.path.join(self.ooni_home, 'inputs')
         self.decks_directory = os.path.join(self.ooni_home, 'decks')
-        self.report_log_file = os.path.join(self.ooni_home, 'reporting.yml')
+        self.reports_directory = os.path.join(self.ooni_home, 'reports')
         self.resources_directory = os.path.join(self.data_directory,
-                                                'resources')
+                                                "resources")
+        if self.advanced.report_log_file:
+            self.report_log_file = self.advanced.report_log_file
+        else:
+            self.report_log_file = os.path.join(self.ooni_home,
+                                                'reporting.yml')
 
         if self.global_options.get('configfile'):
             config_file = self.global_options['configfile']



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits