[Pkg-privacy-commits] [obfsproxy] 42/353: PEP 8 formatting

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:01:37 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 a6c3ec1ba9d832ca7d2e762377d367e68396278f
Author: Brandon Wiley <brandon at blanu.net>
Date:   Mon Aug 27 19:29:38 2012 -0500

    PEP 8 formatting
---
 src/cli.py                             | 14 +++++-----
 src/obfsproxy/framework/pump.py        | 31 +++++++++++++++-------
 src/obfsproxy/framework/socks.py       |  2 ++
 src/obfsproxy/framework/tunnel.py      | 48 ++++++++++++++++++++--------------
 src/obfsproxy/manager/clientManager.py | 16 ++++++------
 src/obfsproxy/manager/serverManager.py | 10 +++----
 src/obfsproxy/transports/base.py       |  3 +++
 src/obfsproxy/transports/dummy.py      |  3 +++
 8 files changed, 79 insertions(+), 48 deletions(-)

diff --git a/src/cli.py b/src/cli.py
index 1f14aee..5b57270 100644
--- a/src/cli.py
+++ b/src/cli.py
@@ -59,10 +59,12 @@ if __name__ == '__main__':
         logging.error('Exception parsing')
         logging.error(str(e))
 
-    if args.log_file and len(args.log_file)>0:
-      logging.error('file logging: '+str(args.log_file[0])+' '+str(os.path.exists(args.log_file[0])))
-      logging.config.fileConfig(str(args.log_file[0]), disable_existing_loggers=False)
-      logging.error('new logging in place')
+    if args.log_file and len(args.log_file) > 0:
+        logging.error('file logging: ' + str(args.log_file[0]) + ' '
+                      + str(os.path.exists(args.log_file[0])))
+        logging.config.fileConfig(str(args.log_file[0]),
+                                  disable_existing_loggers=False)
+        logging.error('new logging in place')
 
     logging.error('py-obfsproxy CLI loaded')
 
@@ -77,6 +79,6 @@ if __name__ == '__main__':
                 daemon = ManagedServer()
         else:
             logging.error('Unsupported mode. Only managed mode is available at the moment.'
-                      )
+                          )
     except:
-      logging.exception('Exception launching daemon')
+        logging.exception('Exception launching daemon')
diff --git a/src/obfsproxy/framework/pump.py b/src/obfsproxy/framework/pump.py
index 2e82904..b849063 100644
--- a/src/obfsproxy/framework/pump.py
+++ b/src/obfsproxy/framework/pump.py
@@ -17,6 +17,7 @@ from obfsproxy.framework.circuit import Circuit
 
 
 class Pump(object):
+
     """ The Pump class takes care of moving bytes between the upstream and downstream connections. """
 
     def __init__(
@@ -37,6 +38,7 @@ class Pump(object):
     @_o
     def run(self):
         """ Calls the start event on the transport and initiates pumping between upstream and downstream connections in both directions. """
+
         self.transport.start()
 
         self.drain()
@@ -51,11 +53,17 @@ class Pump(object):
         yield self.pumpOut(self.circuit.upstream, self.upstream)
 
     @_o
-    def pumpIn(self, input, output, callback):
+    def pumpIn(
+        self,
+        input,
+        output,
+        callback,
+        ):
         logging.error('pumpIn')
-        data=yield input.read_some()
+        data = (yield input.read_some())
         if data:
-            logging.error('Pump read '+str(len(data))+' from tunnel')
+            logging.error('Pump read ' + str(len(data)) + ' from tunnel'
+                          )
             try:
                 data = (yield self.downstream.read_some())
                 if data:
@@ -75,9 +83,10 @@ class Pump(object):
     @_o
     def pumpOut(self, input, output):
         logging.error('pumpOut')
-        data=input.read_some()
+        data = input.read_some()
         if data:
-            logging.error('Pump read '+str(len(data))+' from tunnel')
+            logging.error('Pump read ' + str(len(data)) + ' from tunnel'
+                          )
             try:
                 yield output.write(data)
             except:
@@ -85,14 +94,18 @@ class Pump(object):
 
     @_o
     def pumpUpstream(self):
-	logging.error('pump local')
+        logging.error('pump local')
         while True:
-            yield self.pumpIn(self.dowstream, self.circuit.dowstream, self.transport.downstreamReceived)
+            yield self.pumpIn(self.dowstream, self.circuit.dowstream,
+                              self.transport.downstreamReceived)
             yield self.drain()
 
     @_o
     def pumpDownstream(self):
-	logging.error('pump remote')
+        logging.error('pump remote')
         while True:
-            yield self.pumpIn(self.upstream, self.circuit.upstream, self.transport.upstreamReceived)
+            yield self.pumpIn(self.upstream, self.circuit.upstream,
+                              self.transport.upstreamReceived)
             yield self.drain()
+
+
diff --git a/src/obfsproxy/framework/socks.py b/src/obfsproxy/framework/socks.py
index cf7f735..4f6412f 100644
--- a/src/obfsproxy/framework/socks.py
+++ b/src/obfsproxy/framework/socks.py
@@ -107,3 +107,5 @@ class SocksHandler:
 
         self.pump = Pump(conn, client, self.transport)
         self.pump.run()
+
+
diff --git a/src/obfsproxy/framework/tunnel.py b/src/obfsproxy/framework/tunnel.py
index 2b5107a..fd029f9 100644
--- a/src/obfsproxy/framework/tunnel.py
+++ b/src/obfsproxy/framework/tunnel.py
@@ -3,42 +3,47 @@
 
 import logging
 
+
 class Buffer(object):
+
     def __init__(self):
-        self.buffer=bytes('')
+        self.buffer = bytes('')
 
     def read(self, x):
-        if len(self.buffer)<x:
+        if len(self.buffer) < x:
             return None
         else:
-            data=self.buffer[:x]
-            self.buffer=self.buffer[x:]
+            data = self.buffer[:x]
+            self.buffer = self.buffer[x:]
             return data
 
     def read_some(self):
-	logging.error('buffer read_some '+str(len(self.buffer))+' '+str(self))
-        logging.error('before '+str(self.buffer))
-        data=self.read(len(self.buffer))
-        logging.error('after '+str(self.buffer))
+        logging.error('buffer read_some ' + str(len(self.buffer)) + ' '
+                      + str(self))
+        logging.error('before ' + str(self.buffer))
+        data = self.read(len(self.buffer))
+        logging.error('after ' + str(self.buffer))
         return data
 
     def write(self, bs):
-        logging.error('buffer write '+str(len(bs))+' '+str(self))
-        logging.error('before '+str(self.buffer))
-        self.buffer=self.buffer+bs
-        logging.error('after '+str(self.buffer))
+        logging.error('buffer write ' + str(len(bs)) + ' ' + str(self))
+        logging.error('before ' + str(self.buffer))
+        self.buffer = self.buffer + bs
+        logging.error('after ' + str(self.buffer))
+
 
 class Channel(object):
+
     def __init__(self, incoming=None, outgoing=None):
         if incoming:
-            self.incomingBuffer=incoming
+            self.incomingBuffer = incoming
         else:
-            self.incomingBuffer=Buffer()
+            self.incomingBuffer = Buffer()
 
         if outgoing:
-            self.outgoingBuffer=outgoing
+            self.outgoingBuffer = outgoing
         else:
-            self.outgoingBuffer=Buffer()
+            self.outgoingBuffer = Buffer()
 
     def invert(self):
         return Channel(self.outgoingBuffer, self.incomingBuffer)
@@ -52,17 +57,20 @@ class Channel(object):
     def write(self, bs):
         self.outgoingBuffer.write(bs)
 
+
 class Tunnel(object):
+
     def __init__(self, local=None, remote=None):
         if local:
-            self.local=local
+            self.local = local
         else:
-            self.local=Channel()
+            self.local = Channel()
         if remote:
-            self.remote=remote
+            self.remote = remote
         else:
-            self.remote=Channel()
+            self.remote = Channel()
 
     def invert(self):
         return Tunnel(self.local.invert(), self.remote.invert())
 
+
diff --git a/src/obfsproxy/manager/clientManager.py b/src/obfsproxy/manager/clientManager.py
index bec2670..1b418e9 100644
--- a/src/obfsproxy/manager/clientManager.py
+++ b/src/obfsproxy/manager/clientManager.py
@@ -30,12 +30,12 @@ class ClientManager(Manager):
 
 
 if __name__ == '__main__':
-    if len(sys.argv)<2:
-      print('clientManager [transport]')
+    if len(sys.argv) < 2:
+        print 'clientManager [transport]'
     else:
-      try:
-        transport = sys.argv[1]
-        manager = ClientManager(transport)
-        manager.launch()
-      except Exception as e:
-        print('Exception: '+str(e))
+        try:
+            transport = sys.argv[1]
+            manager = ClientManager(transport)
+            manager.launch()
+        except Exception, e:
+            print 'Exception: ' + str(e)
diff --git a/src/obfsproxy/manager/serverManager.py b/src/obfsproxy/manager/serverManager.py
index b262775..1c4ba63 100644
--- a/src/obfsproxy/manager/serverManager.py
+++ b/src/obfsproxy/manager/serverManager.py
@@ -34,9 +34,9 @@ class ServerManager(Manager):
 
 
 if __name__ == '__main__':
-    if len(sys.argv)<2:
-      print('serverManager [transport]')
+    if len(sys.argv) < 2:
+        print 'serverManager [transport]'
     else:
-      transport = sys.argv[1]
-      manager = ServerManager(transport)
-      manager.launch()
+        transport = sys.argv[1]
+        manager = ServerManager(transport)
+        manager.launch()
diff --git a/src/obfsproxy/transports/base.py b/src/obfsproxy/transports/base.py
index 9503675..8567894 100644
--- a/src/obfsproxy/transports/base.py
+++ b/src/obfsproxy/transports/base.py
@@ -9,6 +9,7 @@ However, BaseDaemon provides utility methods that are useful for a variety of co
 
 
 class BaseDaemon:
+
     """
     The BaseDaemon class is a base class for implementing pluggable transport clients and server.
     """
@@ -88,3 +89,5 @@ class BaseDaemon:
         """
 
         pass
+
+
diff --git a/src/obfsproxy/transports/dummy.py b/src/obfsproxy/transports/dummy.py
index 908c529..4696d24 100644
--- a/src/obfsproxy/transports/dummy.py
+++ b/src/obfsproxy/transports/dummy.py
@@ -9,6 +9,7 @@ from obfsproxy.transports.base import BaseDaemon
 
 
 class DummyDaemon(BaseDaemon):
+
     """
     DummyDaemon is the base class for DummyClient and DummyServer.
     Since the protocol is so simple, DummyDaemon provides all of the functionality for the dummy protocol implementation.
@@ -32,7 +33,9 @@ class DummyDaemon(BaseDaemon):
         data = self.upstreamConnection.readAll()
         self.downstreamConnection.write(data)
 
+
 class DummyClient(DummyDaemon):
+
     """
     DummyClient is a client for the 'dummy' protocol.
     Since this protocol is so simple, the client and the server are identical and both just trivially subclass DummyDaemon.

-- 
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