Show More
@@ -1,13 +1,10 b'' | |||||
1 | """Test suite for our zeromq-based message specification. |
|
1 | """Test suite for our zeromq-based message specification.""" | |
2 | """ |
|
2 | ||
3 | #----------------------------------------------------------------------------- |
|
3 | # Copyright (c) IPython Development Team. | |
4 | # Copyright (C) 2010 The IPython Development Team |
|
4 | # Distributed under the terms of the Modified BSD License. | |
5 | # |
|
|||
6 | # Distributed under the terms of the BSD License. The full license is in |
|
|||
7 | # the file COPYING.txt, distributed as part of this software. |
|
|||
8 | #----------------------------------------------------------------------------- |
|
|||
9 |
|
5 | |||
10 | import re |
|
6 | import re | |
|
7 | from distutils.version import LooseVersion as V | |||
11 | from subprocess import PIPE |
|
8 | from subprocess import PIPE | |
12 | try: |
|
9 | try: | |
13 | from queue import Empty # Py 3 |
|
10 | from queue import Empty # Py 3 | |
@@ -60,8 +57,13 b' class Reference(HasTraits):' | |||||
60 | try: |
|
57 | try: | |
61 | setattr(self, key, d[key]) |
|
58 | setattr(self, key, d[key]) | |
62 | except TraitError as e: |
|
59 | except TraitError as e: | |
63 |
|
|
60 | assert False, str(e) | |
64 |
|
61 | |||
|
62 | class Version(Unicode): | |||
|
63 | def validate(self, obj, value): | |||
|
64 | min_version = self.default_value | |||
|
65 | if V(value) < V(min_version): | |||
|
66 | raise TraitError("bad version: %s < %s" % (value, min_version)) | |||
65 |
|
67 | |||
66 | class RMessage(Reference): |
|
68 | class RMessage(Reference): | |
67 | msg_id = Unicode() |
|
69 | msg_id = Unicode() | |
@@ -69,15 +71,18 b' class RMessage(Reference):' | |||||
69 | header = Dict() |
|
71 | header = Dict() | |
70 | parent_header = Dict() |
|
72 | parent_header = Dict() | |
71 | content = Dict() |
|
73 | content = Dict() | |
|
74 | ||||
|
75 | def check(self, d): | |||
|
76 | super(RMessage, self).check(d) | |||
|
77 | RHeader().check(self.header) | |||
|
78 | RHeader().check(self.parent_header) | |||
72 |
|
79 | |||
73 | class RHeader(Reference): |
|
80 | class RHeader(Reference): | |
74 | msg_id = Unicode() |
|
81 | msg_id = Unicode() | |
75 | msg_type = Unicode() |
|
82 | msg_type = Unicode() | |
76 | session = Unicode() |
|
83 | session = Unicode() | |
77 | username = Unicode() |
|
84 | username = Unicode() | |
78 |
|
85 | version = Version('5.0') | ||
79 | class RContent(Reference): |
|
|||
80 | status = Enum((u'ok', u'error')) |
|
|||
81 |
|
86 | |||
82 |
|
87 | |||
83 | class ExecuteReply(Reference): |
|
88 | class ExecuteReply(Reference): | |
@@ -126,7 +131,7 b' class OInfoReply(Reference):' | |||||
126 | source = Unicode() |
|
131 | source = Unicode() | |
127 |
|
132 | |||
128 | def check(self, d): |
|
133 | def check(self, d): | |
129 | Reference.check(self, d) |
|
134 | super(OInfoReply, self).check(d) | |
130 | if d['argspec'] is not None: |
|
135 | if d['argspec'] is not None: | |
131 | ArgSpec().check(d['argspec']) |
|
136 | ArgSpec().check(d['argspec']) | |
132 |
|
137 | |||
@@ -146,22 +151,12 b' class CompleteReply(Reference):' | |||||
146 | matches = List(Unicode) |
|
151 | matches = List(Unicode) | |
147 |
|
152 | |||
148 |
|
153 | |||
149 | def Version(num, trait=Integer): |
|
|||
150 | return List(trait, default_value=[0] * num, minlen=num, maxlen=num) |
|
|||
151 |
|
||||
152 |
|
||||
153 | class KernelInfoReply(Reference): |
|
154 | class KernelInfoReply(Reference): | |
154 |
|
155 | protocol_version = Version('5.0') | ||
155 |
|
|
156 | ipython_version = Version('2.0') | |
156 |
|
|
157 | language_version = Version('2.7') | |
157 | language_version = Version(3) |
|
|||
158 | language = Unicode() |
|
158 | language = Unicode() | |
159 |
|
159 | |||
160 | def _ipython_version_changed(self, name, old, new): |
|
|||
161 | for v in new: |
|
|||
162 | assert isinstance(v, int) or isinstance(v, string_types), \ |
|
|||
163 | 'expected int or string as version component, got {0!r}'.format(v) |
|
|||
164 |
|
||||
165 |
|
160 | |||
166 | # IOPub messages |
|
161 | # IOPub messages | |
167 |
|
162 | |||
@@ -210,6 +205,7 b' references = {' | |||||
210 | 'pyerr' : PyErr(), |
|
205 | 'pyerr' : PyErr(), | |
211 | 'stream' : Stream(), |
|
206 | 'stream' : Stream(), | |
212 | 'display_data' : DisplayData(), |
|
207 | 'display_data' : DisplayData(), | |
|
208 | 'header' : RHeader(), | |||
213 | } |
|
209 | } | |
214 | """ |
|
210 | """ | |
215 | Specifications of `content` part of the reply messages. |
|
211 | Specifications of `content` part of the reply messages. |
@@ -1,12 +1,11 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 | """An interactive kernel that talks to frontends over 0MQ.""" |
|
2 | """An interactive kernel that talks to frontends over 0MQ.""" | |
3 |
|
3 | |||
4 | #----------------------------------------------------------------------------- |
|
4 | # Copyright (c) IPython Development Team. | |
5 | # Imports |
|
5 | # Distributed under the terms of the Modified BSD License. | |
6 | #----------------------------------------------------------------------------- |
|
6 | ||
7 | from __future__ import print_function |
|
7 | from __future__ import print_function | |
8 |
|
8 | |||
9 | # Standard library imports |
|
|||
10 | import sys |
|
9 | import sys | |
11 | import time |
|
10 | import time | |
12 | import traceback |
|
11 | import traceback | |
@@ -18,12 +17,10 b' from signal import (' | |||||
18 | signal, default_int_handler, SIGINT |
|
17 | signal, default_int_handler, SIGINT | |
19 | ) |
|
18 | ) | |
20 |
|
19 | |||
21 | # System library imports |
|
|||
22 | import zmq |
|
20 | import zmq | |
23 | from zmq.eventloop import ioloop |
|
21 | from zmq.eventloop import ioloop | |
24 | from zmq.eventloop.zmqstream import ZMQStream |
|
22 | from zmq.eventloop.zmqstream import ZMQStream | |
25 |
|
23 | |||
26 | # Local imports |
|
|||
27 | from IPython.config.configurable import Configurable |
|
24 | from IPython.config.configurable import Configurable | |
28 | from IPython.core.error import StdinNotImplementedError |
|
25 | from IPython.core.error import StdinNotImplementedError | |
29 | from IPython.core import release |
|
26 | from IPython.core import release | |
@@ -44,9 +41,9 b' from .zmqshell import ZMQInteractiveShell' | |||||
44 | # Main kernel class |
|
41 | # Main kernel class | |
45 | #----------------------------------------------------------------------------- |
|
42 | #----------------------------------------------------------------------------- | |
46 |
|
43 | |||
47 |
protocol_version = |
|
44 | protocol_version = release.kernel_protocol_version | |
48 |
ipython_version = |
|
45 | ipython_version = release.version | |
49 |
language_version = |
|
46 | language_version = sys.version.split()[0] | |
50 |
|
47 | |||
51 |
|
48 | |||
52 | class Kernel(Configurable): |
|
49 | class Kernel(Configurable): |
General Comments 0
You need to be logged in to leave comments.
Login now