I'm trying to write a node.js application that features a Python debugger GUI. Currently, I'm have a node.js application that calls a Python file with a pdb.set_trace(). I'm able to use node.js to spawn a child process, but I'm not really sure how to make node.js send a child message.
Currently, I have spawned a child program here in a post section in node.js: `
pyProg = spawn('python', ['test-submission-'+req.body.userID+'.py', testCase, "debug"], {stdio: ["pipe","pipe","pipe"]});
pyProg.stdout.on('data', function(data) {
res.write("\n\nOUTPUT:\n")
res.write(data);
res.end('\nDEBUG');
});
` This correctly spawns the child and node.js tells the frontend that pdb has started.
Now, to communicate with pdb, I have written the following post section: `
router.post('/sendDebugMSG', function(req, res) {
console.log("Sending debug message: " + req.body.message);
pyProg.stdin.write(req.body.message);
pyProg.stdout.on('data', function(data) {
res.write("\n\nOUTPUT:\n");
res.write(data);
res.end('\nDEBUG');
});
pyProg.stderr.on('data', function(data) {
dataStr = data.toString();
res.write("\n\nOUTPUT:\n")
res.write(data);
res.end('\nFAILED TO EXECUTE');
// res.send("FAILED:" + dataStr);
// res.end('end');
});
});
When the frontend sends in the message "next", the only thing that outputs is
Sending debug message: next
Does anyone know how to make node.js communicate with pdb?
It turns out I needed a \n appended to the next command.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.