Show More
@@ -11,21 +11,6 b' try:' | |||
|
11 | 11 | except ImportError: |
|
12 | 12 | from Queue import Queue, Empty # Py 2 |
|
13 | 13 | |
|
14 | from IPython.utils.py3compat import string_types, iteritems | |
|
15 | ||
|
16 | # some utilities to validate message structure, these might get moved elsewhere | |
|
17 | # if they prove to have more generic utility | |
|
18 | ||
|
19 | def validate_string_dict(dct): | |
|
20 | """Validate that the input is a dict with string keys and values. | |
|
21 | ||
|
22 | Raises ValueError if not.""" | |
|
23 | for k,v in iteritems(dct): | |
|
24 | if not isinstance(k, string_types): | |
|
25 | raise ValueError('key %r in dict must be a string' % k) | |
|
26 | if not isinstance(v, string_types): | |
|
27 | raise ValueError('value %r in dict must be a string' % v) | |
|
28 | ||
|
29 | 14 | |
|
30 | 15 | class ZMQSocketChannel(object): |
|
31 | 16 | """A ZMQ socket in a simple blocking API""" |
@@ -14,12 +14,10 b' import zmq' | |||
|
14 | 14 | # import ZMQError in top-level namespace, to avoid ugly attribute-error messages |
|
15 | 15 | # during garbage collection of threads at exit: |
|
16 | 16 | from zmq import ZMQError |
|
17 | from zmq.eventloop import ioloop, zmqstream | |
|
18 | 17 | |
|
19 | 18 | from IPython.core.release import kernel_protocol_version_info |
|
20 | 19 | |
|
21 | 20 | from .channelsabc import HBChannelABC |
|
22 | from IPython.utils.py3compat import string_types, iteritems | |
|
23 | 21 | |
|
24 | 22 | #----------------------------------------------------------------------------- |
|
25 | 23 | # Constants and exceptions |
@@ -30,23 +28,6 b' major_protocol_version = kernel_protocol_version_info[0]' | |||
|
30 | 28 | class InvalidPortNumber(Exception): |
|
31 | 29 | pass |
|
32 | 30 | |
|
33 | #----------------------------------------------------------------------------- | |
|
34 | # Utility functions | |
|
35 | #----------------------------------------------------------------------------- | |
|
36 | ||
|
37 | # some utilities to validate message structure, these might get moved elsewhere | |
|
38 | # if they prove to have more generic utility | |
|
39 | ||
|
40 | def validate_string_dict(dct): | |
|
41 | """Validate that the input is a dict with string keys and values. | |
|
42 | ||
|
43 | Raises ValueError if not.""" | |
|
44 | for k,v in iteritems(dct): | |
|
45 | if not isinstance(k, string_types): | |
|
46 | raise ValueError('key %r in dict must be a string' % k) | |
|
47 | if not isinstance(v, string_types): | |
|
48 | raise ValueError('value %r in dict must be a string' % v) | |
|
49 | ||
|
50 | 31 | |
|
51 | 32 | def make_shell_socket(context, identity, address): |
|
52 | 33 | socket = context.socket(zmq.DEALER) |
@@ -4,8 +4,8 b'' | |||
|
4 | 4 | # Distributed under the terms of the Modified BSD License. |
|
5 | 5 | |
|
6 | 6 | from __future__ import absolute_import |
|
7 |
from IPython.kernel.channels import |
|
|
8 | from IPython.utils.py3compat import string_types | |
|
7 | from IPython.kernel.channels import major_protocol_version | |
|
8 | from IPython.utils.py3compat import string_types, iteritems | |
|
9 | 9 | |
|
10 | 10 | import zmq |
|
11 | 11 | |
@@ -21,6 +21,20 b' from .clientabc import KernelClientABC' | |||
|
21 | 21 | from .connect import ConnectionFileMixin |
|
22 | 22 | |
|
23 | 23 | |
|
24 | # some utilities to validate message structure, these might get moved elsewhere | |
|
25 | # if they prove to have more generic utility | |
|
26 | ||
|
27 | def validate_string_dict(dct): | |
|
28 | """Validate that the input is a dict with string keys and values. | |
|
29 | ||
|
30 | Raises ValueError if not.""" | |
|
31 | for k,v in iteritems(dct): | |
|
32 | if not isinstance(k, string_types): | |
|
33 | raise ValueError('key %r in dict must be a string' % k) | |
|
34 | if not isinstance(v, string_types): | |
|
35 | raise ValueError('value %r in dict must be a string' % v) | |
|
36 | ||
|
37 | ||
|
24 | 38 | class KernelClient(ConnectionFileMixin): |
|
25 | 39 | """Communicates with a single kernel on any host via zmq channels. |
|
26 | 40 |
@@ -37,28 +37,11 b' class QtHBChannel(SuperQObject, HBChannel):' | |||
|
37 | 37 | |
|
38 | 38 | from IPython.core.release import kernel_protocol_version_info |
|
39 | 39 | |
|
40 | from IPython.utils.py3compat import string_types, iteritems | |
|
41 | ||
|
42 | 40 | major_protocol_version = kernel_protocol_version_info[0] |
|
43 | 41 | |
|
44 | 42 | class InvalidPortNumber(Exception): |
|
45 | 43 | pass |
|
46 | 44 | |
|
47 | # some utilities to validate message structure, these might get moved elsewhere | |
|
48 | # if they prove to have more generic utility | |
|
49 | ||
|
50 | ||
|
51 | def validate_string_dict(dct): | |
|
52 | """Validate that the input is a dict with string keys and values. | |
|
53 | ||
|
54 | Raises ValueError if not.""" | |
|
55 | for k,v in iteritems(dct): | |
|
56 | if not isinstance(k, string_types): | |
|
57 | raise ValueError('key %r in dict must be a string' % k) | |
|
58 | if not isinstance(v, string_types): | |
|
59 | raise ValueError('value %r in dict must be a string' % v) | |
|
60 | ||
|
61 | ||
|
62 | 45 | |
|
63 | 46 | class QtZMQSocketChannel(SuperQObject): |
|
64 | 47 | """A ZMQ socket emitting a Qt signal when a message is received.""" |
General Comments 0
You need to be logged in to leave comments.
Login now