From c9b58bdcf66df2223bd5b3df56e09066385078f8 2011-12-06 01:40:56 From: Thomas Kluyver Date: 2011-12-06 01:40:56 Subject: [PATCH] Replace tabs with spaces --- diff --git a/IPython/frontend/terminal/completer.py b/IPython/frontend/terminal/completer.py index 91e800e..e85116b 100644 --- a/IPython/frontend/terminal/completer.py +++ b/IPython/frontend/terminal/completer.py @@ -18,35 +18,35 @@ class ClientCompleter2p(object): def complete_request(self,text): line = readline.get_line_buffer() #msg_id = self.km.xreq_channel.complete(text=text,line=line)#this method is not working, the code not continue - msg = self.km.session.send(self.km.xreq_channel.socket, + msg = self.km.session.send(self.km.xreq_channel.socket, 'complete_request', dict(text=text, line=line)) # send completion request to kernel # Give the kernel up to 0.5s to respond msg_matches = None for i in range(5): - if self.km.xreq_channel.was_called(): - msg_xreq = self.km.xreq_channel.get_msg() - if msg["header"]['session'] == msg_xreq["parent_header"]['session'] : - if msg_xreq["content"]["status"] == 'ok' : - if msg_xreq["msg_type"] == "complete_reply" : - msg_matches = msg_xreq["content"]["matches"] - #break + if self.km.xreq_channel.was_called(): + msg_xreq = self.km.xreq_channel.get_msg() + if msg["header"]['session'] == msg_xreq["parent_header"]['session'] : + if msg_xreq["content"]["status"] == 'ok' : + if msg_xreq["msg_type"] == "complete_reply" : + msg_matches = msg_xreq["content"]["matches"] + #break time.sleep(0.1) return msg_matches def complete(self, text, state): if state == 0 : - self.matches = self.complete_request(text) - + self.matches = self.complete_request(text) + if self.matches is None: self.matches = [] print('WARNING: Kernel timeout on tab completion.') #print self.matches - try: - return self.matches[state] - except IndexError: - return None + try: + return self.matches[state] + except IndexError: + return None diff --git a/IPython/frontend/terminal/frontend.py b/IPython/frontend/terminal/frontend.py index 65d41c2..af25059 100755 --- a/IPython/frontend/terminal/frontend.py +++ b/IPython/frontend/terminal/frontend.py @@ -124,7 +124,7 @@ class Frontend(object): while True: answer = raw_input('\nDo you really want to exit ([y]/n)?') if answer == 'y' or answer == '' : - self.km.shutdown_kernel() + self.km.shutdown_kernel() sys.exit() elif answer == 'n': break @@ -141,23 +141,22 @@ class Frontend(object): 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() - if self.msg_header["session"] == self.msg_xreq["parent_header"]["session"] : - if self.msg_xreq["content"]["status"] == 'ok' : - if self.msg_xreq["msg_type"] == "execute_reply" : - self.handle_sub_channel() - self.prompt_count = self.msg_xreq["content"]["execution_count"]+1 - + if self.km.xreq_channel.was_called(): + self.msg_xreq = self.km.xreq_channel.get_msg() + if self.msg_header["session"] == self.msg_xreq["parent_header"]["session"] : + if self.msg_xreq["content"]["status"] == 'ok' : + if self.msg_xreq["msg_type"] == "execute_reply" : + self.handle_sub_channel() + self.prompt_count = self.msg_xreq["content"]["execution_count"]+1 + else: - etb = self.msg_xreq["content"]["traceback"] - print >> sys.stderr, etb[0] - print >> sys.stderr, etb[1] - print >> sys.stderr, etb[2] - self.prompt_count = self.msg_xreq["content"]["execution_count"]+1 + etb = self.msg_xreq["content"]["traceback"] + print >> sys.stderr, etb[0] + print >> sys.stderr, etb[1] + print >> sys.stderr, etb[2] + self.prompt_count = self.msg_xreq["content"]["execution_count"]+1 break - time.sleep(0.1) - + time.sleep(0.1) def handle_sub_channel(self): @@ -195,11 +194,11 @@ class Frontend(object): """ Method to capture raw_input """ if self.km.rep_channel.was_called() : - self.msg_rep = self.km.rep_channel.get_msg() - 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) - + self.msg_rep = self.km.rep_channel.get_msg() + 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) + @@ -280,4 +279,4 @@ def start_frontend(): if __name__ == "__main__" : frontend=start_frontend() - frontend.start() \ No newline at end of file + frontend.start()