开发者

How to send messages to pdb on node.js?

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.bod开发者_JS百科y.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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜