Created on 12-26-2016 02:30 PM - edited 08-18-2019 03:37 AM
Hi all,
I've read this tuto : Logging
So anybody has simple example of python script to write data from ExtracText processor to ExecuteScript processor ?
How extract flowfile name as argument to my script python ?
Created 12-26-2016 06:43 PM
@mayki wogno user defined arguments aren't really sent to ExecuteScript. If the value of the `filename` attribute is needed, it can be retrieved from the flow file itself. Below is an example of how to retrieve the `filename` attribute, update the attribute, and send the flow file to a `success` relationship.
flowFile = session.get() if (flowFile != None): filename = flowFile.getAttribute("filename") flowFile = session.putAttribute(flowFile, "filename", filename + "new_name") session.transfer(flowFile, REL_SUCCESS)
For an example that is a little more in depth, you can download a template from this gist.
For a deeper look into developing with NiFi, please see the developer's guide.
Created 12-26-2016 06:29 PM
It should already be available in your script, if you use this:
flowFile = session.get() flowFile.getAttribute('filename')
This should return your filename in your executeScript.
Created 12-26-2016 06:43 PM
@mayki wogno user defined arguments aren't really sent to ExecuteScript. If the value of the `filename` attribute is needed, it can be retrieved from the flow file itself. Below is an example of how to retrieve the `filename` attribute, update the attribute, and send the flow file to a `success` relationship.
flowFile = session.get() if (flowFile != None): filename = flowFile.getAttribute("filename") flowFile = session.putAttribute(flowFile, "filename", filename + "new_name") session.transfer(flowFile, REL_SUCCESS)
For an example that is a little more in depth, you can download a template from this gist.
For a deeper look into developing with NiFi, please see the developer's guide.