commit defe98fadaed6fcf45dc5d9ac93a964e0d306a78 Author: Arturo Filastò art@fuffa.org Date: Mon May 26 18:47:10 2014 +0200
Fix misc pylint related errors --- ooni/director.py | 10 +++------- ooni/nettest.py | 12 ++++++------ ooni/oonicli.py | 6 ++---- ooni/reporter.py | 16 +++++----------- 4 files changed, 16 insertions(+), 28 deletions(-)
diff --git a/ooni/director.py b/ooni/director.py index 4f0d4a1..21ac9fc 100644 --- a/ooni/director.py +++ b/ooni/director.py @@ -1,9 +1,5 @@ -import random -import sys import os -import re
-from ooni import geoip from ooni.managers import ReportEntryManager, MeasurementManager from ooni.reporter import Report from ooni.utils import log, pushFilenameStack @@ -110,7 +106,7 @@ class Director(object):
if nettest['id'] in nettests: log.err("Found a two tests with the same name %s, %s" % - (nettest_path, nettests[nettest['id']]['path'])) + (net_test_file, nettests[nettest['id']]['path'])) else: category = dirname.replace(config.nettest_directory, '') nettests[nettest['id']] = nettest @@ -289,7 +285,7 @@ class Director(object): log.debug("We now have the following circuits: ") for circuit in state.circuits.values(): log.debug(" * %s" % circuit) - + socks_port = yield state.protocol.get_conf("SocksPort") control_port = yield state.protocol.get_conf("ControlPort")
@@ -344,7 +340,7 @@ class Director(object): else: bridges.append(bridge.strip()) tor_config.Bridge = bridges - + if config.tor.torrc: for i in config.tor.torrc.keys(): setattr(tor_config, i, config.tor.torrc[i]) diff --git a/ooni/nettest.py b/ooni/nettest.py index 866e2d2..4598871 100644 --- a/ooni/nettest.py +++ b/ooni/nettest.py @@ -293,7 +293,7 @@ class NetTestLoader(object):
if not test_cases: raise e.NoTestCasesFound - + self.setupTestCases(test_cases)
def setupTestCases(self, test_cases): @@ -435,10 +435,10 @@ class NetTest(object): self.done.addCallback(self.doneNetTest)
self.state = NetTestState(self.done) - + def __str__(self): return ' '.join(tc.name for tc, _ in self.testCases) - + def doneNetTest(self, result): if not self.summary: return @@ -601,7 +601,7 @@ class NetTestCase(object): optParameters = None baseParameters = None baseFlags = None - + requiredTestHelpers = {} requiredOptions = [] requiresRoot = False @@ -709,7 +709,7 @@ class NetTestCase(object):
We check to see if it's possible to have an input file and if the user has specified such file. - +
If the operations to be done here are network related or blocking, they should be wrapped in a deferred. That is the return value of this @@ -725,7 +725,7 @@ class NetTestCase(object):
if self.inputs: return self.inputs - + return None
def _checkValidOptions(self): diff --git a/ooni/oonicli.py b/ooni/oonicli.py index ec1ed9a..e29d20a 100644 --- a/ooni/oonicli.py +++ b/ooni/oonicli.py @@ -2,13 +2,11 @@
import sys import os -import time import yaml -import random
-from twisted.internet import reactor from twisted.python import usage from twisted.python.util import spewer +from twisted.internet import defer
from ooni import errors, __version__
@@ -197,7 +195,7 @@ def runWithDirector(logging=True, start_tor=True): except Exception as e: log.err(e) sys.exit(5) - + d = director.start(start_tor=start_tor)
def setup_nettest(_): diff --git a/ooni/reporter.py b/ooni/reporter.py index a512891..33b4fdf 100644 --- a/ooni/reporter.py +++ b/ooni/reporter.py @@ -1,10 +1,6 @@ -import traceback -import itertools -import logging import time import yaml import json -import sys import os import re
@@ -13,12 +9,10 @@ from yaml.emitter import * from yaml.serializer import * from yaml.resolver import * from twisted.python.util import untilConcludes -from twisted.trial import reporter -from twisted.internet import defer, reactor +from twisted.internet import defer from twisted.internet.error import ConnectionRefusedError from twisted.python.failure import Failure from twisted.internet.endpoints import TCP4ClientEndpoint -from twisted.web.client import Agent
from ooni.utils import log from ooni.tasks import Measurement @@ -33,7 +27,7 @@ from ooni import errors
from ooni import otime from ooni.utils import pushFilenameStack -from ooni.utils.net import BodyReceiver, StringProducer, userAgents +from ooni.utils.net import BodyReceiver, StringProducer
from ooni.settings import config
@@ -171,7 +165,7 @@ class YAMLReporter(OReporter):
if not os.path.isdir(report_destination): raise InvalidDestination - + if not report_filename: report_filename = "report-" + \ test_details['test_name'] + "-" + \ @@ -301,7 +295,7 @@ class OONIBReporter(OReporter):
from txsocksx.http import SOCKS5Agent from twisted.internet import reactor - + if self.collectorAddress.startswith('httpo://'): self.collectorAddress = \ self.collectorAddress.replace('httpo://', 'http://') @@ -369,7 +363,7 @@ class OONIBReporter(OReporter): log.err("Failed to parse collector response %s" % backend_response) log.exception(e) raise errors.OONIBReportCreationError - + if response.code == 406: # XXX make this more strict log.err("The specified input or nettests cannot be submitted to this collector.")
tor-commits@lists.torproject.org