Show More
@@ -136,15 +136,23 b' class BaseFrontendMixin(object):' | |||||
136 | handler = getattr(self, '_handle_' + msg_type, None) |
|
136 | handler = getattr(self, '_handle_' + msg_type, None) | |
137 | if handler: |
|
137 | if handler: | |
138 | handler(msg) |
|
138 | handler(msg) | |
139 |
|
139 | |||
140 |
def |
|
140 | def from_here(self, msg): | |
141 | """ Returns whether a reply from the kernel originated from a request |
|
141 | """Return whether a message is from this session""" | |
142 | from this frontend. |
|
142 | session_id = self._kernel_client.session.session | |
143 | """ |
|
143 | return msg['parent_header'].get("session", session_id) == session_id | |
144 | session = self._kernel_client.session.session |
|
144 | ||
145 | parent = msg['parent_header'] |
|
145 | def include_output(self, msg): | |
146 | if not parent: |
|
146 | """Return whether we should include a given output message""" | |
147 | # if the message has no parent, assume it is meant for all frontends |
|
147 | if self._hidden: | |
|
148 | return False | |||
|
149 | from_here = self.from_here(msg) | |||
|
150 | if msg['msg_type'] == 'execute_input': | |||
|
151 | # only echo inputs not from here | |||
|
152 | return self.include_other_output and not from_here | |||
|
153 | ||||
|
154 | if self.include_other_output: | |||
148 | return True |
|
155 | return True | |
149 | else: |
|
156 | else: | |
150 | return parent.get('session') == session |
|
157 | return from_here | |
|
158 |
@@ -519,7 +519,15 b" class ConsoleWidget(MetaQObjectHasTraits('NewBase', (LoggingConfigurable, QtGui." | |||||
519 | #--------------------------------------------------------------------------- |
|
519 | #--------------------------------------------------------------------------- | |
520 | # 'ConsoleWidget' public interface |
|
520 | # 'ConsoleWidget' public interface | |
521 | #--------------------------------------------------------------------------- |
|
521 | #--------------------------------------------------------------------------- | |
522 |
|
522 | |||
|
523 | include_other_output = Bool(False, config=True, | |||
|
524 | help="""Whether to include output from clients | |||
|
525 | other than this one sharing the same kernel. | |||
|
526 | ||||
|
527 | Outputs are not displayed until enter is pressed. | |||
|
528 | """ | |||
|
529 | ) | |||
|
530 | ||||
523 | def can_copy(self): |
|
531 | def can_copy(self): | |
524 | """ Returns whether text can be copied to the clipboard. |
|
532 | """ Returns whether text can be copied to the clipboard. | |
525 | """ |
|
533 | """ |
@@ -350,7 +350,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
350 | #--------------------------------------------------------------------------- |
|
350 | #--------------------------------------------------------------------------- | |
351 | def _handle_clear_output(self, msg): |
|
351 | def _handle_clear_output(self, msg): | |
352 | """Handle clear output messages.""" |
|
352 | """Handle clear output messages.""" | |
353 | if not self._hidden and self._is_from_this_session(msg): |
|
353 | if include_output(msg): | |
354 | wait = msg['content'].get('wait', True) |
|
354 | wait = msg['content'].get('wait', True) | |
355 | if wait: |
|
355 | if wait: | |
356 | self._pending_clearoutput = True |
|
356 | self._pending_clearoutput = True | |
@@ -523,7 +523,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
523 | """ Handle display hook output. |
|
523 | """ Handle display hook output. | |
524 | """ |
|
524 | """ | |
525 | self.log.debug("execute_result: %s", msg.get('content', '')) |
|
525 | self.log.debug("execute_result: %s", msg.get('content', '')) | |
526 | if not self._hidden and self._is_from_this_session(msg): |
|
526 | if self.include_output(msg): | |
527 | self.flush_clearoutput() |
|
527 | self.flush_clearoutput() | |
528 | text = msg['content']['data'] |
|
528 | text = msg['content']['data'] | |
529 | self._append_plain_text(text + '\n', before_prompt=True) |
|
529 | self._append_plain_text(text + '\n', before_prompt=True) | |
@@ -532,7 +532,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
532 | """ Handle stdout, stderr, and stdin. |
|
532 | """ Handle stdout, stderr, and stdin. | |
533 | """ |
|
533 | """ | |
534 | self.log.debug("stream: %s", msg.get('content', '')) |
|
534 | self.log.debug("stream: %s", msg.get('content', '')) | |
535 | if not self._hidden and self._is_from_this_session(msg): |
|
535 | if self.include_output(msg): | |
536 | self.flush_clearoutput() |
|
536 | self.flush_clearoutput() | |
537 | self.append_stream(msg['content']['text']) |
|
537 | self.append_stream(msg['content']['text']) | |
538 |
|
538 | |||
@@ -541,7 +541,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
541 | """ |
|
541 | """ | |
542 | self.log.info("shutdown: %s", msg.get('content', '')) |
|
542 | self.log.info("shutdown: %s", msg.get('content', '')) | |
543 | restart = msg.get('content', {}).get('restart', False) |
|
543 | restart = msg.get('content', {}).get('restart', False) | |
544 |
if not self._hidden and not self. |
|
544 | if not self._hidden and not self.from_here(msg): | |
545 | # got shutdown reply, request came from session other than ours |
|
545 | # got shutdown reply, request came from session other than ours | |
546 | if restart: |
|
546 | if restart: | |
547 | # someone restarted the kernel, handle it |
|
547 | # someone restarted the kernel, handle it |
@@ -220,11 +220,21 b' class IPythonWidget(FrontendWidget):' | |||||
220 | last_cell = cell |
|
220 | last_cell = cell | |
221 | self._set_history(items) |
|
221 | self._set_history(items) | |
222 |
|
222 | |||
|
223 | def _handle_execute_input(self, msg): | |||
|
224 | """Handle an execute_input message""" | |||
|
225 | self.log.debug("execute_input: %s", msg.get('content', '')) | |||
|
226 | if self.include_output(msg): | |||
|
227 | content = msg['content'] | |||
|
228 | prompt_number = content.get('execution_count', 0) | |||
|
229 | self._append_html(self._make_in_prompt(prompt_number), True) | |||
|
230 | self._append_plain_text(content['code'], True) | |||
|
231 | ||||
|
232 | ||||
223 | def _handle_execute_result(self, msg): |
|
233 | def _handle_execute_result(self, msg): | |
224 | """ Reimplemented for IPython-style "display hook". |
|
234 | """ Reimplemented for IPython-style "display hook". | |
225 | """ |
|
235 | """ | |
226 | self.log.debug("execute_result: %s", msg.get('content', '')) |
|
236 | self.log.debug("execute_result: %s", msg.get('content', '')) | |
227 | if not self._hidden and self._is_from_this_session(msg): |
|
237 | if self.include_output(msg): | |
228 | self.flush_clearoutput() |
|
238 | self.flush_clearoutput() | |
229 | content = msg['content'] |
|
239 | content = msg['content'] | |
230 | prompt_number = content.get('execution_count', 0) |
|
240 | prompt_number = content.get('execution_count', 0) | |
@@ -246,7 +256,7 b' class IPythonWidget(FrontendWidget):' | |||||
246 | # For now, we don't display data from other frontends, but we |
|
256 | # For now, we don't display data from other frontends, but we | |
247 | # eventually will as this allows all frontends to monitor the display |
|
257 | # eventually will as this allows all frontends to monitor the display | |
248 | # data. But we need to figure out how to handle this in the GUI. |
|
258 | # data. But we need to figure out how to handle this in the GUI. | |
249 | if not self._hidden and self._is_from_this_session(msg): |
|
259 | if self.include_output(msg): | |
250 | self.flush_clearoutput() |
|
260 | self.flush_clearoutput() | |
251 | data = msg['content']['data'] |
|
261 | data = msg['content']['data'] | |
252 | metadata = msg['content']['metadata'] |
|
262 | metadata = msg['content']['metadata'] |
@@ -107,7 +107,7 b' class RichIPythonWidget(IPythonWidget):' | |||||
107 | def _handle_execute_result(self, msg): |
|
107 | def _handle_execute_result(self, msg): | |
108 | """ Overridden to handle rich data types, like SVG. |
|
108 | """ Overridden to handle rich data types, like SVG. | |
109 | """ |
|
109 | """ | |
110 | if not self._hidden and self._is_from_this_session(msg): |
|
110 | if self.include_output(msg): | |
111 | self.flush_clearoutput() |
|
111 | self.flush_clearoutput() | |
112 | content = msg['content'] |
|
112 | content = msg['content'] | |
113 | prompt_number = content.get('execution_count', 0) |
|
113 | prompt_number = content.get('execution_count', 0) | |
@@ -146,7 +146,7 b' class RichIPythonWidget(IPythonWidget):' | |||||
146 | def _handle_display_data(self, msg): |
|
146 | def _handle_display_data(self, msg): | |
147 | """ Overridden to handle rich data types, like SVG. |
|
147 | """ Overridden to handle rich data types, like SVG. | |
148 | """ |
|
148 | """ | |
149 | if not self._hidden and self._is_from_this_session(msg): |
|
149 | if self.include_output(msg): | |
150 | self.flush_clearoutput() |
|
150 | self.flush_clearoutput() | |
151 | data = msg['content']['data'] |
|
151 | data = msg['content']['data'] | |
152 | metadata = msg['content']['metadata'] |
|
152 | metadata = msg['content']['metadata'] |
General Comments 0
You need to be logged in to leave comments.
Login now