[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Various code style fixes suggested by @bassosimone
commit 3483c8005ecf8eb0c856f04913f6132f547f2d84
Author: Arturo Filastò <arturo@xxxxxxxxxxx>
Date: Fri Sep 16 11:56:38 2016 +0200
Various code style fixes suggested by @bassosimone
---
ooni/reporter.py | 6 +++---
ooni/resources.py | 4 ++++
ooni/scripts/ooniprobe.py | 10 ++++++----
ooni/scripts/ooniprobe_agent.py | 12 +++++-------
ooni/scripts/ooniresources.py | 3 ++-
5 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/ooni/reporter.py b/ooni/reporter.py
index 951602f..ab32c54 100644
--- a/ooni/reporter.py
+++ b/ooni/reporter.py
@@ -221,7 +221,8 @@ class NJSONReporter(OReporter):
OReporter.__init__(self, test_details)
def _writeln(self, line):
- self._write("%s\n" % line)
+ self._write(line)
+ self._write("\n")
def _write(self, data):
if not self._stream:
@@ -249,8 +250,7 @@ class NJSONReporter(OReporter):
'test_keys': e
}
report_entry.update(self.testDetails)
- self._write(json.dumps(report_entry))
- self._write("\n")
+ self._writeln(json.dumps(report_entry))
def createReport(self):
self._stream = open(self.report_path, 'w+')
diff --git a/ooni/resources.py b/ooni/resources.py
index ac0f967..edb7781 100644
--- a/ooni/resources.py
+++ b/ooni/resources.py
@@ -91,6 +91,10 @@ def check_for_update(country_code=None):
Checks if we need to update the resources.
If the country_code is specified then only the resources for that
country will be updated/downloaded.
+
+ XXX we currently don't check the shasum of resources although this is
+ included inside of the manifest.
+ This should probably be done once we have signing of resources.
:return: the latest version.
"""
temporary_files = []
diff --git a/ooni/scripts/ooniprobe.py b/ooni/scripts/ooniprobe.py
index d67dd80..c8ffee2 100644
--- a/ooni/scripts/ooniprobe.py
+++ b/ooni/scripts/ooniprobe.py
@@ -12,10 +12,12 @@ def ooniprobe(reactor):
check_incoherences=True)
if global_options['queue']:
return runWithDaemonDirector(global_options)
- elif global_options['initialize']:
+
+ if global_options['initialize']:
initializeOoniprobe(global_options)
return defer.succeed(None)
- elif global_options['web-ui']:
+
+ if global_options['web-ui']:
from ooni.scripts.ooniprobe_agent import WEB_UI_URL
from ooni.scripts.ooniprobe_agent import status_agent, start_agent
if status_agent() != 0:
@@ -25,8 +27,8 @@ def ooniprobe(reactor):
print("Started ooniprobe-agent")
webbrowser.open_new(WEB_UI_URL)
return defer.succeed(None)
- else:
- return runWithDirector(global_options)
+
+ return runWithDirector(global_options)
def run():
task.react(ooniprobe)
diff --git a/ooni/scripts/ooniprobe_agent.py b/ooni/scripts/ooniprobe_agent.py
index c455f9b..479d230 100644
--- a/ooni/scripts/ooniprobe_agent.py
+++ b/ooni/scripts/ooniprobe_agent.py
@@ -1,6 +1,7 @@
from __future__ import print_function
import os
+import sys
import time
import errno
import signal
@@ -65,8 +66,9 @@ def start_agent(options=None):
twistd_args.append("StartOoniprobeAgent")
try:
twistd_config.parseOptions(twistd_args)
- except usage.error, ue:
+ except usage.error as ue:
print("ooniprobe: usage error from twistd: {}\n".format(ue))
+ sys.exit(1)
twistd_config.loadedPlugins = {
"StartOoniprobeAgent": StartOoniprobeAgentPlugin()
}
@@ -103,12 +105,8 @@ def get_running_pidfile():
pid = open(pidfile, "r").read()
pid = int(pid)
if is_process_running(pid):
- running_pidfile = pidfile
- else:
- continue
- if running_pidfile is None:
- raise NotRunning
- return running_pidfile
+ return pidfile
+ raise NotRunning
def status_agent():
try:
diff --git a/ooni/scripts/ooniresources.py b/ooni/scripts/ooniresources.py
index 5fdbbf0..8e77431 100644
--- a/ooni/scripts/ooniresources.py
+++ b/ooni/scripts/ooniresources.py
@@ -30,5 +30,6 @@ def run():
print "%s: Try --help for usage details." % (sys.argv[0])
sys.exit(1)
- print("WARNING: Usage of this script is deprecated.")
+ print("WARNING: Usage of this script is deprecated. We will not do "
+ "anything.")
sys.exit(0)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits