##// END OF EJS Templates
rebased and updated to master
MinRK -
Show More
@@ -81,9 +81,9 b' class Frontend(object):'
81
81
82 try:
82 try:
83 print()
83 print()
84 self._splitter.push(raw_input(' In[%i]: '%self.prompt_count+self.code))
84 self._splitter.push(raw_input('In [%i]: '%self.prompt_count+self.code))
85 while self._splitter.push_accepts_more():
85 while self._splitter.push_accepts_more():
86 self.code = raw_input(' .....: '+' '*self._splitter.indent_spaces)
86 self.code = raw_input('.....: '+' '*self._splitter.indent_spaces)
87 self._splitter.push(' '*self._splitter.indent_spaces+self.code)
87 self._splitter.push(' '*self._splitter.indent_spaces+self.code)
88 self._execute(self._splitter.source,False)
88 self._execute(self._splitter.source,False)
89 self._splitter.reset()
89 self._splitter.reset()
@@ -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.xreq_channel.execute(source, hidden)
120 msg_id = self.km.shell_channel.execute(source, hidden)
121 while not self.km.xreq_channel.msg_ready():
121 while not self.km.shell_channel.msg_ready():
122 try:
122 try:
123 self.handle_rep_channel(timeout=0.1)
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_xreq = self.km.xreq_channel.get_msg()
129 msg = self.km.shell_channel.get_msg()
130 if msg_xreq["parent_header"]["msg_id"] == msg_id:
130 if msg["parent_header"]["msg_id"] == msg_id:
131 if msg_xreq["content"]["status"] == 'ok' :
131 if msg["content"]["status"] == 'ok' :
132 self.handle_sub_channel()
132 self.handle_sub_channel()
133
133
134 elif msg_xreq["content"]["status"] == 'error':
134 elif msg["content"]["status"] == 'error':
135 for frame in msg_xreq["content"]["traceback"]:
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_xreq["content"]["execution_count"] + 1
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_rep_channel(self, timeout=0.1):
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.rep_channel.get_msg(timeout=timeout)
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.rep_channel.input(raw_data)
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('--xreq', type=int, metavar='PORT', default=0,
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('--sub', type=int, metavar='PORT', default=0,
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('--rep', type=int, metavar='PORT', default=0,
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(xreq_address=(args.ip, args.xreq),
234 kernel_manager = KernelManager(shell_address=(args.ip, args.shell),
235 sub_address=(args.ip, args.sub),
235 sub_address=(args.ip, args.iopub),
236 rep_address=(args.ip, args.rep),
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(BlockingRepSocketChannel, self).__init__(context, session, address)
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