Runnable with both Python3 and Python2, with PyQt4 #2249
|
@ -1055,7 +1055,7 @@ class objectProcessor(threading.Thread):
|
||||||
logger.info('ackdata checksum wrong. Not sending ackdata.')
|
logger.info('ackdata checksum wrong. Not sending ackdata.')
|
||||||
return False
|
return False
|
||||||
command = command.rstrip(b'\x00')
|
command = command.rstrip(b'\x00')
|
||||||
if command != 'object':
|
if command != b'object':
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
Message encoding end decoding functions
|
Message encoding end decoding functions
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import string
|
|
||||||
import zlib
|
import zlib
|
||||||
|
|
||||||
import messagetypes
|
import messagetypes
|
||||||
|
@ -100,14 +99,14 @@ class MsgDecode(object):
|
||||||
def decodeExtended(self, data):
|
def decodeExtended(self, data):
|
||||||
"""Handle extended encoding"""
|
"""Handle extended encoding"""
|
||||||
dc = zlib.decompressobj()
|
dc = zlib.decompressobj()
|
||||||
tmp = ""
|
tmp = b""
|
||||||
while len(tmp) <= config.safeGetInt("zlib", "maxsize"):
|
while len(tmp) <= config.safeGetInt("zlib", "maxsize"):
|
||||||
try:
|
try:
|
||||||
got = dc.decompress(
|
got = dc.decompress(
|
||||||
data, config.safeGetInt("zlib", "maxsize")
|
data, config.safeGetInt("zlib", "maxsize")
|
||||||
+ 1 - len(tmp))
|
+ 1 - len(tmp))
|
||||||
# EOF
|
# EOF
|
||||||
if got == "":
|
if got == b"":
|
||||||
break
|
break
|
||||||
tmp += got
|
tmp += got
|
||||||
data = dc.unconsumed_tail
|
data = dc.unconsumed_tail
|
||||||
|
@ -143,7 +142,7 @@ class MsgDecode(object):
|
||||||
|
|
||||||
def decodeSimple(self, data):
|
def decodeSimple(self, data):
|
||||||
"""Handle simple encoding"""
|
"""Handle simple encoding"""
|
||||||
bodyPositionIndex = string.find(data, '\nBody:')
|
bodyPositionIndex = data.find(b'\nBody:')
|
||||||
if bodyPositionIndex > 1:
|
if bodyPositionIndex > 1:
|
||||||
subject = data[8:bodyPositionIndex]
|
subject = data[8:bodyPositionIndex]
|
||||||
# Only save and show the first 500 characters of the subject.
|
# Only save and show the first 500 characters of the subject.
|
||||||
|
@ -151,10 +150,10 @@ class MsgDecode(object):
|
||||||
subject = subject[:500]
|
subject = subject[:500]
|
||||||
body = data[bodyPositionIndex + 6:]
|
body = data[bodyPositionIndex + 6:]
|
||||||
else:
|
else:
|
||||||
subject = ''
|
subject = b''
|
||||||
body = data
|
body = data
|
||||||
# Throw away any extra lines (headers) after the subject.
|
# Throw away any extra lines (headers) after the subject.
|
||||||
if subject:
|
if subject:
|
||||||
subject = subject.splitlines()[0]
|
subject = subject.splitlines()[0]
|
||||||
self.subject = subject
|
self.subject = subject.decode("utf-8", "replace")
|
||||||
self.body = body
|
self.body = body.decode("utf-8", "replace")
|
||||||
|
|
Reference in New Issue
Block a user