connectionpool.py pylint fixes

This commit is contained in:
lakshyacis 2019-08-31 14:36:53 +05:30
parent 5521c16478
commit f1b6b16940
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB

View File

@ -1,3 +1,7 @@
"""
src/network/connectionpool.py
==================================
"""
import errno import errno
import re import re
import socket import socket
@ -20,6 +24,7 @@ from udp import UDPSocket
@Singleton @Singleton
# pylint: disable=too-many-instance-attributes
class BMConnectionPool(object): class BMConnectionPool(object):
"""Pool of all existing connections""" """Pool of all existing connections"""
def __init__(self): def __init__(self):
@ -113,7 +118,8 @@ class BMConnectionPool(object):
pass pass
connection.handle_close() connection.handle_close()
def getListeningIP(self): @staticmethod
def getListeningIP():
"""What IP are we supposed to be listening on?""" """What IP are we supposed to be listening on?"""
if BMConfigParser().safeGet( if BMConfigParser().safeGet(
"bitmessagesettings", "onionhostname").endswith(".onion"): "bitmessagesettings", "onionhostname").endswith(".onion"):
@ -154,7 +160,7 @@ class BMConnectionPool(object):
udpSocket = UDPSocket(host=bind, announcing=True) udpSocket = UDPSocket(host=bind, announcing=True)
self.udpSockets[udpSocket.listening.host] = udpSocket self.udpSockets[udpSocket.listening.host] = udpSocket
def loop(self): def loop(self): # pylint: disable=too-many-branches, too-many-statements
"""Main Connectionpool's loop""" """Main Connectionpool's loop"""
# defaults to empty loop if outbound connections are maxed # defaults to empty loop if outbound connections are maxed
spawnConnections = False spawnConnections = False
@ -176,6 +182,7 @@ class BMConnectionPool(object):
'bitmessagesettings', 'onionhostname', '')): 'bitmessagesettings', 'onionhostname', '')):
acceptConnections = False acceptConnections = False
# pylint: disable=too-many-nested-blocks
if spawnConnections: if spawnConnections:
if not knownnodes.knownNodesActual: if not knownnodes.knownNodesActual:
helper_bootstrap.dns() helper_bootstrap.dns()
@ -253,7 +260,7 @@ class BMConnectionPool(object):
self.startListening() self.startListening()
else: else:
for bind in re.sub( for bind in re.sub(
"[^\w.]+", " ", '[^\w.]+', ' ', # pylint: disable=anomalous-backslash-in-string
BMConfigParser().safeGet('network', 'bind') BMConfigParser().safeGet('network', 'bind')
).split(): ).split():
self.startListening(bind) self.startListening(bind)
@ -263,7 +270,7 @@ class BMConnectionPool(object):
self.startUDPSocket() self.startUDPSocket()
else: else:
for bind in re.sub( for bind in re.sub(
"[^\w.]+", " ", '[^\w.]+', ' ', # pylint: disable=anomalous-backslash-in-string
BMConfigParser().safeGet('network', 'bind') BMConfigParser().safeGet('network', 'bind')
).split(): ).split():
self.startUDPSocket(bind) self.startUDPSocket(bind)