Hello. I currently have a python script in which I set values in a
dictionary from flowfile attributes, referencing them directly by name. I
then create a json string, which I can send to an AMQP broker as a message.
Something like this:
result['absolute.path'] = flowFile.getAttribute('absolute.path')
result['filename'] = flowFile.getAttribute('filename')
result['myAttr'] = flowFile.getAttribute('myAttr')
# Serialize the object to JSON...
json_str = json.dumps(result)
# Replace flowfile payload with this string representation of my json...
outputStream.write(unicode(json_str).encode('utf-8'))I need to generalize this. I want to create attribute properties in my ExecuteScript processor from which I call this python, each property being a value I want to include in my json message. Assuming I create an attribute property in the processor called draftPick, and I set it to "Mahomes, KC". I read it into the script something like this: thisPick = *name of the property field* .evaluateAttributeExpressions().getValue() My first question: can I reference that incoming value in this expression directly by variable reference without quoting as above, and is there a way I can auto detect the property name to use as my key value in my dictionary? result[*name of the property field*] = flowFile.getAttribute(*thisPick*) My second question: is there a way to generalize this so that it dynamically identifies and handles any variable number of properties and values defined in my ExecuteScript processor? This would be the ideal solution, because then I can have one python script that dynamically handles any number of properties I set in the processor. I would do that to grab whichever subset of attributes I happened to want to send to my AMQP as a message at that time. Jim
