2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-01-11 10:32:31 +00:00

Fix collective serialization of screenshot messages

This commit is contained in:
Jarrod Johnson
2025-04-16 09:46:48 -04:00
parent e5da8c01a9
commit 9823ffc12d

View File

@@ -87,7 +87,13 @@ def _htmlify_structure(indict):
def msg_deserialize(packed):
m = msgpack.unpackb(packed, raw=False)
try:
m = msgpack.unpackb(packed, raw=False)
except UnicodeDecodeError: # binary data, likely imagedata
# strings will be made binary, so binary messages
# must tolerate either string or bytes
m = msgpack.unpackb(packed)
m[0] = m[0].decode()
cls = globals()[m[0]]
if issubclass(cls, ConfluentMessage) or issubclass(cls, ConfluentNodeError):
return cls(*m[1:])
@@ -1885,7 +1891,13 @@ class GraphicalConsole(ConfluentMessage):
class ScreenShot(ConfluentMessage):
readonly = True
def __init__(self, imgdata, node, imgformat=None):
if isinstance(node, bytes):
node = node.decode()
if isinstance(imgformat, bytes):
imgformat = imgformat.decode()
self.myargs = (imgdata, node, imgformat)
self.kvpairs = {node: {'image': {'imgformat': imgformat, 'imgdata': base64.b64encode(imgdata).decode()}}}