Show More
@@ -1,9 +1,5 b'' | |||||
1 | //---------------------------------------------------------------------------- |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Copyright (C) 2008 The IPython Development Team |
|
2 | // Distributed under the terms of the Modified BSD License. | |
3 | // |
|
|||
4 | // Distributed under the terms of the BSD License. The full license is in |
|
|||
5 | // the file COPYING, distributed as part of this software. |
|
|||
6 | //---------------------------------------------------------------------------- |
|
|||
7 |
|
3 | |||
8 | //============================================================================ |
|
4 | //============================================================================ | |
9 | // OutputArea |
|
5 | // OutputArea | |
@@ -221,9 +217,12 b' var IPython = (function (IPython) {' | |||||
221 | json = content.data; |
|
217 | json = content.data; | |
222 | json.output_type = msg_type; |
|
218 | json.output_type = msg_type; | |
223 | json.metadata = content.metadata; |
|
219 | json.metadata = content.metadata; | |
224 |
} else if (msg_type === " |
|
220 | } else if (msg_type === "execute_result") { | |
225 | json = content.data; |
|
221 | json = content.data; | |
226 | json.output_type = msg_type; |
|
222 | // pyout message has been renamed to execute_result, | |
|
223 | // but the nbformat has not been updated, | |||
|
224 | // so transform back to pyout for json. | |||
|
225 | json.output_type = "pyout"; | |||
227 | json.metadata = content.metadata; |
|
226 | json.metadata = content.metadata; | |
228 | json.prompt_number = content.execution_count; |
|
227 | json.prompt_number = content.execution_count; | |
229 | } else if (msg_type === "pyerr") { |
|
228 | } else if (msg_type === "pyerr") { | |
@@ -284,7 +283,7 b' var IPython = (function (IPython) {' | |||||
284 | } |
|
283 | } | |
285 |
|
284 | |||
286 | if (json.output_type === 'pyout') { |
|
285 | if (json.output_type === 'pyout') { | |
287 |
this.append_ |
|
286 | this.append_execute_result(json); | |
288 | } else if (json.output_type === 'pyerr') { |
|
287 | } else if (json.output_type === 'pyerr') { | |
289 | this.append_pyerr(json); |
|
288 | this.append_pyerr(json); | |
290 | } else if (json.output_type === 'stream') { |
|
289 | } else if (json.output_type === 'stream') { | |
@@ -406,7 +405,7 b' var IPython = (function (IPython) {' | |||||
406 | }; |
|
405 | }; | |
407 |
|
406 | |||
408 |
|
407 | |||
409 |
OutputArea.prototype.append_ |
|
408 | OutputArea.prototype.append_execute_result = function (json) { | |
410 | var n = json.prompt_number || ' '; |
|
409 | var n = json.prompt_number || ' '; | |
411 | var toinsert = this.create_output_area(); |
|
410 | var toinsert = this.create_output_area(); | |
412 | if (this.prompt_area) { |
|
411 | if (this.prompt_area) { |
@@ -76,7 +76,7 b' var IPython = (function (IPython) {' | |||||
76 | // Initialize the iopub handlers |
|
76 | // Initialize the iopub handlers | |
77 |
|
77 | |||
78 | Kernel.prototype.init_iopub_handlers = function () { |
|
78 | Kernel.prototype.init_iopub_handlers = function () { | |
79 |
var output_types = ['stream', 'display_data', ' |
|
79 | var output_types = ['stream', 'display_data', 'execute_result', 'pyerr']; | |
80 | this._iopub_handlers = {}; |
|
80 | this._iopub_handlers = {}; | |
81 | this.register_iopub_handler('status', $.proxy(this._handle_status_message, this)); |
|
81 | this.register_iopub_handler('status', $.proxy(this._handle_status_message, this)); | |
82 | this.register_iopub_handler('clear_output', $.proxy(this._handle_clear_output, this)); |
|
82 | this.register_iopub_handler('clear_output', $.proxy(this._handle_clear_output, this)); | |
@@ -573,7 +573,7 b' var IPython = (function (IPython) {' | |||||
573 | }; |
|
573 | }; | |
574 |
|
574 | |||
575 |
|
575 | |||
576 |
// handle an output message ( |
|
576 | // handle an output message (execute_result, display_data, etc.) | |
577 | Kernel.prototype._handle_output_message = function (msg) { |
|
577 | Kernel.prototype._handle_output_message = function (msg) { | |
578 | var callbacks = this.get_callbacks_for_msg(msg.parent_header.msg_id); |
|
578 | var callbacks = this.get_callbacks_for_msg(msg.parent_header.msg_id); | |
579 | if (!callbacks || !callbacks.iopub) { |
|
579 | if (!callbacks || !callbacks.iopub) { |
@@ -33,7 +33,7 b' function assert_has(short_name, json, result, result2) {' | |||||
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | // helper function for checkout that the first two cells have a particular |
|
35 | // helper function for checkout that the first two cells have a particular | |
36 |
// output_type (either ' |
|
36 | // output_type (either 'execute_result' or 'display_data'), and checks the to/fromJSON | |
37 | // for a set of mimetype keys, using their short names ('javascript', 'text', |
|
37 | // for a set of mimetype keys, using their short names ('javascript', 'text', | |
38 | // 'png', etc). |
|
38 | // 'png', etc). | |
39 | function check_output_area(output_type, keys) { |
|
39 | function check_output_area(output_type, keys) { | |
@@ -109,7 +109,7 b' casper.notebook_test(function () {' | |||||
109 | }); |
|
109 | }); | |
110 |
|
110 | |||
111 | this.then(function () { |
|
111 | this.then(function () { | |
112 |
check_output_area.apply(this, [' |
|
112 | check_output_area.apply(this, ['execute_result', ['text', 'json']]); | |
113 | }); |
|
113 | }); | |
114 |
|
114 | |||
115 | this.then(function() { |
|
115 | this.then(function() { | |
@@ -127,7 +127,7 b' casper.notebook_test(function () {' | |||||
127 | }); |
|
127 | }); | |
128 |
|
128 | |||
129 | this.then(function ( ) { |
|
129 | this.then(function ( ) { | |
130 |
check_output_area.apply(this, [' |
|
130 | check_output_area.apply(this, ['execute_result', ['text', 'latex']]); | |
131 | }); |
|
131 | }); | |
132 |
|
132 | |||
133 | this.then(function() { |
|
133 | this.then(function() { | |
@@ -145,7 +145,7 b' casper.notebook_test(function () {' | |||||
145 | }); |
|
145 | }); | |
146 |
|
146 | |||
147 | this.then(function ( ) { |
|
147 | this.then(function ( ) { | |
148 |
check_output_area.apply(this, [' |
|
148 | check_output_area.apply(this, ['execute_result', ['text', 'html']]); | |
149 | }); |
|
149 | }); | |
150 |
|
150 | |||
151 | this.then(function() { |
|
151 | this.then(function() { | |
@@ -165,7 +165,7 b' casper.notebook_test(function () {' | |||||
165 | this.thenEvaluate(function() { IPython.notebook.save_notebook(); }); |
|
165 | this.thenEvaluate(function() { IPython.notebook.save_notebook(); }); | |
166 |
|
166 | |||
167 | this.then(function ( ) { |
|
167 | this.then(function ( ) { | |
168 |
check_output_area.apply(this, [' |
|
168 | check_output_area.apply(this, ['execute_result', ['text', 'png']]); | |
169 | }); |
|
169 | }); | |
170 |
|
170 | |||
171 | this.then(function() { |
|
171 | this.then(function() { | |
@@ -184,7 +184,7 b' casper.notebook_test(function () {' | |||||
184 | }); |
|
184 | }); | |
185 |
|
185 | |||
186 | this.then(function ( ) { |
|
186 | this.then(function ( ) { | |
187 |
check_output_area.apply(this, [' |
|
187 | check_output_area.apply(this, ['execute_result', ['text', 'jpeg']]); | |
188 | }); |
|
188 | }); | |
189 |
|
189 | |||
190 | this.then(function() { |
|
190 | this.then(function() { | |
@@ -202,7 +202,7 b' casper.notebook_test(function () {' | |||||
202 | }); |
|
202 | }); | |
203 |
|
203 | |||
204 | this.then(function ( ) { |
|
204 | this.then(function ( ) { | |
205 |
check_output_area.apply(this, [' |
|
205 | check_output_area.apply(this, ['execute_result', ['text', 'svg']]); | |
206 | }); |
|
206 | }); | |
207 |
|
207 | |||
208 | this.then(function() { |
|
208 | this.then(function() { | |
@@ -238,7 +238,7 b' casper.notebook_test(function () {' | |||||
238 | 'display_data custom mimetype ' + long_name); |
|
238 | 'display_data custom mimetype ' + long_name); | |
239 | var result = this.get_output_cell(0, 1); |
|
239 | var result = this.get_output_cell(0, 1); | |
240 | this.test.assertTrue(result.hasOwnProperty(long_name), |
|
240 | this.test.assertTrue(result.hasOwnProperty(long_name), | |
241 |
' |
|
241 | 'execute_result custom mimetype ' + long_name); | |
242 |
|
242 | |||
243 | }); |
|
243 | }); | |
244 |
|
244 |
@@ -185,7 +185,7 b' class DisplayData(Reference):' | |||||
185 | nt.assert_is_instance(v, string_types) |
|
185 | nt.assert_is_instance(v, string_types) | |
186 |
|
186 | |||
187 |
|
187 | |||
188 |
class |
|
188 | class ExecuteResult(Reference): | |
189 | execution_count = Integer() |
|
189 | execution_count = Integer() | |
190 | data = Dict() |
|
190 | data = Dict() | |
191 | def _data_changed(self, name, old, new): |
|
191 | def _data_changed(self, name, old, new): | |
@@ -201,7 +201,7 b' references = {' | |||||
201 | 'complete_reply' : CompleteReply(), |
|
201 | 'complete_reply' : CompleteReply(), | |
202 | 'kernel_info_reply': KernelInfoReply(), |
|
202 | 'kernel_info_reply': KernelInfoReply(), | |
203 | 'execute_input' : ExecuteInput(), |
|
203 | 'execute_input' : ExecuteInput(), | |
204 | 'pyout' : PyOut(), |
|
204 | 'execute_result' : ExecuteResult(), | |
205 | 'pyerr' : PyErr(), |
|
205 | 'pyerr' : PyErr(), | |
206 | 'stream' : Stream(), |
|
206 | 'stream' : Stream(), | |
207 | 'display_data' : DisplayData(), |
|
207 | 'display_data' : DisplayData(), |
@@ -1,5 +1,8 b'' | |||||
1 | """Replacements for sys.displayhook that publish over ZMQ. |
|
1 | """Replacements for sys.displayhook that publish over ZMQ.""" | |
2 | """ |
|
2 | ||
|
3 | # Copyright (c) IPython Development Team. | |||
|
4 | # Distributed under the terms of the Modified BSD License. | |||
|
5 | ||||
3 | import sys |
|
6 | import sys | |
4 |
|
7 | |||
5 | from IPython.core.displayhook import DisplayHook |
|
8 | from IPython.core.displayhook import DisplayHook | |
@@ -12,7 +15,7 b' from .session import extract_header, Session' | |||||
12 | class ZMQDisplayHook(object): |
|
15 | class ZMQDisplayHook(object): | |
13 | """A simple displayhook that publishes the object's repr over a ZeroMQ |
|
16 | """A simple displayhook that publishes the object's repr over a ZeroMQ | |
14 | socket.""" |
|
17 | socket.""" | |
15 |
topic=b' |
|
18 | topic=b'execute_result' | |
16 |
|
19 | |||
17 | def __init__(self, session, pub_socket): |
|
20 | def __init__(self, session, pub_socket): | |
18 | self.session = session |
|
21 | self.session = session | |
@@ -26,7 +29,7 b' class ZMQDisplayHook(object):' | |||||
26 | builtin_mod._ = obj |
|
29 | builtin_mod._ = obj | |
27 | sys.stdout.flush() |
|
30 | sys.stdout.flush() | |
28 | sys.stderr.flush() |
|
31 | sys.stderr.flush() | |
29 |
msg = self.session.send(self.pub_socket, u' |
|
32 | msg = self.session.send(self.pub_socket, u'execute_result', {u'data':repr(obj)}, | |
30 | parent=self.parent_header, ident=self.topic) |
|
33 | parent=self.parent_header, ident=self.topic) | |
31 |
|
34 | |||
32 | def set_parent(self, parent): |
|
35 | def set_parent(self, parent): | |
@@ -48,7 +51,7 b' class ZMQShellDisplayHook(DisplayHook):' | |||||
48 | self.parent_header = extract_header(parent) |
|
51 | self.parent_header = extract_header(parent) | |
49 |
|
52 | |||
50 | def start_displayhook(self): |
|
53 | def start_displayhook(self): | |
51 |
self.msg = self.session.msg(u' |
|
54 | self.msg = self.session.msg(u'execute_result', {}, parent=self.parent_header) | |
52 |
|
55 | |||
53 | def write_output_prompt(self): |
|
56 | def write_output_prompt(self): | |
54 | """Write the output prompt.""" |
|
57 | """Write the output prompt.""" |
@@ -143,7 +143,7 b' class Kernel(Configurable):' | |||||
143 | ) |
|
143 | ) | |
144 | self.shell.displayhook.session = self.session |
|
144 | self.shell.displayhook.session = self.session | |
145 | self.shell.displayhook.pub_socket = self.iopub_socket |
|
145 | self.shell.displayhook.pub_socket = self.iopub_socket | |
146 |
self.shell.displayhook.topic = self._topic(' |
|
146 | self.shell.displayhook.topic = self._topic('execute_result') | |
147 | self.shell.display_pub.session = self.session |
|
147 | self.shell.display_pub.session = self.session | |
148 | self.shell.display_pub.pub_socket = self.iopub_socket |
|
148 | self.shell.display_pub.pub_socket = self.iopub_socket | |
149 | self.shell.data_pub.session = self.session |
|
149 | self.shell.data_pub.session = self.session |
@@ -10,20 +10,18 b" implementation that doesn't rely on so much monkeypatching." | |||||
10 | But this lets us maintain a fully working IPython as we develop the new |
|
10 | But this lets us maintain a fully working IPython as we develop the new | |
11 | machinery. This should thus be thought of as scaffolding. |
|
11 | machinery. This should thus be thought of as scaffolding. | |
12 | """ |
|
12 | """ | |
13 | #----------------------------------------------------------------------------- |
|
13 | ||
14 | # Imports |
|
14 | # Copyright (c) IPython Development Team. | |
15 | #----------------------------------------------------------------------------- |
|
15 | # Distributed under the terms of the Modified BSD License. | |
|
16 | ||||
16 | from __future__ import print_function |
|
17 | from __future__ import print_function | |
17 |
|
18 | |||
18 | # Stdlib |
|
|||
19 | import os |
|
19 | import os | |
20 | import sys |
|
20 | import sys | |
21 | import time |
|
21 | import time | |
22 |
|
22 | |||
23 | # System library imports |
|
|||
24 | from zmq.eventloop import ioloop |
|
23 | from zmq.eventloop import ioloop | |
25 |
|
24 | |||
26 | # Our own |
|
|||
27 | from IPython.core.interactiveshell import ( |
|
25 | from IPython.core.interactiveshell import ( | |
28 | InteractiveShell, InteractiveShellABC |
|
26 | InteractiveShell, InteractiveShellABC | |
29 | ) |
|
27 | ) | |
@@ -512,7 +510,7 b' class ZMQInteractiveShell(InteractiveShell):' | |||||
512 | # to pick up |
|
510 | # to pick up | |
513 | topic = None |
|
511 | topic = None | |
514 | if dh.topic: |
|
512 | if dh.topic: | |
515 |
topic = dh.topic.replace(b' |
|
513 | topic = dh.topic.replace(b'execute_result', b'pyerr') | |
516 |
|
514 | |||
517 | exc_msg = dh.session.send(dh.pub_socket, u'pyerr', json_clean(exc_content), dh.parent_header, ident=topic) |
|
515 | exc_msg = dh.session.send(dh.pub_socket, u'pyerr', json_clean(exc_content), dh.parent_header, ident=topic) | |
518 |
|
516 |
@@ -1,19 +1,7 b'' | |||||
1 | """AsyncResult objects for the client |
|
1 | """AsyncResult objects for the client""" | |
2 |
|
2 | |||
3 | Authors: |
|
3 | # Copyright (c) IPython Development Team. | |
4 |
|
4 | # Distributed under the terms of the Modified BSD License. | ||
5 | * MinRK |
|
|||
6 | """ |
|
|||
7 | #----------------------------------------------------------------------------- |
|
|||
8 | # Copyright (C) 2010-2011 The IPython Development Team |
|
|||
9 | # |
|
|||
10 | # Distributed under the terms of the BSD License. The full license is in |
|
|||
11 | # the file COPYING, distributed as part of this software. |
|
|||
12 | #----------------------------------------------------------------------------- |
|
|||
13 |
|
||||
14 | #----------------------------------------------------------------------------- |
|
|||
15 | # Imports |
|
|||
16 | #----------------------------------------------------------------------------- |
|
|||
17 |
|
5 | |||
18 | from __future__ import print_function |
|
6 | from __future__ import print_function | |
19 |
|
7 | |||
@@ -436,7 +424,7 b' class AsyncResult(object):' | |||||
436 | for output in self.outputs: |
|
424 | for output in self.outputs: | |
437 | self._republish_displaypub(output, self.engine_id) |
|
425 | self._republish_displaypub(output, self.engine_id) | |
438 |
|
426 | |||
439 |
if self. |
|
427 | if self.execute_result is not None: | |
440 | display(self.get()) |
|
428 | display(self.get()) | |
441 |
|
429 | |||
442 | def _wait_for_outputs(self, timeout=-1): |
|
430 | def _wait_for_outputs(self, timeout=-1): | |
@@ -495,15 +483,15 b' class AsyncResult(object):' | |||||
495 |
|
483 | |||
496 | stdouts = self.stdout |
|
484 | stdouts = self.stdout | |
497 | stderrs = self.stderr |
|
485 | stderrs = self.stderr | |
498 | pyouts = self.pyout |
|
486 | execute_results = self.execute_result | |
499 | output_lists = self.outputs |
|
487 | output_lists = self.outputs | |
500 | results = self.get() |
|
488 | results = self.get() | |
501 |
|
489 | |||
502 | targets = self.engine_id |
|
490 | targets = self.engine_id | |
503 |
|
491 | |||
504 | if groupby == "engine": |
|
492 | if groupby == "engine": | |
505 |
for eid,stdout,stderr,outputs,r, |
|
493 | for eid,stdout,stderr,outputs,r,execute_result in zip( | |
506 |
targets, stdouts, stderrs, output_lists, results, |
|
494 | targets, stdouts, stderrs, output_lists, results, execute_results | |
507 | ): |
|
495 | ): | |
508 | self._display_stream(stdout, '[stdout:%i] ' % eid) |
|
496 | self._display_stream(stdout, '[stdout:%i] ' % eid) | |
509 | self._display_stream(stderr, '[stderr:%i] ' % eid, file=sys.stderr) |
|
497 | self._display_stream(stderr, '[stderr:%i] ' % eid, file=sys.stderr) | |
@@ -514,13 +502,13 b' class AsyncResult(object):' | |||||
514 | # displaypub is meaningless outside IPython |
|
502 | # displaypub is meaningless outside IPython | |
515 | return |
|
503 | return | |
516 |
|
504 | |||
517 |
if outputs or |
|
505 | if outputs or execute_result is not None: | |
518 | _raw_text('[output:%i]' % eid) |
|
506 | _raw_text('[output:%i]' % eid) | |
519 |
|
507 | |||
520 | for output in outputs: |
|
508 | for output in outputs: | |
521 | self._republish_displaypub(output, eid) |
|
509 | self._republish_displaypub(output, eid) | |
522 |
|
510 | |||
523 |
if |
|
511 | if execute_result is not None: | |
524 | display(r) |
|
512 | display(r) | |
525 |
|
513 | |||
526 | elif groupby in ('type', 'order'): |
|
514 | elif groupby in ('type', 'order'): | |
@@ -555,9 +543,9 b' class AsyncResult(object):' | |||||
555 | for output in outputs: |
|
543 | for output in outputs: | |
556 | self._republish_displaypub(output, eid) |
|
544 | self._republish_displaypub(output, eid) | |
557 |
|
545 | |||
558 |
# finally, add |
|
546 | # finally, add execute_result: | |
559 |
for eid,r, |
|
547 | for eid,r,execute_result in zip(targets, results, execute_results): | |
560 |
if |
|
548 | if execute_result is not None: | |
561 | display(r) |
|
549 | display(r) | |
562 |
|
550 | |||
563 | else: |
|
551 | else: |
@@ -72,21 +72,21 b' class ExecuteReply(RichOutput):' | |||||
72 |
|
72 | |||
73 | @property |
|
73 | @property | |
74 | def source(self): |
|
74 | def source(self): | |
75 |
|
|
75 | execute_result = self.metadata['execute_result'] | |
76 |
if |
|
76 | if execute_result: | |
77 |
return |
|
77 | return execute_result.get('source', '') | |
78 |
|
78 | |||
79 | @property |
|
79 | @property | |
80 | def data(self): |
|
80 | def data(self): | |
81 |
|
|
81 | execute_result = self.metadata['execute_result'] | |
82 |
if |
|
82 | if execute_result: | |
83 |
return |
|
83 | return execute_result.get('data', {}) | |
84 |
|
84 | |||
85 | @property |
|
85 | @property | |
86 | def _metadata(self): |
|
86 | def _metadata(self): | |
87 |
|
|
87 | execute_result = self.metadata['execute_result'] | |
88 |
if |
|
88 | if execute_result: | |
89 |
return |
|
89 | return execute_result.get('metadata', {}) | |
90 |
|
90 | |||
91 | def display(self): |
|
91 | def display(self): | |
92 | from IPython.display import publish_display_data |
|
92 | from IPython.display import publish_display_data | |
@@ -110,16 +110,16 b' class ExecuteReply(RichOutput):' | |||||
110 | return self.metadata[key] |
|
110 | return self.metadata[key] | |
111 |
|
111 | |||
112 | def __repr__(self): |
|
112 | def __repr__(self): | |
113 |
|
|
113 | execute_result = self.metadata['execute_result'] or {'data':{}} | |
114 |
text_out = |
|
114 | text_out = execute_result['data'].get('text/plain', '') | |
115 | if len(text_out) > 32: |
|
115 | if len(text_out) > 32: | |
116 | text_out = text_out[:29] + '...' |
|
116 | text_out = text_out[:29] + '...' | |
117 |
|
117 | |||
118 | return "<ExecuteReply[%i]: %s>" % (self.execution_count, text_out) |
|
118 | return "<ExecuteReply[%i]: %s>" % (self.execution_count, text_out) | |
119 |
|
119 | |||
120 | def _repr_pretty_(self, p, cycle): |
|
120 | def _repr_pretty_(self, p, cycle): | |
121 |
|
|
121 | execute_result = self.metadata['execute_result'] or {'data':{}} | |
122 |
text_out = |
|
122 | text_out = execute_result['data'].get('text/plain', '') | |
123 |
|
123 | |||
124 | if not text_out: |
|
124 | if not text_out: | |
125 | return |
|
125 | return | |
@@ -170,7 +170,7 b' class Metadata(dict):' | |||||
170 | 'status' : None, |
|
170 | 'status' : None, | |
171 |
|
171 | |||
172 | 'execute_input' : None, |
|
172 | 'execute_input' : None, | |
173 |
' |
|
173 | 'execute_result' : None, | |
174 | 'pyerr' : None, |
|
174 | 'pyerr' : None, | |
175 | 'stdout' : '', |
|
175 | 'stdout' : '', | |
176 | 'stderr' : '', |
|
176 | 'stderr' : '', | |
@@ -875,8 +875,8 b' class Client(HasTraits):' | |||||
875 | md.update({'execute_input' : content['code']}) |
|
875 | md.update({'execute_input' : content['code']}) | |
876 | elif msg_type == 'display_data': |
|
876 | elif msg_type == 'display_data': | |
877 | md['outputs'].append(content) |
|
877 | md['outputs'].append(content) | |
878 |
elif msg_type == ' |
|
878 | elif msg_type == 'execute_result': | |
879 |
md[' |
|
879 | md['execute_result'] = content | |
880 | elif msg_type == 'data_message': |
|
880 | elif msg_type == 'data_message': | |
881 | data, remainder = serialize.unserialize_object(msg['buffers']) |
|
881 | data, remainder = serialize.unserialize_object(msg['buffers']) | |
882 | md['data'].update(data) |
|
882 | md['data'].update(data) |
@@ -67,7 +67,7 b' def empty_record():' | |||||
67 | 'result_buffers' : None, |
|
67 | 'result_buffers' : None, | |
68 | 'queue' : None, |
|
68 | 'queue' : None, | |
69 | 'execute_input' : None, |
|
69 | 'execute_input' : None, | |
70 |
' |
|
70 | 'execute_result': None, | |
71 | 'pyerr': None, |
|
71 | 'pyerr': None, | |
72 | 'stdout': '', |
|
72 | 'stdout': '', | |
73 | 'stderr': '', |
|
73 | 'stderr': '', | |
@@ -95,7 +95,7 b' def init_record(msg):' | |||||
95 | 'result_buffers' : None, |
|
95 | 'result_buffers' : None, | |
96 | 'queue' : None, |
|
96 | 'queue' : None, | |
97 | 'execute_input' : None, |
|
97 | 'execute_input' : None, | |
98 |
' |
|
98 | 'execute_result': None, | |
99 | 'pyerr': None, |
|
99 | 'pyerr': None, | |
100 | 'stdout': '', |
|
100 | 'stdout': '', | |
101 | 'stderr': '', |
|
101 | 'stderr': '', | |
@@ -869,7 +869,7 b' class Hub(SessionFactory):' | |||||
869 | d['pyerr'] = content |
|
869 | d['pyerr'] = content | |
870 | elif msg_type == 'execute_input': |
|
870 | elif msg_type == 'execute_input': | |
871 | d['execute_input'] = content['code'] |
|
871 | d['execute_input'] = content['code'] | |
872 |
elif msg_type in ('display_data', ' |
|
872 | elif msg_type in ('display_data', 'execute_result'): | |
873 | d[msg_type] = content |
|
873 | d[msg_type] = content | |
874 | elif msg_type == 'status': |
|
874 | elif msg_type == 'status': | |
875 | pass |
|
875 | pass | |
@@ -1316,7 +1316,7 b' class Hub(SessionFactory):' | |||||
1316 | def _extract_record(self, rec): |
|
1316 | def _extract_record(self, rec): | |
1317 | """decompose a TaskRecord dict into subsection of reply for get_result""" |
|
1317 | """decompose a TaskRecord dict into subsection of reply for get_result""" | |
1318 | io_dict = {} |
|
1318 | io_dict = {} | |
1319 |
for key in ('execute_input', ' |
|
1319 | for key in ('execute_input', 'execute_result', 'pyerr', 'stdout', 'stderr'): | |
1320 | io_dict[key] = rec[key] |
|
1320 | io_dict[key] = rec[key] | |
1321 | content = { |
|
1321 | content = { | |
1322 | 'header': rec['header'], |
|
1322 | 'header': rec['header'], |
@@ -121,7 +121,7 b' class SQLiteDB(BaseDB):' | |||||
121 | 'result_buffers' , |
|
121 | 'result_buffers' , | |
122 | 'queue' , |
|
122 | 'queue' , | |
123 | 'execute_input' , |
|
123 | 'execute_input' , | |
124 |
' |
|
124 | 'execute_result', | |
125 | 'pyerr', |
|
125 | 'pyerr', | |
126 | 'stdout', |
|
126 | 'stdout', | |
127 | 'stderr', |
|
127 | 'stderr', | |
@@ -145,7 +145,7 b' class SQLiteDB(BaseDB):' | |||||
145 | 'result_buffers' : 'bufs blob', |
|
145 | 'result_buffers' : 'bufs blob', | |
146 | 'queue' : 'text', |
|
146 | 'queue' : 'text', | |
147 | 'execute_input' : 'text', |
|
147 | 'execute_input' : 'text', | |
148 |
' |
|
148 | 'execute_result' : 'text', | |
149 | 'pyerr' : 'text', |
|
149 | 'pyerr' : 'text', | |
150 | 'stdout' : 'text', |
|
150 | 'stdout' : 'text', | |
151 | 'stderr' : 'text', |
|
151 | 'stderr' : 'text', | |
@@ -256,7 +256,7 b' class SQLiteDB(BaseDB):' | |||||
256 | result_buffers bufs blob, |
|
256 | result_buffers bufs blob, | |
257 | queue text, |
|
257 | queue text, | |
258 | execute_input text, |
|
258 | execute_input text, | |
259 |
|
|
259 | execute_result text, | |
260 | pyerr text, |
|
260 | pyerr text, | |
261 | stdout text, |
|
261 | stdout text, | |
262 | stderr text) |
|
262 | stderr text) |
@@ -1,17 +1,10 b'' | |||||
1 | """A simple engine that talks to a controller over 0MQ. |
|
1 | """A simple engine that talks to a controller over 0MQ. | |
2 | it handles registration, etc. and launches a kernel |
|
2 | it handles registration, etc. and launches a kernel | |
3 | connected to the Controller's Schedulers. |
|
3 | connected to the Controller's Schedulers. | |
4 |
|
||||
5 | Authors: |
|
|||
6 |
|
||||
7 | * Min RK |
|
|||
8 | """ |
|
4 | """ | |
9 | #----------------------------------------------------------------------------- |
|
5 | ||
10 |
# |
|
6 | # Copyright (c) IPython Development Team. | |
11 | # |
|
7 | # Distributed under the terms of the Modified BSD License. | |
12 | # Distributed under the terms of the BSD License. The full license is in |
|
|||
13 | # the file COPYING, distributed as part of this software. |
|
|||
14 | #----------------------------------------------------------------------------- |
|
|||
15 |
|
8 | |||
16 | from __future__ import print_function |
|
9 | from __future__ import print_function | |
17 |
|
10 | |||
@@ -228,7 +221,7 b' class EngineFactory(RegistrationFactory):' | |||||
228 | sys.stderr.topic = cast_bytes('engine.%i.stderr' % self.id) |
|
221 | sys.stderr.topic = cast_bytes('engine.%i.stderr' % self.id) | |
229 | if self.display_hook_factory: |
|
222 | if self.display_hook_factory: | |
230 | sys.displayhook = self.display_hook_factory(self.session, iopub_socket) |
|
223 | sys.displayhook = self.display_hook_factory(self.session, iopub_socket) | |
231 |
sys.displayhook.topic = cast_bytes('engine.%i. |
|
224 | sys.displayhook.topic = cast_bytes('engine.%i.execute_result' % self.id) | |
232 |
|
225 | |||
233 | self.kernel = Kernel(parent=self, int_id=self.id, ident=self.ident, session=self.session, |
|
226 | self.kernel = Kernel(parent=self, int_id=self.id, ident=self.ident, session=self.session, | |
234 | control_stream=control_stream, shell_streams=shell_streams, iopub_socket=iopub_socket, |
|
227 | control_stream=control_stream, shell_streams=shell_streams, iopub_socket=iopub_socket, |
@@ -1,20 +1,7 b'' | |||||
1 | """Tests for parallel client.py |
|
1 | """Tests for parallel client.py""" | |
2 |
|
2 | |||
3 | Authors: |
|
3 | # Copyright (c) IPython Development Team. | |
4 |
|
4 | # Distributed under the terms of the Modified BSD License. | ||
5 | * Min RK |
|
|||
6 | """ |
|
|||
7 |
|
||||
8 | #------------------------------------------------------------------------------- |
|
|||
9 | # Copyright (C) 2011 The IPython Development Team |
|
|||
10 | # |
|
|||
11 | # Distributed under the terms of the BSD License. The full license is in |
|
|||
12 | # the file COPYING, distributed as part of this software. |
|
|||
13 | #------------------------------------------------------------------------------- |
|
|||
14 |
|
||||
15 | #------------------------------------------------------------------------------- |
|
|||
16 | # Imports |
|
|||
17 | #------------------------------------------------------------------------------- |
|
|||
18 |
|
5 | |||
19 | from __future__ import division |
|
6 | from __future__ import division | |
20 |
|
7 | |||
@@ -177,7 +164,7 b' class TestClient(ClusterTestCase):' | |||||
177 | time.sleep(.25) |
|
164 | time.sleep(.25) | |
178 | ahr = self.client.get_result(ar.msg_ids[0]) |
|
165 | ahr = self.client.get_result(ar.msg_ids[0]) | |
179 | self.assertTrue(isinstance(ahr, AsyncHubResult)) |
|
166 | self.assertTrue(isinstance(ahr, AsyncHubResult)) | |
180 |
self.assertEqual(ahr.get(). |
|
167 | self.assertEqual(ahr.get().execute_result, ar.get().execute_result) | |
181 | ar2 = self.client.get_result(ar.msg_ids[0]) |
|
168 | ar2 = self.client.get_result(ar.msg_ids[0]) | |
182 | self.assertFalse(isinstance(ar2, AsyncHubResult)) |
|
169 | self.assertFalse(isinstance(ar2, AsyncHubResult)) | |
183 | c.close() |
|
170 | c.close() |
@@ -537,7 +537,7 b' class TestView(ClusterTestCase):' | |||||
537 | ar = e0.execute("5", silent=False) |
|
537 | ar = e0.execute("5", silent=False) | |
538 | er = ar.get() |
|
538 | er = ar.get() | |
539 | self.assertEqual(str(er), "<ExecuteReply[%i]: 5>" % er.execution_count) |
|
539 | self.assertEqual(str(er), "<ExecuteReply[%i]: 5>" % er.execution_count) | |
540 |
self.assertEqual(er. |
|
540 | self.assertEqual(er.execute_result['data']['text/plain'], '5') | |
541 |
|
541 | |||
542 | def test_execute_reply_rich(self): |
|
542 | def test_execute_reply_rich(self): | |
543 | e0 = self.client[self.client.ids[0]] |
|
543 | e0 = self.client[self.client.ids[0]] | |
@@ -558,21 +558,21 b' class TestView(ClusterTestCase):' | |||||
558 | er = ar.get() |
|
558 | er = ar.get() | |
559 | self.assertEqual(er.stdout.strip(), '5') |
|
559 | self.assertEqual(er.stdout.strip(), '5') | |
560 |
|
560 | |||
561 |
def test_execute_ |
|
561 | def test_execute_result(self): | |
562 |
"""execute triggers |
|
562 | """execute triggers execute_result with silent=False""" | |
563 | view = self.client[:] |
|
563 | view = self.client[:] | |
564 | ar = view.execute("5", silent=False, block=True) |
|
564 | ar = view.execute("5", silent=False, block=True) | |
565 |
|
565 | |||
566 | expected = [{'text/plain' : '5'}] * len(view) |
|
566 | expected = [{'text/plain' : '5'}] * len(view) | |
567 |
mimes = [ out['data'] for out in ar. |
|
567 | mimes = [ out['data'] for out in ar.execute_result ] | |
568 | self.assertEqual(mimes, expected) |
|
568 | self.assertEqual(mimes, expected) | |
569 |
|
569 | |||
570 | def test_execute_silent(self): |
|
570 | def test_execute_silent(self): | |
571 |
"""execute does not trigger |
|
571 | """execute does not trigger execute_result with silent=True""" | |
572 | view = self.client[:] |
|
572 | view = self.client[:] | |
573 | ar = view.execute("5", block=True) |
|
573 | ar = view.execute("5", block=True) | |
574 | expected = [None] * len(view) |
|
574 | expected = [None] * len(view) | |
575 |
self.assertEqual(ar. |
|
575 | self.assertEqual(ar.execute_result, expected) | |
576 |
|
576 | |||
577 | def test_execute_magic(self): |
|
577 | def test_execute_magic(self): | |
578 | """execute accepts IPython commands""" |
|
578 | """execute accepts IPython commands""" |
@@ -1,17 +1,19 b'' | |||||
|
1 | """Frontend widget for the Qt Console""" | |||
|
2 | ||||
|
3 | # Copyright (c) IPython Development Team. | |||
|
4 | # Distributed under the terms of the Modified BSD License. | |||
|
5 | ||||
1 | from __future__ import print_function |
|
6 | from __future__ import print_function | |
2 |
|
7 | |||
3 | # Standard library imports |
|
|||
4 | from collections import namedtuple |
|
8 | from collections import namedtuple | |
5 | import sys |
|
9 | import sys | |
6 | import uuid |
|
10 | import uuid | |
7 |
|
11 | |||
8 | # System library imports |
|
|||
9 | from IPython.external import qt |
|
12 | from IPython.external import qt | |
10 | from IPython.external.qt import QtCore, QtGui |
|
13 | from IPython.external.qt import QtCore, QtGui | |
11 | from IPython.utils import py3compat |
|
14 | from IPython.utils import py3compat | |
12 | from IPython.utils.importstring import import_item |
|
15 | from IPython.utils.importstring import import_item | |
13 |
|
16 | |||
14 | # Local imports |
|
|||
15 | from IPython.core.inputsplitter import InputSplitter, IPythonInputSplitter |
|
17 | from IPython.core.inputsplitter import InputSplitter, IPythonInputSplitter | |
16 | from IPython.core.inputtransformer import classic_prompt |
|
18 | from IPython.core.inputtransformer import classic_prompt | |
17 | from IPython.core.oinspect import call_tip |
|
19 | from IPython.core.oinspect import call_tip | |
@@ -526,10 +528,10 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
526 | if call_info or doc: |
|
528 | if call_info or doc: | |
527 | self._call_tip_widget.show_call_info(call_info, doc) |
|
529 | self._call_tip_widget.show_call_info(call_info, doc) | |
528 |
|
530 | |||
529 |
def _handle_ |
|
531 | def _handle_execute_result(self, msg): | |
530 | """ Handle display hook output. |
|
532 | """ Handle display hook output. | |
531 | """ |
|
533 | """ | |
532 |
self.log.debug(" |
|
534 | self.log.debug("execute_result: %s", msg.get('content', '')) | |
533 | if not self._hidden and self._is_from_this_session(msg): |
|
535 | if not self._hidden and self._is_from_this_session(msg): | |
534 | self.flush_clearoutput() |
|
536 | self.flush_clearoutput() | |
535 | text = msg['content']['data'] |
|
537 | text = msg['content']['data'] |
@@ -3,11 +3,9 b'' | |||||
3 | This supports the additional functionality provided by the IPython kernel. |
|
3 | This supports the additional functionality provided by the IPython kernel. | |
4 | """ |
|
4 | """ | |
5 |
|
5 | |||
6 | #----------------------------------------------------------------------------- |
|
6 | # Copyright (c) IPython Development Team. | |
7 | # Imports |
|
7 | # Distributed under the terms of the Modified BSD License. | |
8 | #----------------------------------------------------------------------------- |
|
|||
9 |
|
8 | |||
10 | # Standard library imports |
|
|||
11 | from collections import namedtuple |
|
9 | from collections import namedtuple | |
12 | import os.path |
|
10 | import os.path | |
13 | import re |
|
11 | import re | |
@@ -16,10 +14,8 b' import sys' | |||||
16 | import time |
|
14 | import time | |
17 | from textwrap import dedent |
|
15 | from textwrap import dedent | |
18 |
|
16 | |||
19 | # System library imports |
|
|||
20 | from IPython.external.qt import QtCore, QtGui |
|
17 | from IPython.external.qt import QtCore, QtGui | |
21 |
|
18 | |||
22 | # Local imports |
|
|||
23 | from IPython.core.inputsplitter import IPythonInputSplitter |
|
19 | from IPython.core.inputsplitter import IPythonInputSplitter | |
24 | from IPython.core.inputtransformer import ipy_prompt |
|
20 | from IPython.core.inputtransformer import ipy_prompt | |
25 | from IPython.utils.traitlets import Bool, Unicode |
|
21 | from IPython.utils.traitlets import Bool, Unicode | |
@@ -217,10 +213,10 b' class IPythonWidget(FrontendWidget):' | |||||
217 | last_cell = cell |
|
213 | last_cell = cell | |
218 | self._set_history(items) |
|
214 | self._set_history(items) | |
219 |
|
215 | |||
220 |
def _handle_ |
|
216 | def _handle_execute_result(self, msg): | |
221 | """ Reimplemented for IPython-style "display hook". |
|
217 | """ Reimplemented for IPython-style "display hook". | |
222 | """ |
|
218 | """ | |
223 |
self.log.debug(" |
|
219 | self.log.debug("execute_result: %s", msg.get('content', '')) | |
224 | if not self._hidden and self._is_from_this_session(msg): |
|
220 | if not self._hidden and self._is_from_this_session(msg): | |
225 | self.flush_clearoutput() |
|
221 | self.flush_clearoutput() | |
226 | content = msg['content'] |
|
222 | content = msg['content'] |
@@ -98,12 +98,12 b' class RichIPythonWidget(IPythonWidget):' | |||||
98 |
|
98 | |||
99 | Shared code for some the following if statement |
|
99 | Shared code for some the following if statement | |
100 | """ |
|
100 | """ | |
101 |
self.log.debug(" |
|
101 | self.log.debug("execute_result: %s", msg.get('content', '')) | |
102 | self._append_plain_text(self.output_sep, True) |
|
102 | self._append_plain_text(self.output_sep, True) | |
103 | self._append_html(self._make_out_prompt(prompt_number), True) |
|
103 | self._append_html(self._make_out_prompt(prompt_number), True) | |
104 | self._append_plain_text('\n', True) |
|
104 | self._append_plain_text('\n', True) | |
105 |
|
105 | |||
106 |
def _handle_ |
|
106 | def _handle_execute_result(self, msg): | |
107 | """ Overridden to handle rich data types, like SVG. |
|
107 | """ Overridden to handle rich data types, like SVG. | |
108 | """ |
|
108 | """ | |
109 | if not self._hidden and self._is_from_this_session(msg): |
|
109 | if not self._hidden and self._is_from_this_session(msg): | |
@@ -128,7 +128,7 b' class RichIPythonWidget(IPythonWidget):' | |||||
128 | self._append_html(self.output_sep2, True) |
|
128 | self._append_html(self.output_sep2, True) | |
129 | else: |
|
129 | else: | |
130 | # Default back to the plain text representation. |
|
130 | # Default back to the plain text representation. | |
131 |
return super(RichIPythonWidget, self)._handle_ |
|
131 | return super(RichIPythonWidget, self)._handle_execute_result(msg) | |
132 |
|
132 | |||
133 | def _handle_display_data(self, msg): |
|
133 | def _handle_display_data(self, msg): | |
134 | """ Overridden to handle rich data types, like SVG. |
|
134 | """ Overridden to handle rich data types, like SVG. |
@@ -88,8 +88,8 b' class QtIOPubChannelMixin(ChannelQObject):' | |||||
88 | # Emitted when a message of type 'execute_input' is received. |
|
88 | # Emitted when a message of type 'execute_input' is received. | |
89 | execute_input_received = QtCore.Signal(object) |
|
89 | execute_input_received = QtCore.Signal(object) | |
90 |
|
90 | |||
91 |
# Emitted when a message of type ' |
|
91 | # Emitted when a message of type 'execute_result' is received. | |
92 |
|
|
92 | execute_result_received = QtCore.Signal(object) | |
93 |
|
93 | |||
94 | # Emitted when a message of type 'pyerr' is received. |
|
94 | # Emitted when a message of type 'pyerr' is received. | |
95 | pyerr_received = QtCore.Signal(object) |
|
95 | pyerr_received = QtCore.Signal(object) |
@@ -1,17 +1,9 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """terminal client to the IPython kernel |
|
2 | """terminal client to the IPython kernel""" | |
3 |
|
3 | |||
4 | """ |
|
4 | # Copyright (c) IPython Development Team. | |
5 | #----------------------------------------------------------------------------- |
|
5 | # Distributed under the terms of the Modified BSD License. | |
6 | # Copyright (C) 2013 The IPython Development Team |
|
6 | ||
7 | # |
|
|||
8 | # Distributed under the terms of the BSD License. The full license is in |
|
|||
9 | # the file COPYING, distributed as part of this software. |
|
|||
10 | #----------------------------------------------------------------------------- |
|
|||
11 |
|
||||
12 | #----------------------------------------------------------------------------- |
|
|||
13 | # Imports |
|
|||
14 | #----------------------------------------------------------------------------- |
|
|||
15 | from __future__ import print_function |
|
7 | from __future__ import print_function | |
16 |
|
8 | |||
17 | import bdb |
|
9 | import bdb | |
@@ -228,7 +220,7 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):' | |||||
228 | """Process messages on the IOPub channel |
|
220 | """Process messages on the IOPub channel | |
229 |
|
221 | |||
230 | This method consumes and processes messages on the IOPub channel, |
|
222 | This method consumes and processes messages on the IOPub channel, | |
231 |
such as stdout, stderr, |
|
223 | such as stdout, stderr, execute_result and status. | |
232 |
|
224 | |||
233 | It only displays output that is caused by this session. |
|
225 | It only displays output that is caused by this session. | |
234 | """ |
|
226 | """ | |
@@ -254,7 +246,7 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):' | |||||
254 | print(sub_msg["content"]["data"], file=io.stderr, end="") |
|
246 | print(sub_msg["content"]["data"], file=io.stderr, end="") | |
255 | io.stderr.flush() |
|
247 | io.stderr.flush() | |
256 |
|
248 | |||
257 |
elif msg_type == ' |
|
249 | elif msg_type == 'execute_result': | |
258 | if self._pending_clearoutput: |
|
250 | if self._pending_clearoutput: | |
259 | print("\r", file=io.stdout, end="") |
|
251 | print("\r", file=io.stdout, end="") | |
260 | self._pending_clearoutput = False |
|
252 | self._pending_clearoutput = False |
General Comments 0
You need to be logged in to leave comments.
Login now