Runnable with both Python3 and Python2, with both PyQt5 and PyQt4 by using Qt.py #2250
12
src/upnp.py
12
src/upnp.py
|
@ -94,12 +94,12 @@ class Router: # pylint: disable=old-style-class
|
||||||
|
|
||||||
self.address = address
|
self.address = address
|
||||||
|
|
||||||
row = ssdpResponse.split('\r\n')
|
row = ssdpResponse.split(b'\r\n')
|
||||||
header = {}
|
header = {}
|
||||||
for i in range(1, len(row)):
|
for i in range(1, len(row)):
|
||||||
part = row[i].split(': ')
|
part = row[i].split(b': ')
|
||||||
if len(part) == 2:
|
if len(part) == 2:
|
||||||
header[part[0].lower()] = part[1]
|
header[part[0].decode("utf-8", "replace").lower()] = part[1].decode("utf-8", "replace")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.routerPath = urlparse(header['location'])
|
self.routerPath = urlparse(header['location'])
|
||||||
|
@ -222,10 +222,6 @@ class uPnPThread(StoppableThread):
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Start the thread to manage UPnP activity"""
|
"""Start the thread to manage UPnP activity"""
|
||||||
|
|
||||||
if six.PY3:
|
|
||||||
logger.warning("UPnP is disabled currently, due to incompleted migration to Python3.")
|
|
||||||
return
|
|
||||||
|
|
||||||
logger.debug("Starting UPnP thread")
|
logger.debug("Starting UPnP thread")
|
||||||
logger.debug("Local IP: %s", self.localIP)
|
logger.debug("Local IP: %s", self.localIP)
|
||||||
lastSent = 0
|
lastSent = 0
|
||||||
|
@ -323,7 +319,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.encode("utf8", "replace"), (uPnPThread.SSDP_ADDR, uPnPThread.SSDP_PORT))
|
||||||
except: # noqa:E722
|
except: # noqa:E722
|
||||||
logger.exception("UPnP send query failed")
|
logger.exception("UPnP send query failed")
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user