Mike, Also worth mentioning these are not the steps documented by the other person (which I know is operational). i have just put the steps together in my dev environment.
Cheers On Sat, May 6, 2017 at 9:57 AM, Andre <[email protected]> wrote: > Mike, > > Here it goes > > (Note the requests based script is very simple) > > Prep-work > 1. download jython installer (I tested with the standalone jar without > success) > 2. <path_to_jython_home>/bin/jython -m ensurepip > 3. <path_to_jython_home>/bin/pip install requests > > Verify requests was installed (you should be able to find it under to > <path_to_jython_home>/Lib/site-packages) > > Processor settings: > > Script Engine: python > Script File: simple.py > Script Body: "No value set" > Module Directory: <path_to_jython_home/>Lib/site-packages/ > > > The content of simple.py is: > > # start of script > import requests > import java.io > from org.apache.commons.io import IOUtils > from java.nio.charset import StandardCharsets > from org.apache.nifi.processor.io import StreamCallback > > class PyStreamCallback(StreamCallback): > def __init__(self): > pass > def process(self, inputStream, outputStream): > r = requests.get('http://www.varditlahav.com') > outputStream.write(bytearray(r.content)) > > flowFile = session.create() > if (flowFile != None): > flowFile = session.write(flowFile,PyStreamCallback()) > session.transfer(flowFile, REL_SUCCESS) > # End of script > > > Let us know how it goes > > > On Sat, May 6, 2017 at 8:09 AM, Andre <[email protected]> wrote: > >> Mike, >> >> I believe it is possible to use requests under jython, however the >> process isn't very intuitive. >> >> I know one folk that if I recall correctly has used it. Happy to try to >> find out how it is done. >> >> Cheers >> >> On Sat, May 6, 2017 at 4:57 AM, Mike Harding <[email protected]> >> wrote: >> >>> Hi All, >>> >>> I'm now looking at using ExecuteScript and python engine to execute HTTP >>> requests using the requests module. >>> >>> I've tried referencing requests the module but when I try to import >>> requests I get a module reference error. >>> >>> I downloaded the module from here > https://pypi.python.org/pypi/r >>> equests >>> >>> Not sure why it isnt picking it up. Ive tried referencing the directory >>> and the .py directly with no success. >>> >>> Any ideas where im going wrong? >>> >>> Cheers, >>> Mike >>> >> >> >
