(self, data)
| 81 | self.subject = _translate("MsgDecode", "Unknown encoding") |
| 82 | |
| 83 | def decodeExtended(self, data): |
| 84 | dc = zlib.decompressobj() |
| 85 | tmp = "" |
| 86 | while len(tmp) <= BMConfigParser().safeGetInt("zlib", "maxsize"): |
| 87 | try: |
| 88 | got = dc.decompress(data, BMConfigParser().safeGetInt("zlib", "maxsize") + 1 - len(tmp)) |
| 89 | # EOF |
| 90 | if got == "": |
| 91 | break |
| 92 | tmp += got |
| 93 | data = dc.unconsumed_tail |
| 94 | except zlib.error: |
| 95 | logger.error("Error decompressing message") |
| 96 | raise MsgDecodeException("Error decompressing message") |
| 97 | else: |
| 98 | raise DecompressionSizeException(len(tmp)) |
| 99 | |
| 100 | try: |
| 101 | tmp = msgpack.loads(tmp) |
| 102 | except (msgpack.exceptions.UnpackException, |
| 103 | msgpack.exceptions.ExtraData): |
| 104 | logger.error("Error msgunpacking message") |
| 105 | raise MsgDecodeException("Error msgunpacking message") |
| 106 | |
| 107 | try: |
| 108 | msgType = tmp[""] |
| 109 | except KeyError: |
| 110 | logger.error("Message type missing") |
| 111 | raise MsgDecodeException("Message type missing") |
| 112 | |
| 113 | msgObj = messagetypes.constructObject(tmp) |
| 114 | if msgObj is None: |
| 115 | raise MsgDecodeException("Malformed message") |
| 116 | try: |
| 117 | msgObj.process() |
| 118 | except: |
| 119 | raise MsgDecodeException("Malformed message") |
| 120 | if msgType == "message": |
| 121 | self.subject = msgObj.subject |
| 122 | self.body = msgObj.body |
| 123 | |
| 124 | def decodeSimple(self, data): |
| 125 | bodyPositionIndex = string.find(data, '\nBody:') |
no test coverage detected