|
1 | 1 | var spawn = require('child_process').spawn,
|
2 | 2 | exec = require('child_process').exec,
|
| 3 | + db = require('../../models/webideModel'), |
3 | 4 | net = require('net'),
|
4 | 5 | path = require('path'),
|
5 | 6 | ws_helper = require('../websocket_helper'),
|
@@ -29,39 +30,46 @@ exports.start_debug = function start_debug(file, socket) {
|
29 | 30 | console.log(!debug_program);
|
30 | 31 | if (!debug_program) {
|
31 | 32 | console.log('spawn debugger');
|
32 |
| - debug_program = spawn("sudo", ["python", "debugger.py"], {cwd: __dirname}); |
33 |
| - var buffer = ""; |
34 |
| - debug_program.stdout.on('data', function(data) { |
35 |
| - console.log(data.toString()); |
| 33 | + db.findOne({type: "editor:settings"}, function(err, settings) { |
| 34 | + var command = 'python'; |
| 35 | + if (typeof settings !== 'undefined' && settings.python_version === '3') { |
| 36 | + command = 'python3'; |
| 37 | + } |
36 | 38 |
|
37 |
| - buffer += data.toString(); |
| 39 | + debug_program = spawn("sudo", [command, "debugger.py"], {cwd: __dirname}); |
| 40 | + var buffer = ""; |
| 41 | + debug_program.stdout.on('data', function(data) { |
| 42 | + console.log(data.toString()); |
38 | 43 |
|
39 |
| - if (buffer.indexOf("DEBUGGER READY") !== -1 && !client_connected) { |
40 |
| - console.log("DEBUGGER READY"); |
41 |
| - connect_client(file, socket); |
42 |
| - console.log("after connect_client"); |
43 |
| - } |
| 44 | + buffer += data.toString(); |
44 | 45 |
|
45 |
| - }); |
| 46 | + if (buffer.indexOf("DEBUGGER READY") !== -1 && !client_connected) { |
| 47 | + console.log("DEBUGGER READY"); |
| 48 | + connect_client(file, socket); |
| 49 | + console.log("after connect_client"); |
| 50 | + } |
46 | 51 |
|
47 |
| - debug_program.stderr.on('data', function(data) { |
48 |
| - console.log(data.toString()); |
49 |
| - ws_helper.send_message(socket, 'debug-error', {file: file, error: data}); |
50 |
| - }); |
| 52 | + }); |
51 | 53 |
|
52 |
| - debug_program.on('error', function(data) { |
53 |
| - console.log("DEBUG PROGRAM ERROR:"); |
54 |
| - console.log(data); |
55 |
| - }); |
| 54 | + debug_program.stderr.on('data', function(data) { |
| 55 | + console.log(data.toString()); |
| 56 | + ws_helper.send_message(socket, 'debug-error', {file: file, error: data}); |
| 57 | + }); |
56 | 58 |
|
57 |
| - debug_program.on('exit', function(code) { |
58 |
| - console.log('Debug Program Exit'); |
59 |
| - console.log(code); |
60 |
| - debug_program = null; |
| 59 | + debug_program.on('error', function(data) { |
| 60 | + console.log("DEBUG PROGRAM ERROR:"); |
| 61 | + console.log(data); |
| 62 | + }); |
61 | 63 |
|
62 |
| - if (enable_debug) { |
63 |
| - self.start_debug(file, socket); |
64 |
| - } |
| 64 | + debug_program.on('exit', function(code) { |
| 65 | + console.log('Debug Program Exit'); |
| 66 | + console.log(code); |
| 67 | + debug_program = null; |
| 68 | + |
| 69 | + if (enable_debug) { |
| 70 | + self.start_debug(file, socket); |
| 71 | + } |
| 72 | + }); |
65 | 73 | });
|
66 | 74 | } else {
|
67 | 75 | //console.log('resetting debugger');
|
|
0 commit comments