WIP: Handling a new pylint design checker message #17

Draft
lee.miller wants to merge 4 commits from lee.miller/MiNode:lint into v0.3
3 changed files with 11 additions and 26 deletions
Showing only changes of commit 1a6c796b7d - Show all commits

View File

@ -20,22 +20,19 @@ class ConnectionBase(threading.Thread):
Common code for the connection thread
with minimum command handlers to reuse
"""
def __init__(
self, host, port, s=None, network='ip', server=False,
i2p_remote_dest=b''
):
def __init__(self, host, port, s=None, server=False):
self.host = host
self.port = port
self.network = network
self.i2p_remote_dest = i2p_remote_dest
self.network = 'i2p' if port == 'i2p' else 'ip'
if self.network == 'i2p':
self.host_print = self.i2p_remote_dest[:8].decode()
else:
self.host_print = self.host
self.host_print = (
self.host[:8].decode() if self.network == 'i2p' else self.host)
super().__init__(name='Connection to {}:{}'.format(host, port))
self.s = s
self.server = server
self.send_queue = queue.Queue()
self.vectors_to_get = set()
@ -43,22 +40,13 @@ class ConnectionBase(threading.Thread):
self.vectors_requested = {}
self.status = 'ready'
self.tls = False
self.status = 'connected' if bool(s) else 'ready'
self.verack_received = False
self.verack_sent = False
self.s = s
self.remote_version = None
self.server = server
if bool(s):
self.status = 'connected'
self.buffer_receive = b''
self.buffer_send = b''
@ -238,7 +226,7 @@ class ConnectionBase(threading.Thread):
logging.debug('ssl.SSLError reason: %s', e.reason)
shared.node_pool.discard((self.host, self.port))
return
self.tls = True
logging.debug(
'Established TLS connection with %s:%s (%s)',
self.host_print, self.port, self.s.version())

View File

@ -28,9 +28,7 @@ class I2PDialer(I2PThread):
logging.debug('Connecting to %s', self.destination)
self._connect()
if not self.state.shutting_down and self.success:
c = self.state.connection(
self.destination, 'i2p', self.s, 'i2p',
False, self.destination)
c = self.state.connection(self.destination, 'i2p', self.s, False)
c.start()
self.state.connections.add(c)

View File

@ -45,8 +45,7 @@ class I2PListener(I2PThread):
logging.debug('Rejecting duplicate I2P connection.')
self.s.close()
else:
c = self.state.connection(
destination, 'i2p', self.s, 'i2p', True, destination)
c = self.state.connection(destination, 'i2p', self.s, True)
c.start()
self.state.connections.add(c)
c = None