[Bug] system.util.sendMessage fails with remoteServers when payload is not a dict

We have the code below in a script module that converts Ignition-specific objects to native Python lists and dicts. We pass the Ignition object to the propertyToPython function, and get back Python lists and/or dicts.

def _isDictLikeObject(value):
	return 'iteritems' in dir(value)


def _isListLikeObject(value):
	return 'append' in dir(value)
	    	
	
def dictLikeObjectToDict(dictLikeObject):
	pyDict = {}
	for key, item in dict(dictLikeObject).iteritems():
		item = propertyToPython(item)				
		pyDict[key] = item
	return pyDict


def listLikeObjectToList(listLikeObject):
	pyList = []
	for item in list(listLikeObject):
		item = propertyToPython(item)				
		pyList.append(item)
	return pyList


def propertyToPython(property):
	"""
	Accepts a value, object, or array property that might be
	encoded as an Ignition ObjectWrapper or ArrayWrapper and
	returns the property as Python dicts and lists.
	"""
	if _isDictLikeObject(property):
		property = dictLikeObjectToDict(property)
	elif _isListLikeObject(property):
		property = listLikeObjectToList(property)
	return property
3 Likes