Show More
@@ -68,6 +68,10 b' class Kernel(KernelBase):' | |||||
68 | def banner(self): |
|
68 | def banner(self): | |
69 | return self.shell.banner |
|
69 | return self.shell.banner | |
70 |
|
70 | |||
|
71 | def start(self): | |||
|
72 | self.shell.exit_now = False | |||
|
73 | super(Kernel, self).start() | |||
|
74 | ||||
71 | def set_parent(self, ident, parent): |
|
75 | def set_parent(self, ident, parent): | |
72 | """Overridden from parent to tell the display hook and output streams |
|
76 | """Overridden from parent to tell the display hook and output streams | |
73 | about the parent message. |
|
77 | about the parent message. |
@@ -225,7 +225,6 b' class KernelBase(Configurable):' | |||||
225 |
|
225 | |||
226 | def start(self): |
|
226 | def start(self): | |
227 | """register dispatchers for streams""" |
|
227 | """register dispatchers for streams""" | |
228 | self.shell.exit_now = False |
|
|||
229 | if self.control_stream: |
|
228 | if self.control_stream: | |
230 | self.control_stream.on_recv(self.dispatch_control, copy=False) |
|
229 | self.control_stream.on_recv(self.dispatch_control, copy=False) | |
231 |
|
230 | |||
@@ -374,6 +373,12 b' class KernelBase(Configurable):' | |||||
374 |
|
373 | |||
375 | self._publish_status(u'idle', parent) |
|
374 | self._publish_status(u'idle', parent) | |
376 |
|
375 | |||
|
376 | def do_execute(self, code, silent, store_history=True, | |||
|
377 | user_experssions=None, allow_stdin=False): | |||
|
378 | """Execute user code. Must be overridden by subclasses. | |||
|
379 | """ | |||
|
380 | raise NotImplementedError | |||
|
381 | ||||
377 | def complete_request(self, stream, ident, parent): |
|
382 | def complete_request(self, stream, ident, parent): | |
378 | content = parent['content'] |
|
383 | content = parent['content'] | |
379 | code = content['code'] |
|
384 | code = content['code'] | |
@@ -385,6 +390,15 b' class KernelBase(Configurable):' | |||||
385 | matches, parent, ident) |
|
390 | matches, parent, ident) | |
386 | self.log.debug("%s", completion_msg) |
|
391 | self.log.debug("%s", completion_msg) | |
387 |
|
392 | |||
|
393 | def do_complete(self, code, cursor_pos): | |||
|
394 | """Override in subclasses to find completions. | |||
|
395 | """ | |||
|
396 | return {'matches' : [], | |||
|
397 | 'cursor_end' : cursor_pos, | |||
|
398 | 'cursor_start' : cursor_pos, | |||
|
399 | 'metadata' : {}, | |||
|
400 | 'status' : 'ok'} | |||
|
401 | ||||
388 | def inspect_request(self, stream, ident, parent): |
|
402 | def inspect_request(self, stream, ident, parent): | |
389 | content = parent['content'] |
|
403 | content = parent['content'] | |
390 |
|
404 | |||
@@ -396,6 +410,11 b' class KernelBase(Configurable):' | |||||
396 | reply_content, parent, ident) |
|
410 | reply_content, parent, ident) | |
397 | self.log.debug("%s", msg) |
|
411 | self.log.debug("%s", msg) | |
398 |
|
412 | |||
|
413 | def do_inspect(self, code, cursor_pos, detail_level=0): | |||
|
414 | """Override in subclasses to allow introspection. | |||
|
415 | """ | |||
|
416 | return {'status': 'ok', 'data':{}, 'metadata':{}, 'found':False} | |||
|
417 | ||||
399 | def history_request(self, stream, ident, parent): |
|
418 | def history_request(self, stream, ident, parent): | |
400 | # We need to pull these out, as passing **kwargs doesn't work with |
|
419 | # We need to pull these out, as passing **kwargs doesn't work with | |
401 | # unicode keys before Python 2.6.5. |
|
420 | # unicode keys before Python 2.6.5. | |
@@ -416,6 +435,12 b' class KernelBase(Configurable):' | |||||
416 | reply_content, parent, ident) |
|
435 | reply_content, parent, ident) | |
417 | self.log.debug("%s", msg) |
|
436 | self.log.debug("%s", msg) | |
418 |
|
437 | |||
|
438 | def do_history(self, hist_access_type, output, raw, session=None, start=None, | |||
|
439 | stop=None, n=None, pattern=None, unique=False): | |||
|
440 | """Override in subclasses to access history. | |||
|
441 | """ | |||
|
442 | return {'history': []} | |||
|
443 | ||||
419 | def connect_request(self, stream, ident, parent): |
|
444 | def connect_request(self, stream, ident, parent): | |
420 | if self._recorded_ports is not None: |
|
445 | if self._recorded_ports is not None: | |
421 | content = self._recorded_ports.copy() |
|
446 | content = self._recorded_ports.copy() | |
@@ -454,6 +479,12 b' class KernelBase(Configurable):' | |||||
454 | loop = ioloop.IOLoop.instance() |
|
479 | loop = ioloop.IOLoop.instance() | |
455 | loop.add_timeout(time.time()+0.1, loop.stop) |
|
480 | loop.add_timeout(time.time()+0.1, loop.stop) | |
456 |
|
481 | |||
|
482 | def do_shutdown(self, restart): | |||
|
483 | """Override in subclasses to do things when the frontend shuts down the | |||
|
484 | kernel. | |||
|
485 | """ | |||
|
486 | return {'status': 'ok', 'restart': restart} | |||
|
487 | ||||
457 | #--------------------------------------------------------------------------- |
|
488 | #--------------------------------------------------------------------------- | |
458 | # Engine methods |
|
489 | # Engine methods | |
459 | #--------------------------------------------------------------------------- |
|
490 | #--------------------------------------------------------------------------- | |
@@ -488,6 +519,11 b' class KernelBase(Configurable):' | |||||
488 |
|
519 | |||
489 | self._publish_status(u'idle', parent) |
|
520 | self._publish_status(u'idle', parent) | |
490 |
|
521 | |||
|
522 | def do_apply(self, content, bufs, msg_id, reply_metadata): | |||
|
523 | """Override in subclasses to support the IPython parallel framework. | |||
|
524 | """ | |||
|
525 | raise NotImplementedError | |||
|
526 | ||||
491 | #--------------------------------------------------------------------------- |
|
527 | #--------------------------------------------------------------------------- | |
492 | # Control messages |
|
528 | # Control messages | |
493 | #--------------------------------------------------------------------------- |
|
529 | #--------------------------------------------------------------------------- | |
@@ -513,6 +549,13 b' class KernelBase(Configurable):' | |||||
513 | self.session.send(stream, 'clear_reply', ident=idents, parent=parent, |
|
549 | self.session.send(stream, 'clear_reply', ident=idents, parent=parent, | |
514 | content = content) |
|
550 | content = content) | |
515 |
|
551 | |||
|
552 | def do_clear(self): | |||
|
553 | """Override in subclasses to clear the namespace | |||
|
554 | ||||
|
555 | This is only required for IPython.parallel. | |||
|
556 | """ | |||
|
557 | raise NotImplementedError | |||
|
558 | ||||
516 | #--------------------------------------------------------------------------- |
|
559 | #--------------------------------------------------------------------------- | |
517 | # Protected interface |
|
560 | # Protected interface | |
518 | #--------------------------------------------------------------------------- |
|
561 | #--------------------------------------------------------------------------- |
General Comments 0
You need to be logged in to leave comments.
Login now