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