[Pkg-privacy-commits] [obfsproxy] 110/353: Make pylint a bit happier.

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:01:47 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository obfsproxy.

commit 45905f660e34c123b5378d86f4593f09f5323e48
Author: George Kadianakis <desnacked at riseup.net>
Date:   Tue Feb 5 18:10:44 2013 +0000

    Make pylint a bit happier.
---
 obfsproxy/managed/client.py          |  5 +++--
 obfsproxy/managed/server.py          | 19 ++++++++++---------
 obfsproxy/network/extended_orport.py |  2 --
 obfsproxy/network/network.py         | 27 ++++++++++++++++-----------
 obfsproxy/network/socks.py           |  6 +++---
 obfsproxy/pyobfsproxy.py             | 15 +++++++--------
 obfsproxy/test/buffer_unittest.py    |  4 ++--
 obfsproxy/transports/obfs2.py        |  2 --
 obfsproxy/transports/obfs3_dh.py     |  2 --
 9 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/obfsproxy/managed/client.py b/obfsproxy/managed/client.py
index e605989..91eb286 100644
--- a/obfsproxy/managed/client.py
+++ b/obfsproxy/managed/client.py
@@ -1,7 +1,6 @@
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
 
-import obfsproxy.network.socks as socks
 from twisted.internet import reactor, error
 
 import obfsproxy.network.launch_transport as launch_transport
@@ -16,6 +15,8 @@ import pprint
 log = logging.get_obfslogger()
 
 def do_managed_client():
+    """Start the managed-proxy protocol as a client."""
+
     should_start_event_loop = False
 
     try:
@@ -40,7 +41,7 @@ def do_managed_client():
 
         should_start_event_loop = True
         log.debug("Successfully launched '%s' at '%s'" % (transport, log.safe_addr_str(str(addrport))))
-        reportSuccess(transport, 4, addrport, None, None) # XXX SOCKS v4 hardcoded
+        reportSuccess(transport, 4, addrport, None, None)
 
     reportEnd()
 
diff --git a/obfsproxy/managed/server.py b/obfsproxy/managed/server.py
index c1b0e3c..13542ae 100644
--- a/obfsproxy/managed/server.py
+++ b/obfsproxy/managed/server.py
@@ -1,12 +1,11 @@
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
 
-from twisted.internet import reactor, error, address, tcp
+from twisted.internet import reactor, error
 
 from pyptlib.server import init, reportSuccess, reportFailure, reportEnd
 from pyptlib.config import EnvError
 
-import obfsproxy.network.network as network
 import obfsproxy.transports.transports as transports
 import obfsproxy.network.launch_transport as launch_transport
 import obfsproxy.common.log as logging
@@ -16,29 +15,31 @@ import pprint
 log = logging.get_obfslogger()
 
 def do_managed_server():
+    """Start the managed-proxy protocol as a server."""
+
     should_start_event_loop = False
 
     try:
-        managedInfo = init(transports.transports.keys())
+        managed_info = init(transports.transports.keys())
     except EnvError, err:
         log.warning("Server managed-proxy protocol failed (%s)." % err)
         return
 
-    log.debug("pyptlib gave us the following data:\n'%s'", pprint.pformat(managedInfo))
+    log.debug("pyptlib gave us the following data:\n'%s'", pprint.pformat(managed_info))
 
-    for transport, transport_bindaddr in managedInfo['transports'].items():
+    for transport, transport_bindaddr in managed_info['transports'].items():
         try:
-            if managedInfo['ext_orport']:
+            if managed_info['ext_orport']:
                 addrport = launch_transport.launch_transport_listener(transport,
                                                                       transport_bindaddr,
                                                                       'ext_server',
-                                                                      managedInfo['ext_orport'],
-                                                                      managedInfo['auth_cookie_file'])
+                                                                      managed_info['ext_orport'],
+                                                                      managed_info['auth_cookie_file'])
             else:
                 addrport = launch_transport.launch_transport_listener(transport,
                                                                       transport_bindaddr,
                                                                       'server',
-                                                                      managedInfo['orport'])
+                                                                      managed_info['orport'])
         except transports.TransportNotFound:
             log.warning("Could not find transport '%s'" % transport)
             reportFailure(transport, "Could not find transport.")
diff --git a/obfsproxy/network/extended_orport.py b/obfsproxy/network/extended_orport.py
index 48bf350..3c238c5 100644
--- a/obfsproxy/network/extended_orport.py
+++ b/obfsproxy/network/extended_orport.py
@@ -1,6 +1,5 @@
 import os
 
-from twisted.internet.protocol import Protocol
 from twisted.internet import reactor
 
 import obfsproxy.common.log as logging
@@ -9,7 +8,6 @@ import obfsproxy.common.hmac_sha256 as hmac_sha256
 import obfsproxy.common.rand as rand
 
 import obfsproxy.network.network as network
-import obfsproxy.network.buffer as buffer
 
 log = logging.get_obfslogger()
 
diff --git a/obfsproxy/network/network.py b/obfsproxy/network/network.py
index 2116eb5..d7a6cad 100644
--- a/obfsproxy/network/network.py
+++ b/obfsproxy/network/network.py
@@ -1,11 +1,10 @@
-from twisted.python import failure
-from twisted.internet import reactor, error, address, tcp
-from twisted.internet.protocol import Protocol, Factory, ClientFactory
+from twisted.internet import reactor
+from twisted.internet.protocol import Protocol, Factory
 
 import obfsproxy.common.log as logging
 import obfsproxy.common.heartbeat as heartbeat
 
-import obfsproxy.network.buffer as buffer
+import obfsproxy.network.buffer as obfs_buf
 import obfsproxy.transports.base as base
 
 log = logging.get_obfslogger()
@@ -94,7 +93,8 @@ class Circuit(Protocol):
         assert(not self.downstream)
         self.downstream = conn
 
-        if self.circuitIsReady(): self.circuitCompleted(self.upstream)
+        if self.circuitIsReady():
+            self.circuitCompleted(self.upstream)
 
     def setUpstreamConnection(self, conn):
         """
@@ -105,7 +105,8 @@ class Circuit(Protocol):
         assert(not self.upstream)
         self.upstream = conn
 
-        if self.circuitIsReady(): self.circuitCompleted(self.downstream)
+        if self.circuitIsReady():
+            self.circuitCompleted(self.downstream)
 
     def circuitIsReady(self):
         """
@@ -161,14 +162,17 @@ class Circuit(Protocol):
         'reason' and 'side' tells us where it happened: either upstream or
         downstream.
         """
-        if self.closed: return # NOP if already closed
+        if self.closed:
+            return # NOP if already closed
 
         log.debug("%s: Tearing down circuit." % self.name)
 
         self.closed = True
 
-        if self.downstream: self.downstream.close()
-        if self.upstream: self.upstream.close()
+        if self.downstream:
+            self.downstream.close()
+        if self.upstream:
+            self.upstream.close()
 
         self.transport.circuitDestroyed(self, reason, side)
 
@@ -185,7 +189,7 @@ class GenericProtocol(Protocol, object):
     """
     def __init__(self, circuit):
         self.circuit = circuit
-        self.buffer = buffer.Buffer()
+        self.buffer = obfs_buf.Buffer()
         self.closed = False # True if connection is closed.
 
     def connectionLost(self, reason):
@@ -208,7 +212,8 @@ class GenericProtocol(Protocol, object):
         """
         Close the connection.
         """
-        if self.closed: return # NOP if already closed
+        if self.closed:
+            return # NOP if already closed
 
         log.debug("%s: Closing connection." % self.name)
 
diff --git a/obfsproxy/network/socks.py b/obfsproxy/network/socks.py
index 6032e94..8271837 100644
--- a/obfsproxy/network/socks.py
+++ b/obfsproxy/network/socks.py
@@ -1,9 +1,8 @@
 from twisted.protocols import socks
-from twisted.internet.protocol import Protocol, Factory, ClientFactory
+from twisted.internet.protocol import Factory
 
 import obfsproxy.common.log as logging
 import obfsproxy.network.network as network
-import obfsproxy.network.buffer as buffer
 
 log = logging.get_obfslogger()
 
@@ -48,7 +47,8 @@ class MySOCKSv4Outgoing(socks.SOCKSv4Outgoing, network.GenericProtocol):
         """
         Close the connection.
         """
-        if self.closed: return # NOP if already closed
+        if self.closed:
+            return # NOP if already closed
 
         log.debug("%s: Closing connection." % self.name)
 
diff --git a/obfsproxy/pyobfsproxy.py b/obfsproxy/pyobfsproxy.py
index 7f23554..d4d11f3 100755
--- a/obfsproxy/pyobfsproxy.py
+++ b/obfsproxy/pyobfsproxy.py
@@ -7,7 +7,6 @@ It is designed to be a drop-in replacement for the obfsproxy executable.
 Currently, not all of the obfsproxy command line options have been implemented.
 """
 
-import os
 import sys
 import argparse
 
@@ -43,13 +42,13 @@ def set_up_cli_parsing():
                         default=False,
                         help='disable safe (scrubbed address) logging')
 
-    """Managed mode is a subparser for now because there are no
-    optional subparsers: bugs.python.org/issue9253"""
-    sp = subparsers.add_parser("managed", help="managed mode")
+    # Managed mode is a subparser for now because there are no
+    # optional subparsers: bugs.python.org/issue9253
+    subparsers.add_parser("managed", help="managed mode")
 
-    """Add a subparser for each transport. Also add a
-    transport-specific function to later validate the parsed
-    arguments."""
+    # Add a subparser for each transport. Also add a
+    # transport-specific function to later validate the parsed
+    # arguments.
     for transport, transport_class in transports.transports.items():
         subparser = subparsers.add_parser(transport, help='%s help' % transport)
         transport_class['client'].register_external_mode_cli(subparser)
@@ -76,7 +75,7 @@ def do_external_mode(args):
 
     from twisted.internet import reactor
 
-    addrport = launch_transport.launch_transport_listener(args.name, args.listen_addr, args.mode, args.dest, args.ext_cookie_file)
+    launch_transport.launch_transport_listener(args.name, args.listen_addr, args.mode, args.dest, args.ext_cookie_file)
     log.info("Launched '%s' listener at '%s:%s' for transport '%s'." % \
                  (args.mode, log.safe_addr_str(args.listen_addr[0]), args.listen_addr[1], args.name))
     reactor.run()
diff --git a/obfsproxy/test/buffer_unittest.py b/obfsproxy/test/buffer_unittest.py
index 4deefea..6e02b16 100644
--- a/obfsproxy/test/buffer_unittest.py
+++ b/obfsproxy/test/buffer_unittest.py
@@ -1,11 +1,11 @@
 import unittest
 
-import obfsproxy.network.buffer as buffer
+import obfsproxy.network.buffer as obfs_buf
 
 class testBuffer(unittest.TestCase):
     def setUp(self):
         self.test_string = "No pop no style, I strictly roots."
-        self.buf = buffer.Buffer(self.test_string)
+        self.buf = obfs_buf.Buffer(self.test_string)
 
     def test_totalread(self):
         tmp = self.buf.read(-1)
diff --git a/obfsproxy/transports/obfs2.py b/obfsproxy/transports/obfs2.py
index ee06998..33c49d5 100644
--- a/obfsproxy/transports/obfs2.py
+++ b/obfsproxy/transports/obfs2.py
@@ -5,10 +5,8 @@
 The obfs2 module implements the obfs2 protocol.
 """
 
-import os
 import random
 import hashlib
-import struct
 
 import obfsproxy.common.aes as aes
 import obfsproxy.common.serialize as srlz
diff --git a/obfsproxy/transports/obfs3_dh.py b/obfsproxy/transports/obfs3_dh.py
index 6db25f9..117b66a 100644
--- a/obfsproxy/transports/obfs3_dh.py
+++ b/obfsproxy/transports/obfs3_dh.py
@@ -1,5 +1,3 @@
-import os
-import math
 import binascii
 
 import obfsproxy.common.rand as rand

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/obfsproxy.git



More information about the Pkg-privacy-commits mailing list