Message Utilities

class dxlbootstrap.util.MessageUtils

Messaging related utility methods

static decode(value, enc='utf-8')

Decodes the specified value and returns it.

Parameters:
  • value -- The value
  • enc -- The encoding
Returns:

The decoded value

static decode_payload(message, enc='utf-8')

Decodes the specified message's payload and returns it.

Parameters:
  • message -- The DXL message
  • enc -- The encoding of the payload
Returns:

The decoded value

static dict_to_json(dict, pretty_print=False)

Converts the specified Python dictionary (dict) to a JSON string and returns it.

Parameters:
  • dict -- The Python dictionary (dict)
  • pretty_print -- Whether to pretty print the JSON
Returns:

The JSON string

static dict_to_json_payload(message, dict, enc='utf-8')

Converts the specified Python dictionary (dict) to a JSON string and places it in the DXL message's payload.

Parameters:
  • message -- The DXL message
  • dict -- The Python dictionary (dict)
  • enc -- The encoding to use for the payload
static encode(value, enc='utf-8')

Encodes the specified value and returns it

Parameters:
  • value -- The value
  • enc -- The encoding to use
Returns:

The encoded value

static encode_payload(message, value, enc='utf-8')

Encodes the specified value and places it in the DXL message's payload

Parameters:
  • message -- The DXL message
  • value -- The value
  • enc -- The encoding to use
static json_payload_to_dict(message, enc='utf-8')

Converts the specified message's payload from JSON to a Python dictionary (dict) and returns it.

Parameters:
  • message -- The DXL message
  • enc -- The encoding of the payload
Returns:

The Python dictionary (dict)

static json_to_dict(json_string)

Converts the specified JSON string to a Python dictionary (dict) and returns it.

Parameters:json_string -- The JSON string
Returns:The Python dictionary (dict)