2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-12-25 12:41:39 +00:00

Fix media list through collective

The Media class was not
serializable by msgpack.  Fix this
and improve error messages in
future instances of this behavior.
This commit is contained in:
Jarrod Johnson 2020-02-11 09:04:49 -05:00
parent 7cd7068dd7
commit c6812274e4
3 changed files with 11 additions and 7 deletions

View File

@ -753,9 +753,9 @@ def _forward_rsp(connection, res):
r = msgpack.packb(
['Exception', 'Unable to serialize response ' + repr(res)],
use_bin_type=False)
except Exception:
except Exception as e:
r = msgpack.packb(
['Exception', 'Unable to serialize response ' + repr(res)],
['Exception', 'Unable to serialize response ' + repr(res) + ' due to ' + str(e)],
use_bin_type=False)
rlen = len(r)
if not rlen:

View File

@ -21,10 +21,12 @@ import msgpack
def deserialize_exc(msg):
excd = msgpack.unpackb(msg, raw=False)
if excd[0] == 'Exception':
return Exception(excd[1])
if excd[0] not in globals():
return False
return Exception('Cannot deserialize: {0}'.format(repr(excd)))
if not issubclass(excd[0], ConfluentException):
return False
return Exception('Cannot deserialize: {0}'.format(repr(excd)))
return globals(excd[0])(*excd[1])
class ConfluentException(Exception):

View File

@ -578,9 +578,11 @@ class DetachMedia(ConfluentMessage):
class Media(ConfluentMessage):
def __init__(self, node, media):
self.myargs = (node, media)
self.kvpairs = {node: {'name': media.name, 'url': media.url}}
def __init__(self, node, media=None, rawmedia=None):
if media:
rawmedia = {'name': media.name, 'url': media.url}
self.myargs = (node, None, rawmedia)
self.kvpairs = {node: rawmedia}
class SavedFile(ConfluentMessage):
def __init__(self, node, file):