mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 23:11:33 +00:00
Add message_bytes() function to serialization module
This commit is contained in:
parent
646a671ff3
commit
16d98c75ca
@ -1,9 +1,9 @@
|
|||||||
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
||||||
# All Rights Reserved. See LICENSE file for details.
|
# All Rights Reserved. See LICENSE file for details.
|
||||||
|
|
||||||
from .serialization import serialize_tfw_msg, deserialize_tfw_msg, with_deserialize_tfw_msg
|
from .serialization import serialize_tfw_msg, deserialize_tfw_msg
|
||||||
|
from .serialization import with_deserialize_tfw_msg, message_bytes
|
||||||
from .zmq_connector_base import ZMQConnectorBase
|
from .zmq_connector_base import ZMQConnectorBase
|
||||||
# from .controller_connector import ControllerConnector # TODO: readd once controller stuff is resolved
|
|
||||||
from .message_sender import MessageSender
|
from .message_sender import MessageSender
|
||||||
from .event_handlers.server_connector import ServerUplinkConnector as TFWServerConnector
|
from .event_handlers.server_connector import ServerUplinkConnector as TFWServerConnector
|
||||||
from .server.tfw_server import TFWServer
|
from .server.tfw_server import TFWServer
|
||||||
|
@ -67,10 +67,14 @@ def _serialize_single(data):
|
|||||||
(serialize input if it is JSON)
|
(serialize input if it is JSON)
|
||||||
"""
|
"""
|
||||||
if not isinstance(data, str):
|
if not isinstance(data, str):
|
||||||
data = json.dumps(data)
|
data = message_bytes(data)
|
||||||
return _encode_if_needed(data)
|
return _encode_if_needed(data)
|
||||||
|
|
||||||
|
|
||||||
|
def message_bytes(message):
|
||||||
|
return json.dumps(message, sort_keys=True).encode()
|
||||||
|
|
||||||
|
|
||||||
def _deserialize_single(data):
|
def _deserialize_single(data):
|
||||||
"""
|
"""
|
||||||
Try parsing input as JSON, return it as
|
Try parsing input as JSON, return it as
|
||||||
|
Loading…
Reference in New Issue
Block a user