Skip to content

Commit f12471a

Browse files
committed
fix visualizer
1 parent 72e39a0 commit f12471a

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

Diff for: helpers/exec_helper.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var spawn = require('child_process').spawn,
2+
ws_helper = require('./websocket_helper'),
23
//pty = require('pty.js'),
34
path = require('path'),
45
ipython, spawn_list = [];
@@ -54,12 +55,12 @@ function execute_python_trace(file_path, socket) {
5455
});
5556

5657
prog.stderr.on('data', function(data) {
57-
socket.emit('trace-program-stderr', {output: data.toString()});
58+
ws_helper.send_message(socket, 'trace-program-stderr', {output: data.toString()});
5859
console.log(data.toString());
5960
});
6061

6162
prog.on('exit', function(code) {
62-
socket.emit('trace-program-exit', {output: program_output});
63+
ws_helper.send_message(socket, 'trace-program-exit', {output: program_output});
6364
});
6465
}
6566

@@ -68,16 +69,16 @@ function execute_python_trace(file_path, socket) {
6869
ipython.removeAllListeners('data');
6970
require('../server').get_socket(file.username, function(socket) {
7071
if (is_job) {
71-
socket.emit('scheduler-start', {file: file});
72+
ws_helper.send_message(socket, 'scheduler-start', {file: file});
7273
}
7374
ipython.on('data', function(data) {
7475
console.log(data);
7576
//data = data.replace(/\[0;.*?In\s\[.*?\[0m/, '~-prompt-~');
7677
//data = data.replace(/In\s\[.*?\]:/, '~-prompt-~');
7778
if (is_job) {
78-
socket.emit('scheduler-executing', {file: file});
79+
ws_helper.send_message(socket, 'scheduler-executing', {file: file});
7980
} else {
80-
socket.emit('program-stdout', {output: data});
81+
ws_helper.send_message(socket, 'program-stdout', {output: data});
8182
}
8283
});
8384
});
@@ -117,26 +118,26 @@ function execute_program(file, type, is_job) {
117118

118119
function handle_output(prog, file, is_job, socket) {
119120
if (is_job) {
120-
socket.emit('scheduler-start', {file: file});
121+
ws_helper.send_message(socket, 'scheduler-start', {file: file});
121122
}
122123

123124
prog.stdout.on('data', function(data) {
124125
if (is_job) {
125126
console.log(data.toString());
126-
socket.emit('scheduler-executing', {file: file});
127+
ws_helper.send_message(socket, 'scheduler-executing', {file: file});
127128
} else {
128129
console.log(data.toString());
129-
socket.emit('program-stdout', {output: data.toString()});
130+
ws_helper.send_message(socket, 'program-stdout', {output: data.toString()});
130131
}
131132
});
132133

133134
prog.stderr.on('data', function(data) {
134135
if (is_job) {
135136
console.log(data.toString());
136-
socket.emit('scheduler-error', {file: file, error: data});
137+
ws_helper.send_message(socket, 'scheduler-error', {file: file, error: data});
137138
} else {
138139
console.log(data.toString());
139-
socket.emit('program-stderr', {output: data.toString()});
140+
ws_helper.send_message(socket, 'program-stderr', {output: data.toString()});
140141
}
141142
});
142143

@@ -149,9 +150,9 @@ function handle_output(prog, file, is_job, socket) {
149150
}
150151

151152
if (is_job) {
152-
socket.emit('scheduler-exit', {code: code, file: file});
153+
ws_helper.send_message(socket, 'scheduler-exit', {code: code, file: file});
153154
} else {
154-
socket.emit('program-exit', {code: code});
155+
ws_helper.send_message(socket, 'program-exit', {code: code});
155156
}
156157

157158
});

0 commit comments

Comments
 (0)