diff options
author | Florian Zeitz <florob@babelmonkeys.de> | 2016-09-15 22:55:36 +0200 |
---|---|---|
committer | Florian Zeitz <florob@babelmonkeys.de> | 2016-09-15 22:55:36 +0200 |
commit | 9ffea4ad9ef0f0b23e5b4e5ebbfe5f140ecf5450 (patch) | |
tree | 54b1279870df9ce4fa828373d35d879e8ef431d7 /voctocore/lib/tcpsingleconnection.py | |
parent | 746d75dee7fb6291a900e0162345354e6eb41c13 (diff) |
voctocore: pep8ify
* Indent by 4 spaces
* Reformat some argument lists
* Two newlines before free functions
* One newline before methods
* Spaces around infix operators
Diffstat (limited to 'voctocore/lib/tcpsingleconnection.py')
-rw-r--r-- | voctocore/lib/tcpsingleconnection.py | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/voctocore/lib/tcpsingleconnection.py b/voctocore/lib/tcpsingleconnection.py index bf89651..2d3c658 100644 --- a/voctocore/lib/tcpsingleconnection.py +++ b/voctocore/lib/tcpsingleconnection.py @@ -1,39 +1,45 @@ -import logging, socket, time +import logging +import socket +import time from gi.repository import GObject from lib.config import Config + class TCPSingleConnection(object): - def __init__(self, port): - if not hasattr(self, 'log'): - self.log = logging.getLogger('TCPMultiConnection') - self.log.debug('Binding to Source-Socket on [::]:%u', port) - self.boundSocket = socket.socket(socket.AF_INET6) - self.boundSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - self.boundSocket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, False) - self.boundSocket.bind(('::', port)) - self.boundSocket.listen(1) + def __init__(self, port): + if not hasattr(self, 'log'): + self.log = logging.getLogger('TCPMultiConnection') + + self.log.debug('Binding to Source-Socket on [::]:%u', port) + self.boundSocket = socket.socket(socket.AF_INET6) + self.boundSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + self.boundSocket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, + False) + self.boundSocket.bind(('::', port)) + self.boundSocket.listen(1) - self.currentConnection = None + self.currentConnection = None - self.log.debug('Setting GObject io-watch on Socket') - GObject.io_add_watch(self.boundSocket, GObject.IO_IN, self.on_connect) + self.log.debug('Setting GObject io-watch on Socket') + GObject.io_add_watch(self.boundSocket, GObject.IO_IN, self.on_connect) - def on_connect(self, sock, *args): - conn, addr = sock.accept() - self.log.info("Incomming Connection from %s", addr) + def on_connect(self, sock, *args): + conn, addr = sock.accept() + self.log.info('Incomming Connection from %s', addr) - if self.currentConnection is not None: - self.log.warn("Another Source is already connected, closing existing pipeline") - self.disconnect() - time.sleep(1) + if self.currentConnection is not None: + self.log.warn('Another Source is already connected, ' + 'closing existing pipeline') + self.disconnect() + time.sleep(1) - self.on_accepted(conn, addr) - self.currentConnection = conn + self.on_accepted(conn, addr) + self.currentConnection = conn - return True + return True - def close_connection(self): - self.currentConnection = None - self.log.info('Connection closed') + def close_connection(self): + self.currentConnection = None + self.log.info('Connection closed') |