Show More
@@ -240,9 +240,6 b' define([' | |||
|
240 | 240 | this.events.on('kernel_ready.Kernel', function(event, data) { |
|
241 | 241 | var kinfo = data.kernel.info_reply; |
|
242 | 242 | var langinfo = kinfo.language_info || {}; |
|
243 | if (!langinfo.name) { | |
|
244 | langinfo.name = kinfo.language; | |
|
245 | } | |
|
246 | 243 | that.metadata.language_info = langinfo; |
|
247 | 244 | // Mode 'null' should be plain, unhighlighted text. |
|
248 | 245 | var cm_mode = langinfo.codemirror_mode || langinfo.name || 'null'; |
@@ -102,16 +102,20 b' class V5toV4(Adapter):' | |||
|
102 | 102 | # shell channel |
|
103 | 103 | |
|
104 | 104 | def kernel_info_reply(self, msg): |
|
105 | v4c = {} | |
|
105 | 106 | content = msg['content'] |
|
106 | content.pop('banner', None) | |
|
107 | 107 | for key in ('language_version', 'protocol_version'): |
|
108 | 108 | if key in content: |
|
109 |
c |
|
|
110 |
if content. |
|
|
109 | v4c[key] = _version_str_to_list(content[key]) | |
|
110 | if content.get('implementation', '') == 'ipython' \ | |
|
111 | 111 | and 'implementation_version' in content: |
|
112 |
c |
|
|
113 | content.pop('implementation_version', None) | |
|
114 | content.setdefault("implmentation", content['language']) | |
|
112 | v4c['ipython_version'] = _version_str_to_list(content['implementation_version']) | |
|
113 | language_info = content.get('language_info', {}) | |
|
114 | language = language_info.get('name', '') | |
|
115 | v4c.setdefault('language', language) | |
|
116 | if 'version' in language_info: | |
|
117 | v4c.setdefault('language_version', _version_str_to_list(language_info['version'])) | |
|
118 | msg['content'] = v4c | |
|
115 | 119 | return msg |
|
116 | 120 | |
|
117 | 121 | def execute_request(self, msg): |
@@ -204,14 +208,23 b' class V4toV5(Adapter):' | |||
|
204 | 208 | |
|
205 | 209 | def kernel_info_reply(self, msg): |
|
206 | 210 | content = msg['content'] |
|
207 |
for key in ( |
|
|
211 | for key in ('protocol_version', 'ipython_version'): | |
|
208 | 212 | if key in content: |
|
209 |
content[key] = |
|
|
213 | content[key] = '.'.join(map(str, content[key])) | |
|
214 | ||
|
215 | content.setdefault('protocol_version', '4.1') | |
|
210 | 216 | |
|
211 | 217 | if content['language'].startswith('python') and 'ipython_version' in content: |
|
212 | 218 | content['implementation'] = 'ipython' |
|
213 | 219 | content['implementation_version'] = content.pop('ipython_version') |
|
214 | 220 | |
|
221 | language = content.pop('language') | |
|
222 | language_info = content.setdefault('language_info', {}) | |
|
223 | language_info.setdefault('name', language) | |
|
224 | if 'language_version' in content: | |
|
225 | language_version = '.'.join(map(str, content.pop('language_version'))) | |
|
226 | language_info.setdefault('version', language_version) | |
|
227 | ||
|
215 | 228 | content['banner'] = '' |
|
216 | 229 | return msg |
|
217 | 230 |
@@ -169,6 +169,26 b' class V4toV5TestCase(AdapterTest):' | |||
|
169 | 169 | text = v5c['data']['text/plain'] |
|
170 | 170 | self.assertEqual(text, '\n'.join([v4c['definition'], v4c['docstring']])) |
|
171 | 171 | |
|
172 | def test_kernel_info_reply(self): | |
|
173 | msg = self.msg("kernel_info_reply", { | |
|
174 | 'language': 'python', | |
|
175 | 'language_version': [2,8,0], | |
|
176 | 'ipython_version': [1,2,3], | |
|
177 | }) | |
|
178 | v4, v5 = self.adapt(msg) | |
|
179 | v4c = v4['content'] | |
|
180 | v5c = v5['content'] | |
|
181 | self.assertEqual(v5c, { | |
|
182 | 'protocol_version': '4.1', | |
|
183 | 'implementation': 'ipython', | |
|
184 | 'implementation_version': '1.2.3', | |
|
185 | 'language_info': { | |
|
186 | 'name': 'python', | |
|
187 | 'version': '2.8.0', | |
|
188 | }, | |
|
189 | 'banner' : '', | |
|
190 | }) | |
|
191 | ||
|
172 | 192 | # iopub channel |
|
173 | 193 | |
|
174 | 194 | def test_display_data(self): |
@@ -305,6 +325,29 b' class V5toV4TestCase(AdapterTest):' | |||
|
305 | 325 | self.assertEqual(sorted(v4c), ['found', 'oname']) |
|
306 | 326 | self.assertEqual(v4c['found'], False) |
|
307 | 327 | |
|
328 | def test_kernel_info_reply(self): | |
|
329 | msg = self.msg("kernel_info_reply", { | |
|
330 | 'protocol_version': '5.0', | |
|
331 | 'implementation': 'ipython', | |
|
332 | 'implementation_version': '1.2.3', | |
|
333 | 'language_info': { | |
|
334 | 'name': 'python', | |
|
335 | 'version': '2.8.0', | |
|
336 | 'mimetype': 'text/x-python', | |
|
337 | }, | |
|
338 | 'banner' : 'the banner', | |
|
339 | }) | |
|
340 | v5, v4 = self.adapt(msg) | |
|
341 | v4c = v4['content'] | |
|
342 | v5c = v5['content'] | |
|
343 | info = v5c['language_info'] | |
|
344 | self.assertEqual(v4c, { | |
|
345 | 'protocol_version': [5,0], | |
|
346 | 'language': 'python', | |
|
347 | 'language_version': [2,8,0], | |
|
348 | 'ipython_version': [1,2,3], | |
|
349 | }) | |
|
350 | ||
|
308 | 351 | # iopub channel |
|
309 | 352 | |
|
310 | 353 | def test_display_data(self): |
@@ -69,9 +69,10 b' class IPythonKernel(KernelBase):' | |||
|
69 | 69 | # Kernel info fields |
|
70 | 70 | implementation = 'ipython' |
|
71 | 71 | implementation_version = release.version |
|
72 |
language = |
|
|
73 | language_version = sys.version.split()[0] | |
|
74 | language_info = {'mimetype': 'text/x-python', | |
|
72 | language_info = { | |
|
73 | 'name': 'python', | |
|
74 | 'version': sys.version.split()[0], | |
|
75 | 'mimetype': 'text/x-python', | |
|
75 | 76 | 'codemirror_mode': {'name': 'ipython', |
|
76 | 77 | 'version': sys.version_info[0]}, |
|
77 | 78 | 'pygments_lexer': 'ipython%d' % (3 if PY3 else 2), |
@@ -455,8 +455,6 b' class Kernel(SingletonConfigurable):' | |||
|
455 | 455 | 'protocol_version': release.kernel_protocol_version, |
|
456 | 456 | 'implementation': self.implementation, |
|
457 | 457 | 'implementation_version': self.implementation_version, |
|
458 | 'language': self.language, | |
|
459 | 'language_version': self.language_version, | |
|
460 | 458 | 'language_info': self.language_info, |
|
461 | 459 | 'banner': self.banner, |
|
462 | 460 | } |
@@ -674,19 +674,20 b' Message type: ``kernel_info_reply``::' | |||
|
674 | 674 | # Implementation version number. |
|
675 | 675 | # The version number of the kernel's implementation |
|
676 | 676 | # (e.g. IPython.__version__ for the IPython kernel) |
|
677 |
'implementation_version': 'X.Y.Z', |
|
|
678 | ||
|
679 | # Programming language in which kernel is implemented. | |
|
680 | # Kernel included in IPython returns 'python'. | |
|
681 | 'language': str, | |
|
682 | ||
|
683 | # Language version number. | |
|
684 | # It is Python version number (e.g., '2.7.3') for the kernel | |
|
685 | # included in IPython. | |
|
686 | 'language_version': 'X.Y.Z', | |
|
677 | 'implementation_version': 'X.Y.Z', | |
|
687 | 678 | |
|
688 | 679 | # Information about the language of code for the kernel |
|
689 | 680 | 'language_info': { |
|
681 | # Name of the programming language in which kernel is implemented. | |
|
682 | # Kernel included in IPython returns 'python'. | |
|
683 | 'name': str, | |
|
684 | ||
|
685 | # Language version number. | |
|
686 | # It is Python version number (e.g., '2.7.3') for the kernel | |
|
687 | # included in IPython. | |
|
688 | 'version': 'X.Y.Z', | |
|
689 | ||
|
690 | # mimetype for script files in this language | |
|
690 | 691 | 'mimetype': str, |
|
691 | 692 | |
|
692 | 693 | # Pygments lexer, for highlighting |
@@ -725,6 +726,14 b' and `codemirror modes <http://codemirror.net/mode/index.html>`_ for those fields' | |||
|
725 | 726 | ``language_info``, ``implementation``, ``implementation_version``, ``banner`` |
|
726 | 727 | and ``help_links`` keys are added. |
|
727 | 728 | |
|
729 | .. versionchanged:: 5.0 | |
|
730 | ||
|
731 | ``language_version`` moved to ``language_info.version`` | |
|
732 | ||
|
733 | .. versionchanged:: 5.0 | |
|
734 | ||
|
735 | ``language`` moved to ``language_info.name`` | |
|
736 | ||
|
728 | 737 | .. _msging_shutdown: |
|
729 | 738 | |
|
730 | 739 | Kernel shutdown |
General Comments 0
You need to be logged in to leave comments.
Login now