Updated code quality added bare except warning ignore comment
This commit is contained in:
parent
98ce5d793c
commit
9b00ef02b3
16
src/upnp.py
16
src/upnp.py
|
@ -191,7 +191,7 @@ class Router: # pylint: disable=old-style-class
|
||||||
if errinfo:
|
if errinfo:
|
||||||
logger.error("UPnP error: %s", respData)
|
logger.error("UPnP error: %s", respData)
|
||||||
raise UPnPError(errinfo[0].childNodes[0].data)
|
raise UPnPError(errinfo[0].childNodes[0].data)
|
||||||
except:
|
except: # noqa:E722
|
||||||
raise UPnPError("Unable to parse SOAP error: %s" % (respData))
|
raise UPnPError("Unable to parse SOAP error: %s" % (respData))
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ class uPnPThread(StoppableThread):
|
||||||
super(uPnPThread, self).__init__(name="uPnPThread")
|
super(uPnPThread, self).__init__(name="uPnPThread")
|
||||||
try:
|
try:
|
||||||
self.extPort = BMConfigParser().getint('bitmessagesettings', 'extport')
|
self.extPort = BMConfigParser().getint('bitmessagesettings', 'extport')
|
||||||
except:
|
except: # noqa:E722
|
||||||
self.extPort = None
|
self.extPort = None
|
||||||
self.localIP = self.getLocalIP()
|
self.localIP = self.getLocalIP()
|
||||||
self.routers = []
|
self.routers = []
|
||||||
|
@ -242,7 +242,7 @@ class uPnPThread(StoppableThread):
|
||||||
if time.time() - lastSent > self.sendSleep and not self.routers:
|
if time.time() - lastSent > self.sendSleep and not self.routers:
|
||||||
try:
|
try:
|
||||||
self.sendSearchRouter()
|
self.sendSearchRouter()
|
||||||
except:
|
except: # noqa:E722
|
||||||
pass
|
pass
|
||||||
lastSent = time.time()
|
lastSent = time.time()
|
||||||
try:
|
try:
|
||||||
|
@ -263,7 +263,7 @@ class uPnPThread(StoppableThread):
|
||||||
newRouter.GetExternalIPAddress(),
|
newRouter.GetExternalIPAddress(),
|
||||||
self.extPort
|
self.extPort
|
||||||
)
|
)
|
||||||
except:
|
except: # noqa:E722
|
||||||
logger.debug('Failed to get external IP')
|
logger.debug('Failed to get external IP')
|
||||||
else:
|
else:
|
||||||
with knownnodes.knownNodesLock:
|
with knownnodes.knownNodesLock:
|
||||||
|
@ -275,18 +275,18 @@ class uPnPThread(StoppableThread):
|
||||||
break
|
break
|
||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
pass
|
pass
|
||||||
except:
|
except: # noqa:E722
|
||||||
logger.error("Failure running UPnP router search.", exc_info=True)
|
logger.error("Failure running UPnP router search.", exc_info=True)
|
||||||
for router in self.routers:
|
for router in self.routers:
|
||||||
if router.extPort is None:
|
if router.extPort is None:
|
||||||
self.createPortMapping(router)
|
self.createPortMapping(router)
|
||||||
try:
|
try:
|
||||||
self.sock.shutdown(socket.SHUT_RDWR)
|
self.sock.shutdown(socket.SHUT_RDWR)
|
||||||
except:
|
except: # noqa:E722
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.sock.close()
|
self.sock.close()
|
||||||
except:
|
except: # noqa:E722
|
||||||
pass
|
pass
|
||||||
deleted = False
|
deleted = False
|
||||||
for router in self.routers:
|
for router in self.routers:
|
||||||
|
@ -317,7 +317,7 @@ class uPnPThread(StoppableThread):
|
||||||
try:
|
try:
|
||||||
logger.debug("Sending UPnP query")
|
logger.debug("Sending UPnP query")
|
||||||
self.sock.sendto(ssdpRequest, (uPnPThread.SSDP_ADDR, uPnPThread.SSDP_PORT))
|
self.sock.sendto(ssdpRequest, (uPnPThread.SSDP_ADDR, uPnPThread.SSDP_PORT))
|
||||||
except:
|
except: # noqa:E722
|
||||||
logger.exception("UPnP send query failed")
|
logger.exception("UPnP send query failed")
|
||||||
|
|
||||||
def createPortMapping(self, router):
|
def createPortMapping(self, router):
|
||||||
|
|
Reference in New Issue
Block a user