[tor-commits] [ooni-probe/master] Improve output of oonireport when running upload commands.
art at torproject.org
art at torproject.org
Sat Aug 9 23:04:25 UTC 2014
commit b98530c7b22f9297148d840d4000d1b47f4c6e30
Author: Arturo Filastò <art at fuffa.org>
Date: Thu Aug 7 19:20:16 2014 +0200
Improve output of oonireport when running upload commands.
---
ooni/report/cli.py | 15 +++++++++++++--
ooni/report/tool.py | 4 ++--
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/ooni/report/cli.py b/ooni/report/cli.py
index 6b611d5..6f98574 100644
--- a/ooni/report/cli.py
+++ b/ooni/report/cli.py
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
import os
import sys
@@ -21,7 +23,7 @@ class Options(usage.Options):
]
def opt_version(self):
- print "oonireport version:", __version__
+ print("oonireport version: %s" % __version__)
sys.exit(0)
def parseArgs(self, *args):
@@ -42,18 +44,27 @@ def parse_options():
try:
options.parseOptions()
except Exception as exc:
- print exc
+ print(exc)
return dict(options)
+def tor_check():
+ if not config.tor.socks_port:
+ print("Currently oonireport requires that you start Tor yourself "
+ "and set the socks_port inside of ooniprobe.conf")
+ sys.exit(1)
+
+
def run():
config.read_config_file()
options = parse_options()
if options['command'] == "upload" and options['report_file']:
+ tor_check()
return tool.upload(options['report_file'],
options['collector'],
options['bouncer'])
elif options['command'] == "upload":
+ tor_check()
return tool.upload_all(options['collector'],
options['bouncer'])
elif options['command'] == "status":
diff --git a/ooni/report/tool.py b/ooni/report/tool.py
index b8f60b0..e86626e 100644
--- a/ooni/report/tool.py
+++ b/ooni/report/tool.py
@@ -15,6 +15,8 @@ oonib_report_log = OONIBReportLog()
@defer.inlineCallbacks
def upload(report_file, collector=None, bouncer=None):
+ print "Attempting to upload %s" % report_file
+
with open(config.report_log_file) as f:
report_log = yaml.safe_load(f)
@@ -49,9 +51,7 @@ def upload(report_file, collector=None, bouncer=None):
@defer.inlineCallbacks
def upload_all(collector=None, bouncer=None):
- print "Running upload all..."
for report_file, value in oonib_report_log.reports_to_upload:
- print report_file
try:
yield upload(report_file, collector, bouncer)
except Exception as exc:
More information about the tor-commits
mailing list