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:
parent
7cd7068dd7
commit
c6812274e4
@ -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:
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user