##// END OF EJS Templates
Replace tabs with spaces
Thomas Kluyver -
Show More
@@ -18,35 +18,35 b' class ClientCompleter2p(object):'
18 def complete_request(self,text):
18 def complete_request(self,text):
19 line = readline.get_line_buffer()
19 line = readline.get_line_buffer()
20 #msg_id = self.km.xreq_channel.complete(text=text,line=line)#this method is not working, the code not continue
20 #msg_id = self.km.xreq_channel.complete(text=text,line=line)#this method is not working, the code not continue
21 msg = self.km.session.send(self.km.xreq_channel.socket,
21 msg = self.km.session.send(self.km.xreq_channel.socket,
22 'complete_request',
22 'complete_request',
23 dict(text=text, line=line))
23 dict(text=text, line=line))
24 # send completion request to kernel
24 # send completion request to kernel
25 # Give the kernel up to 0.5s to respond
25 # Give the kernel up to 0.5s to respond
26 msg_matches = None
26 msg_matches = None
27 for i in range(5):
27 for i in range(5):
28 if self.km.xreq_channel.was_called():
28 if self.km.xreq_channel.was_called():
29 msg_xreq = self.km.xreq_channel.get_msg()
29 msg_xreq = self.km.xreq_channel.get_msg()
30 if msg["header"]['session'] == msg_xreq["parent_header"]['session'] :
30 if msg["header"]['session'] == msg_xreq["parent_header"]['session'] :
31 if msg_xreq["content"]["status"] == 'ok' :
31 if msg_xreq["content"]["status"] == 'ok' :
32 if msg_xreq["msg_type"] == "complete_reply" :
32 if msg_xreq["msg_type"] == "complete_reply" :
33 msg_matches = msg_xreq["content"]["matches"]
33 msg_matches = msg_xreq["content"]["matches"]
34 #break
34 #break
35 time.sleep(0.1)
35 time.sleep(0.1)
36 return msg_matches
36 return msg_matches
37
37
38 def complete(self, text, state):
38 def complete(self, text, state):
39 if state == 0 :
39 if state == 0 :
40 self.matches = self.complete_request(text)
40 self.matches = self.complete_request(text)
41
41
42 if self.matches is None:
42 if self.matches is None:
43 self.matches = []
43 self.matches = []
44 print('WARNING: Kernel timeout on tab completion.')
44 print('WARNING: Kernel timeout on tab completion.')
45 #print self.matches
45 #print self.matches
46 try:
46 try:
47 return self.matches[state]
47 return self.matches[state]
48 except IndexError:
48 except IndexError:
49 return None
49 return None
50
50
51
51
52
52
@@ -124,7 +124,7 b' class Frontend(object):'
124 while True:
124 while True:
125 answer = raw_input('\nDo you really want to exit ([y]/n)?')
125 answer = raw_input('\nDo you really want to exit ([y]/n)?')
126 if answer == 'y' or answer == '' :
126 if answer == 'y' or answer == '' :
127 self.km.shutdown_kernel()
127 self.km.shutdown_kernel()
128 sys.exit()
128 sys.exit()
129 elif answer == 'n':
129 elif answer == 'n':
130 break
130 break
@@ -141,23 +141,22 b' class Frontend(object):'
141 def handle_xreq_channel(self):
141 def handle_xreq_channel(self):
142 # Give the kernel up to 0.5s to respond
142 # Give the kernel up to 0.5s to respond
143 for i in range(5):
143 for i in range(5):
144 if self.km.xreq_channel.was_called():
144 if self.km.xreq_channel.was_called():
145 self.msg_xreq = self.km.xreq_channel.get_msg()
145 self.msg_xreq = self.km.xreq_channel.get_msg()
146 if self.msg_header["session"] == self.msg_xreq["parent_header"]["session"] :
146 if self.msg_header["session"] == self.msg_xreq["parent_header"]["session"] :
147 if self.msg_xreq["content"]["status"] == 'ok' :
147 if self.msg_xreq["content"]["status"] == 'ok' :
148 if self.msg_xreq["msg_type"] == "execute_reply" :
148 if self.msg_xreq["msg_type"] == "execute_reply" :
149 self.handle_sub_channel()
149 self.handle_sub_channel()
150 self.prompt_count = self.msg_xreq["content"]["execution_count"]+1
150 self.prompt_count = self.msg_xreq["content"]["execution_count"]+1
151
151
152 else:
152 else:
153 etb = self.msg_xreq["content"]["traceback"]
153 etb = self.msg_xreq["content"]["traceback"]
154 print >> sys.stderr, etb[0]
154 print >> sys.stderr, etb[0]
155 print >> sys.stderr, etb[1]
155 print >> sys.stderr, etb[1]
156 print >> sys.stderr, etb[2]
156 print >> sys.stderr, etb[2]
157 self.prompt_count = self.msg_xreq["content"]["execution_count"]+1
157 self.prompt_count = self.msg_xreq["content"]["execution_count"]+1
158 break
158 break
159 time.sleep(0.1)
159 time.sleep(0.1)
160
161
160
162
161
163 def handle_sub_channel(self):
162 def handle_sub_channel(self):
@@ -195,11 +194,11 b' class Frontend(object):'
195 """ Method to capture raw_input
194 """ Method to capture raw_input
196 """
195 """
197 if self.km.rep_channel.was_called() :
196 if self.km.rep_channel.was_called() :
198 self.msg_rep = self.km.rep_channel.get_msg()
197 self.msg_rep = self.km.rep_channel.get_msg()
199 if self.msg_header["session"] == self.msg_rep["parent_header"]["session"] :
198 if self.msg_header["session"] == self.msg_rep["parent_header"]["session"] :
200 raw_data = raw_input(self.msg_rep["content"]["prompt"])
199 raw_data = raw_input(self.msg_rep["content"]["prompt"])
201 self.km.rep_channel.input(raw_data)
200 self.km.rep_channel.input(raw_data)
202
201
203
202
204
203
205
204
@@ -280,4 +279,4 b' def start_frontend():'
280
279
281 if __name__ == "__main__" :
280 if __name__ == "__main__" :
282 frontend=start_frontend()
281 frontend=start_frontend()
283 frontend.start() No newline at end of file
282 frontend.start()
General Comments 0
You need to be logged in to leave comments. Login now