rtCommon.serialization
Module Contents
Functions
|
Check if any args are of type 'bytes' and if so base64 encode them. |
|
Decodes rpc args that were previously encoded with encodeByteTypeArgs. |
|
Converts components in data that are numpy types to regular python types. |
|
b64 encode binary data in preparation for sending. Updates the message header |
|
Given a message encoded with encodeMessageData (above), decode that message. |
|
A python "generator" that, for data > 10 MB, will create multi-part |
|
Handles receiving multipart (an singlepart) data messages and returns the data bytes. |
Attributes
- rtCommon.serialization.multiPartDataCache
- rtCommon.serialization.dataPartSize
- rtCommon.serialization.encodeByteTypeArgs(cmd) dict
Check if any args are of type ‘bytes’ and if so base64 encode them. The original arg will be replaced with a tag that will reference the encoded bytes within the cmd dict. :param cmd: a dictionary of the command to check
- Returns
A cmd dictionary with the byte args encoded
- rtCommon.serialization.decodeByteTypeArgs(cmd) dict
Decodes rpc args that were previously encoded with encodeByteTypeArgs. :param cmd: a dictionary with encoded args
- Returns
a dictionary with decoded args
- Return type
cmd
- rtCommon.serialization.npToPy(data)
Converts components in data that are numpy types to regular python types. Uses recursive calls to convert nested data structures :returns: The data structure with numpy elements converted to python types
- rtCommon.serialization.encodeMessageData(message, data, compress)
b64 encode binary data in preparation for sending. Updates the message header as needed :param message: message header :type message: dict :param data: binary data :type data: bytes :param compress: whether to compress binary data :type compress: bool
- Returns
Modified message dict with appropriate fields filled in
- rtCommon.serialization.decodeMessageData(message)
Given a message encoded with encodeMessageData (above), decode that message. Validate and retrive orignal bytes. :param message: encoded message to decode :type message: dict
- Returns
The byte data of the original message from the sender
- rtCommon.serialization.generateDataParts(data, msg, compress)
A python “generator” that, for data > 10 MB, will create multi-part messages of 10MB each to send the data incrementally :param data: data to send :type data: bytes :param msg: message header for the request :type msg: dict :param compress: whether to compress the data befor sending :type compress: bool
- Returns
- Repeated calls return the next partial message to be sent until
None is returned
- rtCommon.serialization.unpackDataMessage(msg)
Handles receiving multipart (an singlepart) data messages and returns the data bytes. In the case of multipart messages a data cache is used to store intermediate parts until all parts are received and the final data can be reconstructed. :param msg: Potentially on part of a multipart message to unpack :type msg: dict
- Returns
None if not all multipart messages have been received yet, or Data bytes if all multipart messages have been received.