Show More
@@ -37,10 +37,10 b' class ExecutePreprocessor(Preprocessor):' | |||||
37 | self.kc.start_channels() |
|
37 | self.kc.start_channels() | |
38 | self.iopub = self.kc.iopub_channel |
|
38 | self.iopub = self.kc.iopub_channel | |
39 | self.shell = self.kc.shell_channel |
|
39 | self.shell = self.kc.shell_channel | |
40 |
|
40 | |||
41 | self.shell.execute("pass") |
|
41 | self.shell.execute("pass") | |
42 | self.shell.get_msg() |
|
42 | self.shell.get_msg() | |
43 |
|
43 | |||
44 | def preprocess_cell(self, cell, resources, cell_index): |
|
44 | def preprocess_cell(self, cell, resources, cell_index): | |
45 | """ |
|
45 | """ | |
46 | Apply a transformation on each code cell. See base.py for details. |
|
46 | Apply a transformation on each code cell. See base.py for details. | |
@@ -63,7 +63,7 b' class ExecutePreprocessor(Preprocessor):' | |||||
63 | # wait for finish, maximum 20s |
|
63 | # wait for finish, maximum 20s | |
64 | shell.get_msg(timeout=20) |
|
64 | shell.get_msg(timeout=20) | |
65 | outs = [] |
|
65 | outs = [] | |
66 |
|
66 | |||
67 | while True: |
|
67 | while True: | |
68 | try: |
|
68 | try: | |
69 | msg = iopub.get_msg(timeout=0.2) |
|
69 | msg = iopub.get_msg(timeout=0.2) | |
@@ -75,11 +75,11 b' class ExecutePreprocessor(Preprocessor):' | |||||
75 | elif msg_type == 'clear_output': |
|
75 | elif msg_type == 'clear_output': | |
76 | outs = [] |
|
76 | outs = [] | |
77 | continue |
|
77 | continue | |
78 |
|
78 | |||
79 | content = msg['content'] |
|
79 | content = msg['content'] | |
80 | # print msg_type, content |
|
80 | # print msg_type, content | |
81 | out = NotebookNode(output_type=msg_type) |
|
81 | out = NotebookNode(output_type=msg_type) | |
82 |
|
82 | |||
83 | if msg_type == 'stream': |
|
83 | if msg_type == 'stream': | |
84 | out.stream = content['name'] |
|
84 | out.stream = content['name'] | |
85 | out.text = content['data'] |
|
85 | out.text = content['data'] | |
@@ -98,10 +98,10 b' class ExecutePreprocessor(Preprocessor):' | |||||
98 | out.traceback = content['traceback'] |
|
98 | out.traceback = content['traceback'] | |
99 | else: |
|
99 | else: | |
100 | print >> sys.stderr, "unhandled iopub msg:", msg_type |
|
100 | print >> sys.stderr, "unhandled iopub msg:", msg_type | |
101 |
|
101 | |||
102 | outs.append(out) |
|
102 | outs.append(out) | |
103 | return outs |
|
103 | return outs | |
104 |
|
104 | |||
105 |
|
105 | |||
106 | def __del__(self): |
|
106 | def __del__(self): | |
107 | self.kc.stop_channels() |
|
107 | self.kc.stop_channels() |
General Comments 0
You need to be logged in to leave comments.
Login now