Show More
@@ -117,25 +117,25 b' class Frontend(object):' | |||||
117 |
|
117 | |||
118 | See parent class :meth:`execute` docstring for full details. |
|
118 | See parent class :meth:`execute` docstring for full details. | |
119 | """ |
|
119 | """ | |
120 |
msg_id = self.km. |
|
120 | msg_id = self.km.shell_channel.execute(source, hidden) | |
121 |
while not self.km. |
|
121 | while not self.km.shell_channel.msg_ready(): | |
122 | try: |
|
122 | try: | |
123 |
self.handle_ |
|
123 | self.handle_stdin_channel(timeout=0.1) | |
124 | except Empty: |
|
124 | except Empty: | |
125 | pass |
|
125 | pass | |
126 | self.handle_execute_reply(msg_id) |
|
126 | self.handle_execute_reply(msg_id) | |
127 |
|
127 | |||
128 | def handle_execute_reply(self, msg_id): |
|
128 | def handle_execute_reply(self, msg_id): | |
129 |
msg |
|
129 | msg = self.km.shell_channel.get_msg() | |
130 |
if msg |
|
130 | if msg["parent_header"]["msg_id"] == msg_id: | |
131 |
if msg |
|
131 | if msg["content"]["status"] == 'ok' : | |
132 | self.handle_sub_channel() |
|
132 | self.handle_sub_channel() | |
133 |
|
133 | |||
134 |
elif msg |
|
134 | elif msg["content"]["status"] == 'error': | |
135 |
for frame in msg |
|
135 | for frame in msg["content"]["traceback"]: | |
136 | print(frame, file=sys.stderr) |
|
136 | print(frame, file=sys.stderr) | |
137 |
|
137 | |||
138 |
self.prompt_count = msg |
|
138 | self.prompt_count = msg["content"]["execution_count"] + 1 | |
139 |
|
139 | |||
140 |
|
140 | |||
141 | def handle_sub_channel(self): |
|
141 | def handle_sub_channel(self): | |
@@ -169,13 +169,13 b' class Frontend(object):' | |||||
169 | file=sys.stdout) |
|
169 | file=sys.stdout) | |
170 | sys.stdout.flush() |
|
170 | sys.stdout.flush() | |
171 |
|
171 | |||
172 |
def handle_ |
|
172 | def handle_stdin_channel(self, timeout=0.1): | |
173 | """ Method to capture raw_input |
|
173 | """ Method to capture raw_input | |
174 | """ |
|
174 | """ | |
175 |
msg_rep = self.km. |
|
175 | msg_rep = self.km.stdin_channel.get_msg(timeout=timeout) | |
176 | if self.session_id == msg_rep["parent_header"]["session"] : |
|
176 | if self.session_id == msg_rep["parent_header"]["session"] : | |
177 | raw_data = raw_input(msg_rep["content"]["prompt"]) |
|
177 | raw_data = raw_input(msg_rep["content"]["prompt"]) | |
178 |
self.km. |
|
178 | self.km.stdin_channel.input(raw_data) | |
179 |
|
179 | |||
180 |
|
180 | |||
181 |
|
181 | |||
@@ -195,11 +195,11 b' def start_frontend():' | |||||
195 | If the IP address is something other than localhost, then \ |
|
195 | If the IP address is something other than localhost, then \ | |
196 | Consoles on other machines will be able to connect\ |
|
196 | Consoles on other machines will be able to connect\ | |
197 | to the Kernel, so be careful!") |
|
197 | to the Kernel, so be careful!") | |
198 |
kgroup.add_argument('-- |
|
198 | kgroup.add_argument('--shell', type=int, metavar='PORT', default=0, | |
199 | help='set the XREQ channel port [default random]') |
|
199 | help='set the XREQ channel port [default random]') | |
200 |
kgroup.add_argument('-- |
|
200 | kgroup.add_argument('--iopub', type=int, metavar='PORT', default=0, | |
201 | help='set the SUB channel port [default random]') |
|
201 | help='set the SUB channel port [default random]') | |
202 |
kgroup.add_argument('-- |
|
202 | kgroup.add_argument('--stdin', type=int, metavar='PORT', default=0, | |
203 | help='set the REP channel port [default random]') |
|
203 | help='set the REP channel port [default random]') | |
204 | kgroup.add_argument('--hb', type=int, metavar='PORT', default=0, |
|
204 | kgroup.add_argument('--hb', type=int, metavar='PORT', default=0, | |
205 | help='set the heartbeat port [default random]') |
|
205 | help='set the heartbeat port [default random]') | |
@@ -231,21 +231,15 b' def start_frontend():' | |||||
231 | colors=None |
|
231 | colors=None | |
232 |
|
232 | |||
233 | # Create a KernelManager and start a kernel. |
|
233 | # Create a KernelManager and start a kernel. | |
234 |
kernel_manager = KernelManager( |
|
234 | kernel_manager = KernelManager(shell_address=(args.ip, args.shell), | |
235 |
sub_address=(args.ip, args. |
|
235 | sub_address=(args.ip, args.iopub), | |
236 |
|
|
236 | stdin_address=(args.ip, args.stdin), | |
237 | hb_address=(args.ip, args.hb)) |
|
237 | hb_address=(args.ip, args.hb)) | |
238 | if not args.existing: |
|
238 | if not args.existing: | |
239 | # if not args.ip in LOCAL_IPS+ALL_ALIAS: |
|
239 | # if not args.ip in LOCAL_IPS+ALL_ALIAS: | |
240 | # raise ValueError("Must bind a local ip, such as: %s"%LOCAL_IPS) |
|
240 | # raise ValueError("Must bind a local ip, such as: %s"%LOCAL_IPS) | |
241 |
|
241 | |||
242 | kwargs = dict(ip=args.ip) |
|
242 | kwargs = dict(ip=args.ip, ipython=True) | |
243 | if args.pure: |
|
|||
244 | kwargs['ipython']=False |
|
|||
245 | else: |
|
|||
246 | kwargs['colors']=colors |
|
|||
247 | if args.pylab: |
|
|||
248 | kwargs['pylab']=args.pylab |
|
|||
249 | kernel_manager.start_kernel(**kwargs) |
|
243 | kernel_manager.start_kernel(**kwargs) | |
250 |
|
244 | |||
251 |
|
245 |
@@ -106,7 +106,7 b' class BlockingShellSocketChannel(ShellSocketChannel):' | |||||
106 | class BlockingStdInSocketChannel(StdInSocketChannel): |
|
106 | class BlockingStdInSocketChannel(StdInSocketChannel): | |
107 |
|
107 | |||
108 | def __init__(self, context, session, address=None): |
|
108 | def __init__(self, context, session, address=None): | |
109 |
super(Blocking |
|
109 | super(BlockingStdInSocketChannel, self).__init__(context, session, address) | |
110 | self._in_queue = Queue() |
|
110 | self._in_queue = Queue() | |
111 |
|
111 | |||
112 | def call_handlers(self, msg): |
|
112 | def call_handlers(self, msg): |
General Comments 0
You need to be logged in to leave comments.
Login now