I need to use a python3 script executed by js sever, i dont know how to set the variables like --name on spawn, thats my problem.
this is my code on js:
var { spawn } = require('child_process');
console.log("--------------------SART---------------------");
var path = "/home/usr/Documentos/Proyectos/Repos/test_recurrent.py";
pythonProcess = spawn('python3',[path]);
console.log("--------------------SPAWN---------------------");
pythonProcess.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
pythonProcess.stderr.on('data', (data) => {
console.error(`stderr: ${data}`);
});
pythonProcess.on('close', (code) => {
console.log(`child process exited with code ${code}`);
});
I need execute this line :
python3 test_recurrent.py --name "Default_name" --dataroot "/home/usr/UIInputs" --which_epoch 72000 --ancho_ventana 512 --alto_ventana 1200 --numero_imagenes 4 --numero_generaciones 7 --output_path "/home/usr/UIResults" --xcoor 1526 1526 1526 1526 --ycoor 3995 3995 3995 3995
i have no idea about how to set this variables.
you can pass switches as list after your path
var { spawn } = require('child_process');
console.log("--------------------SART---------------------");
var scriptPath = "/home/usr/Documentos/Proyectos/Repos/test_recurrent.py";
pythonProcess = spawn('python3', [scriptPath, "--name", "Default_name", "--dataroot", "/home/usr/UIInputs", "--which_epoch", "72000", "--ancho_ventana", "512", "--alto_ventana", "1200", "--numero_imagenes", "4", "--numero_generaciones", "7", "--output_path", "/home/usr/UIResults", "--xcoor", "1526 1526 1526 1526", "--ycoor", "3995 3995 3995 3995"]);
console.log("--------------------SPAWN---------------------");
pythonProcess.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
pythonProcess.stderr.on('data', (data) => {
console.error(`stderr: ${data}`);
});
pythonProcess.on('close', (code) => {
console.log(`child process exited with code ${code}`);
});