Closed Alkarex closed 5 months ago
Thank you @Alkarex ! I read your code. I think it is a good idea to use python exec to read the msg.payload value.
I installed the repository you Forked into Node-RED and got some errors. The first error was a missing python file error, which was caused by the missing tmp folder. This was my mistake, I have fixed this with a .gitignore.
The second error was a syntax error when executing the command. Have you encountered this error?
I will try to solve this error and write the Python code that was written in the command in the new file.
Ah, this is probably due to running on Windows. Let me try something
Please try again
Thank you @Alkarex ! I had the same error after that, but it was solved.
I tried it with a short command. It seems that the error occurs depending on the type of quotation:
I fixed it for line 19 in the node/venv.js file.:
const command = `${pythonPath} -c 'import base64;import json;msg=json.loads(base64.b64decode(r"${message}"));exec(open(r"${filePath}").read())'`
↓
const command = `${pythonPath} -c "import base64;import json;msg=json.loads(base64.b64decode(r'${message}'));exec(open(r'${filePath}').read())"`
I can run it in my environment. Could you try it?
Could you show the error message you get in Node-RED when running with the original quotes?
@Alkarex It was the same as the second error message when running with the original quotes.
After fixing the quotations, I was able to run it!
Your suggestion also works for me, so fine
Thank you @Alkarex ! I will merge this pull request, and release as a new version.
Allow something like
print(msg['payload'])
fix https://github.com/404background/node-red-contrib-python-venv/issues/4