Question about executing python files with node.js "child_process"
Hello!
I am trying to execute a python file in my PP extention, i read that 'node.js' and 'child_process' is the way to go if you want to run CLI commands in javascript, so i went to my XML file and enabled it ( it works as it should with other methods like "fs"). Also i have a folder inside my extention with all the necessery modules that i want to use. I tried to execute the same piece of code as a seperate .js file and it works fine. In my extention panel a button is attached to call the function but nothing happens, it completely ignores it.
These are the functions i am trying to use:
<script src="./lib/CSInterface.js"></script>
<script src="./lib/jquery-1.9.1.js"></script>
<script type="text/javascript">
function execute (command) {
const exec = require('child_process').exec
exec(command, (err, stdout, stderr) => {
process.stdout.write(stdout)
})
}
function runPython() {
execute('python pythonFile.py')
}
</script>
The runPython function is attached to a run-button in the index.html file that should execute the scirpt. I tried to use the "child_process" method with many differend compinations but i can't figure out what might be the probelm here. Any ideas on the subject? Has anyone expirienced something similar?
Thanks in advantage.
