Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions ipykernel/ipkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def do_execute(self, code, silent, store_history=True,
if res.success:
reply_content[u'status'] = u'ok'
elif isinstance(err, KeyboardInterrupt):
reply_content[u'status'] = u'abort'
reply_content[u'status'] = u'aborted'
else:
reply_content[u'status'] = u'error'

Expand Down Expand Up @@ -296,7 +296,10 @@ def do_history(self, hist_access_type, output, raw, session=None, start=None,
else:
hist = []

return {'history' : list(hist)}
return {
'status': 'ok',
'history' : list(hist),
}

def do_shutdown(self, restart):
self.shell.exit_now = True
Expand Down
9 changes: 6 additions & 3 deletions ipykernel/kernelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,14 @@ def do_history(self, hist_access_type, output, raw, session=None, start=None,
stop=None, n=None, pattern=None, unique=False):
"""Override in subclasses to access history.
"""
return {'history': []}
return {'status': 'ok', 'history': []}

def connect_request(self, stream, ident, parent):
if self._recorded_ports is not None:
content = self._recorded_ports.copy()
else:
content = {}
content['status'] = 'ok'
msg = self.session.send(stream, 'connect_reply',
content, parent, ident)
self.log.debug("%s", msg)
Expand All @@ -490,8 +491,10 @@ def kernel_info(self):
}

def kernel_info_request(self, stream, ident, parent):
content = {'status': 'ok'}
content.update(self.kernel_info)
msg = self.session.send(stream, 'kernel_info_reply',
self.kernel_info, parent, ident)
content, parent, ident)
self.log.debug("%s", msg)

def comm_info_request(self, stream, ident, parent):
Expand All @@ -507,7 +510,7 @@ def comm_info_request(self, stream, ident, parent):
}
else:
comms = {}
reply_content = dict(comms=comms)
reply_content = dict(comms=comms, status='ok')
msg = self.session.send(stream, 'comm_info_reply',
reply_content, parent, ident)
self.log.debug("%s", msg)
Expand Down
31 changes: 20 additions & 11 deletions ipykernel/tests/test_message_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,14 @@ def _data_changed(self, name, old, new):
assert mime_pat.match(k)
nt.assert_is_instance(v, string_types)


# shell replies
class Reply(Reference):
status = Enum((u'ok', u'error'), default_value=u'ok')

class ExecuteReply(Reference):

class ExecuteReply(Reply):
execution_count = Integer()
status = Enum((u'ok', u'error'), default_value=u'ok')

def check(self, d):
Reference.check(self, d)
Expand All @@ -117,18 +120,18 @@ def check(self, d):
ExecuteReplyError().check(d)


class ExecuteReplyOkay(Reference):
payload = List(Dict())
class ExecuteReplyOkay(Reply):
status = Enum(('ok',))
user_expressions = Dict()


class ExecuteReplyError(Reference):
class ExecuteReplyError(Reply):
ename = Unicode()
evalue = Unicode()
traceback = List(Unicode())


class InspectReply(MimeBundle):
class InspectReply(Reply, MimeBundle):
found = Bool()


Expand All @@ -143,17 +146,19 @@ class Status(Reference):
execution_state = Enum((u'busy', u'idle', u'starting'), default_value=u'busy')


class CompleteReply(Reference):
class CompleteReply(Reply):
matches = List(Unicode())
cursor_start = Integer()
cursor_end = Integer()
status = Unicode()


class LanguageInfo(Reference):
name = Unicode('python')
version = Unicode(sys.version.split()[0])

class KernelInfoReply(Reference):

class KernelInfoReply(Reply):
protocol_version = Version(min='5.0')
implementation = Unicode('ipython')
implementation_version = Version(min='2.1')
Expand All @@ -173,9 +178,10 @@ class ConnectReply(Reference):
hb_port = Integer()


class CommInfoReply(Reference):
class CommInfoReply(Reply):
comms = Dict()


class IsCompleteReply(Reference):
status = Enum((u'complete', u'incomplete', u'invalid', u'unknown'), default_value=u'complete')

Expand All @@ -184,6 +190,7 @@ def check(self, d):
if d['status'] == 'incomplete':
IsCompleteReplyIncomplete().check(d)


class IsCompleteReplyIncomplete(Reference):
indent = Unicode()

Expand All @@ -195,7 +202,9 @@ class ExecuteInput(Reference):
execution_count = Integer()


Error = ExecuteReplyError
class Error(ExecuteReplyError):
"""Errors are the same as ExecuteReply, but without status"""
status = None # no status field


class Stream(Reference):
Expand All @@ -211,7 +220,7 @@ class ExecuteResult(MimeBundle):
execution_count = Integer()


class HistoryReply(Reference):
class HistoryReply(Reply):
history = List(List())


Expand Down