Skip to content

Commit

Permalink
raw_input captured and working fine
Browse files Browse the repository at this point in the history
  • Loading branch information
omazapa authored and minrk committed Aug 17, 2011
1 parent eb57363 commit 6051b91
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions IPython/frontend/terminal/frontend.py
Expand Up @@ -27,6 +27,7 @@
import code
import zmq
import rlcompleter
import readline
import time


Expand Down Expand Up @@ -70,9 +71,9 @@ def __init__(self,kernelmanager):
self.msg_header = self.km.session.msg_header()

self.completer = completer.ClientCompleter(self,self.session,self.request_socket)
rlcompleter.readline.set_completer(self.completer.complete)
rlcompleter.readline.parse_and_bind("tab: complete")
rlcompleter.readline.parse_and_bind('set show-all-if-ambiguous on')
readline.set_completer(self.completer.complete)
readline.parse_and_bind("tab: complete")
readline.parse_and_bind('set show-all-if-ambiguous on')

history_path = os.path.expanduser('~/.ipython/history')
if os.path.isfile(history_path):
Expand Down Expand Up @@ -134,12 +135,14 @@ def _execute(self, source, hidden = True):
"""
self.km.xreq_channel.execute(source, hidden)
self.handle_xreq_channel()
self.handle_rep_channel()

def handle_xreq_channel(self):
# Give the kernel up to 0.5s to respond
for i in range(5):
if self.km.xreq_channel.was_called():
self.msg_xreq = self.km.xreq_channel.get_msg()
#print self.msg_xreq
if self.msg_header["session"] == self.msg_xreq["parent_header"]["session"] :
if self.msg_xreq["content"]["status"] == 'ok' :
if self.msg_xreq["msg_type"] == "complete_reply" :
Expand Down Expand Up @@ -186,9 +189,20 @@ def handle_sub_channel(self):

if sub_msg['msg_type'] == 'pyout' :
print >> sys.stdout,"Out[%i]:"%sub_msg["content"]["execution_count"], sub_msg["content"]["data"]
#print >> sys.stdout,"Out[%i]:"%self.msg_xreq["content"]["execution_count"], sub_msg["content"]["data"]
sys.stdout.flush()

def handle_rep_channel(self):
""" Method to capture raw_input
"""
if self.km.rep_channel.was_called() :
self.msg_rep = self.km.rep_channel.get_msg()
#print self.msg_rep
if self.msg_header["session"] == self.msg_rep["parent_header"]["session"] :
raw_data = raw_input(self.msg_rep["content"]["prompt"])
self.km.rep_channel.input(raw_data)




def start_frontend():
""" Entry point for application.
Expand Down

0 comments on commit 6051b91

Please sign in to comment.