So I am trying to write a simple wrapper in python to call rasa, a nlu tool from. The command I would write on the the command line is this:
curl -X POST "localhost:5000/parse" -d '{"q":"I am looking for fucking Mexican food"}' | python -m json.tool
The output I expect is something like this:
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 545 0 500 100 45 33615 3025 --:--:-- --:--:-- --:--:-- 35714
plus the outprint of a json file.
I wrote this program in python:
import subprocess
utterance = "Lets say something"
result = subprocess.run(["curl", "-X", "POST", "localhost:5000/parse", "-d", "'{\"q\":\""+utterance+"\"}'", "|", "python", "-m", "json.tool"], stdout=subprocess.PIPE)
print(vars(result))
print(result.stdout.decode('utf-8'))
Unfortunately my output is like this, meaning I dont actually get the return from the curl call:
{'args': ['curl', '-X', 'POST', 'localhost:5000/parse', '-d', '\'{"q":"Lets say something"}\'', '|', 'python', '-m', 'json.tool'], 'returncode': 2, 'stdout': b'', 'stderr': None}
If I call my python programm from the commandline, this is the output:
curl: option -m: expected a proper numerical parameter curl: try 'curl --help' or 'curl --manual' for more information {'args': ['curl', '-X', 'POST', 'localhost:5000/parse', '-d', '\'{"q":"Lets say something"}\'', '|', 'python', '-m', 'json.tool'], 'returncode': 2, 'stdout': b'', 'stderr': None}
I tried looking everywhere but just cant get it going. Would really appreciate some help.