Show More
@@ -6,14 +6,15 b'' | |||||
6 |
|
6 | |||
7 | from __future__ import print_function |
|
7 | from __future__ import print_function | |
8 |
|
8 | |||
|
9 | import base64 | |||
9 | import bdb |
|
10 | import bdb | |
10 | import signal |
|
11 | import signal | |
11 | import os |
|
12 | import os | |
12 | import sys |
|
13 | import sys | |
13 | import time |
|
14 | import time | |
14 | import subprocess |
|
15 | import subprocess | |
|
16 | from getpass import getpass | |||
15 | from io import BytesIO |
|
17 | from io import BytesIO | |
16 | import base64 |
|
|||
17 |
|
18 | |||
18 | try: |
|
19 | try: | |
19 | from queue import Empty # Py 3 |
|
20 | from queue import Empty # Py 3 | |
@@ -171,7 +172,7 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):' | |||||
171 | self._execution_state = "busy" |
|
172 | self._execution_state = "busy" | |
172 | while self._execution_state != 'idle' and self.client.is_alive(): |
|
173 | while self._execution_state != 'idle' and self.client.is_alive(): | |
173 | try: |
|
174 | try: | |
174 |
self.handle_ |
|
175 | self.handle_input_request(msg_id, timeout=0.05) | |
175 | except Empty: |
|
176 | except Empty: | |
176 | # display intermediate print statements, etc. |
|
177 | # display intermediate print statements, etc. | |
177 | self.handle_iopub(msg_id) |
|
178 | self.handle_iopub(msg_id) | |
@@ -327,13 +328,13 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):' | |||||
327 | def handle_image_callable(self, data, mime): |
|
328 | def handle_image_callable(self, data, mime): | |
328 | self.callable_image_handler(data) |
|
329 | self.callable_image_handler(data) | |
329 |
|
330 | |||
330 |
def handle_ |
|
331 | def handle_input_request(self, msg_id, timeout=0.1): | |
331 | """ Method to capture raw_input |
|
332 | """ Method to capture raw_input | |
332 | """ |
|
333 | """ | |
333 |
|
|
334 | req = self.client.stdin_channel.get_msg(timeout=timeout) | |
334 | # in case any iopub came while we were waiting: |
|
335 | # in case any iopub came while we were waiting: | |
335 | self.handle_iopub(msg_id) |
|
336 | self.handle_iopub(msg_id) | |
336 |
if msg_id == |
|
337 | if msg_id == req["parent_header"].get("msg_id"): | |
337 | # wrap SIGINT handler |
|
338 | # wrap SIGINT handler | |
338 | real_handler = signal.getsignal(signal.SIGINT) |
|
339 | real_handler = signal.getsignal(signal.SIGINT) | |
339 | def double_int(sig,frame): |
|
340 | def double_int(sig,frame): | |
@@ -342,9 +343,10 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):' | |||||
342 | real_handler(sig,frame) |
|
343 | real_handler(sig,frame) | |
343 | raise KeyboardInterrupt |
|
344 | raise KeyboardInterrupt | |
344 | signal.signal(signal.SIGINT, double_int) |
|
345 | signal.signal(signal.SIGINT, double_int) | |
345 |
|
346 | content = req['content'] | ||
|
347 | read = getpass if content.get('password', False) else input | |||
346 | try: |
|
348 | try: | |
347 |
raw_data = |
|
349 | raw_data = read(content["prompt"]) | |
348 | except EOFError: |
|
350 | except EOFError: | |
349 | # turn EOFError into EOF character |
|
351 | # turn EOFError into EOF character | |
350 | raw_data = '\x04' |
|
352 | raw_data = '\x04' |
General Comments 0
You need to be logged in to leave comments.
Login now