Show More
@@ -39,12 +39,11 b' from IPython.utils import py3compat' | |||||
39 | from IPython.utils.jsonutil import json_clean |
|
39 | from IPython.utils.jsonutil import json_clean | |
40 | from IPython.lib import pylabtools |
|
40 | from IPython.lib import pylabtools | |
41 | from IPython.utils.traitlets import ( |
|
41 | from IPython.utils.traitlets import ( | |
42 |
Any |
|
42 | Any, Instance, Float, Dict, CaselessStrEnum | |
43 | ) |
|
43 | ) | |
44 |
|
44 | |||
45 | from entry_point import base_launch_kernel |
|
45 | from entry_point import base_launch_kernel | |
46 | from kernelapp import KernelApp, kernel_flags, kernel_aliases |
|
46 | from kernelapp import KernelApp, kernel_flags, kernel_aliases | |
47 | from iostream import OutStream |
|
|||
48 | from session import Session, Message |
|
47 | from session import Session, Message | |
49 | from zmqshell import ZMQInteractiveShell |
|
48 | from zmqshell import ZMQInteractiveShell | |
50 |
|
49 | |||
@@ -212,16 +211,16 b' class Kernel(Configurable):' | |||||
212 | def _publish_pyin(self, code, parent): |
|
211 | def _publish_pyin(self, code, parent): | |
213 | """Publish the code request on the pyin stream.""" |
|
212 | """Publish the code request on the pyin stream.""" | |
214 |
|
213 | |||
215 |
|
|
214 | self.session.send(self.iopub_socket, u'pyin', {u'code':code}, | |
|
215 | parent=parent) | |||
216 |
|
216 | |||
217 | def execute_request(self, ident, parent): |
|
217 | def execute_request(self, ident, parent): | |
218 |
|
218 | |||
219 |
|
|
219 | self.session.send(self.iopub_socket, | |
220 | u'status', |
|
220 | u'status', | |
221 | {u'execution_state':u'busy'}, |
|
221 | {u'execution_state':u'busy'}, | |
222 | parent=parent |
|
222 | parent=parent ) | |
223 |
|
|
223 | ||
224 |
|
||||
225 | try: |
|
224 | try: | |
226 | content = parent[u'content'] |
|
225 | content = parent[u'content'] | |
227 | code = content[u'code'] |
|
226 | code = content[u'code'] | |
@@ -331,11 +330,10 b' class Kernel(Configurable):' | |||||
331 | if reply_msg['content']['status'] == u'error': |
|
330 | if reply_msg['content']['status'] == u'error': | |
332 | self._abort_queue() |
|
331 | self._abort_queue() | |
333 |
|
332 | |||
334 |
|
|
333 | self.session.send(self.iopub_socket, | |
335 | u'status', |
|
334 | u'status', | |
336 | {u'execution_state':u'idle'}, |
|
335 | {u'execution_state':u'idle'}, | |
337 | parent=parent |
|
336 | parent=parent ) | |
338 | ) |
|
|||
339 |
|
337 | |||
340 | def complete_request(self, ident, parent): |
|
338 | def complete_request(self, ident, parent): | |
341 | txt, matches = self._complete(parent) |
|
339 | txt, matches = self._complete(parent) | |
@@ -375,7 +373,8 b' class Kernel(Configurable):' | |||||
375 |
|
373 | |||
376 | elif hist_access_type == 'search': |
|
374 | elif hist_access_type == 'search': | |
377 | pattern = parent['content']['pattern'] |
|
375 | pattern = parent['content']['pattern'] | |
378 |
hist = self.shell.history_manager.search(pattern, raw=raw, |
|
376 | hist = self.shell.history_manager.search(pattern, raw=raw, | |
|
377 | output=output) | |||
379 |
|
378 | |||
380 | else: |
|
379 | else: | |
381 | hist = [] |
|
380 | hist = [] | |
@@ -396,7 +395,8 b' class Kernel(Configurable):' | |||||
396 |
|
395 | |||
397 | def shutdown_request(self, ident, parent): |
|
396 | def shutdown_request(self, ident, parent): | |
398 | self.shell.exit_now = True |
|
397 | self.shell.exit_now = True | |
399 |
self._shutdown_message = self.session.msg(u'shutdown_reply', |
|
398 | self._shutdown_message = self.session.msg(u'shutdown_reply', | |
|
399 | parent['content'], parent) | |||
400 | sys.exit(0) |
|
400 | sys.exit(0) | |
401 |
|
401 | |||
402 | #--------------------------------------------------------------------------- |
|
402 | #--------------------------------------------------------------------------- | |
@@ -427,8 +427,10 b' class Kernel(Configurable):' | |||||
427 | time.sleep(0.1) |
|
427 | time.sleep(0.1) | |
428 |
|
428 | |||
429 | def _no_raw_input(self): |
|
429 | def _no_raw_input(self): | |
430 |
"""Raise StdinNotImplentedError if active frontend doesn't support |
|
430 | """Raise StdinNotImplentedError if active frontend doesn't support | |
431 | raise StdinNotImplementedError("raw_input was called, but this frontend does not support stdin.") |
|
431 | stdin.""" | |
|
432 | raise StdinNotImplementedError("raw_input was called, but this " | |||
|
433 | "frontend does not support stdin.") | |||
432 |
|
434 | |||
433 | def _raw_input(self, prompt, ident, parent): |
|
435 | def _raw_input(self, prompt, ident, parent): | |
434 | # Flush output before making the request. |
|
436 | # Flush output before making the request. | |
@@ -437,7 +439,8 b' class Kernel(Configurable):' | |||||
437 |
|
439 | |||
438 | # Send the input request. |
|
440 | # Send the input request. | |
439 | content = json_clean(dict(prompt=prompt)) |
|
441 | content = json_clean(dict(prompt=prompt)) | |
440 |
|
|
442 | self.session.send(self.stdin_socket, u'input_request', content, parent, | |
|
443 | ident=ident) | |||
441 |
|
444 | |||
442 | # Await a response. |
|
445 | # Await a response. | |
443 | while True: |
|
446 | while True: | |
@@ -584,7 +587,8 b' class IPKernelApp(KernelApp, InteractiveShellApp):' | |||||
584 | # replace pyerr-sending traceback with stdout |
|
587 | # replace pyerr-sending traceback with stdout | |
585 | _showtraceback = shell._showtraceback |
|
588 | _showtraceback = shell._showtraceback | |
586 | def print_tb(etype, evalue, stb): |
|
589 | def print_tb(etype, evalue, stb): | |
587 |
print ("Error initializing pylab, pylab mode will not |
|
590 | print ("Error initializing pylab, pylab mode will not " | |
|
591 | "be active", file=io.stderr) | |||
588 | print (shell.InteractiveTB.stb2text(stb), file=io.stdout) |
|
592 | print (shell.InteractiveTB.stb2text(stb), file=io.stdout) | |
589 | shell._showtraceback = print_tb |
|
593 | shell._showtraceback = print_tb | |
590 |
|
594 | |||
@@ -607,8 +611,8 b' class IPKernelApp(KernelApp, InteractiveShellApp):' | |||||
607 | def launch_kernel(*args, **kwargs): |
|
611 | def launch_kernel(*args, **kwargs): | |
608 | """Launches a localhost IPython kernel, binding to the specified ports. |
|
612 | """Launches a localhost IPython kernel, binding to the specified ports. | |
609 |
|
613 | |||
610 |
This function simply calls entry_point.base_launch_kernel with the right |
|
614 | This function simply calls entry_point.base_launch_kernel with the right | |
611 | command to start an ipkernel. See base_launch_kernel for arguments. |
|
615 | first command to start an ipkernel. See base_launch_kernel for arguments. | |
612 |
|
616 | |||
613 | Returns |
|
617 | Returns | |
614 | ------- |
|
618 | ------- |
General Comments 0
You need to be logged in to leave comments.
Login now