commit d5b45ca0e47729252da40b3994ce9e86140ffcf8 Author: Joe Landers joe@joelanders.net Date: Sun Feb 8 14:37:21 2015 +0100
factor out a level of if/elses --- ooni/nettests/blocking/bridge_reachability.py | 52 ++++++++++++------------- 1 file changed, 25 insertions(+), 27 deletions(-)
diff --git a/ooni/nettests/blocking/bridge_reachability.py b/ooni/nettests/blocking/bridge_reachability.py index e282853..1be175a 100644 --- a/ooni/nettests/blocking/bridge_reachability.py +++ b/ooni/nettests/blocking/bridge_reachability.py @@ -134,35 +134,33 @@ class BridgeReachability(nettest.NetTestCase):
if transport_name: self.report['transport_name'] = transport_name - - if transport_name and transport_name == 'fte' and self.fteproxy_bin: - config.ClientTransportPlugin = "%s exec %s --managed" % ( - transport_name, self.fteproxy_bin) - log.debug("Using fte from %s" % self.fteproxy_bin) - self.report['bridge_address'] = self.bridge.split(' ')[1] - elif transport_name and transport_name == 'fte'\ - and not self.fteproxy_bin: - log.err("Unable to test bridge because fteproxy is not installed") - self.report['error'] = 'missing-fteproxy' - return - elif transport_name and self.pyobfsproxy_bin: - config.ClientTransportPlugin = ("%s exec %s --log-min-severity info " - "--log-file %s managed") % (transport_name, - self.pyobfsproxy_bin, - self.obfsproxy_logfile) - if onion.OBFSProxyVersion('0.2') > onion.obfsproxy_details['version']: + if transport_name == 'fte' and self.fteproxy_bin: + config.ClientTransportPlugin = "%s exec %s --managed" % ( + transport_name, self.fteproxy_bin) + log.debug("Using fte from %s" % self.fteproxy_bin) + self.report['bridge_address'] = self.bridge.split(' ')[1] + elif transport_name == 'fte' and not self.fteproxy_bin: + log.err("Unable to test bridge because fteproxy is not installed") + self.report['error'] = 'missing-fteproxy' + return + elif self.pyobfsproxy_bin: + config.ClientTransportPlugin = ("%s exec %s --log-min-severity info " + "--log-file %s managed") % (transport_name, + self.pyobfsproxy_bin, + self.obfsproxy_logfile) + if onion.OBFSProxyVersion('0.2') > onion.obfsproxy_details['version']: + log.err( + "The obfsproxy version you are using appears to be outdated." + ) + self.report['error'] = 'old-obfsproxy' + return + log.debug("Using pyobfsproxy from %s" % self.pyobfsproxy_bin) + self.report['bridge_address'] = self.bridge.split(' ')[1] + else: log.err( - "The obfsproxy version you are using appears to be outdated." - ) - self.report['error'] = 'old-obfsproxy' + "Unable to test bridge because pyobfsproxy is not installed") + self.report['error'] = 'missing-pyobfsproxy' return - log.debug("Using pyobfsproxy from %s" % self.pyobfsproxy_bin) - self.report['bridge_address'] = self.bridge.split(' ')[1] - elif transport_name and not self.pyobfsproxy_bin: - log.err( - "Unable to test bridge because pyobfsproxy is not installed") - self.report['error'] = 'missing-pyobfsproxy' - return else: self.report['bridge_address'] = self.bridge.split(' ')[0]
tor-commits@lists.torproject.org