Show More
@@ -168,9 +168,8 b' class FrontEndBase(object):' | |||||
168 | output_prompt_template = string.Template(rc.prompt_out) |
|
168 | output_prompt_template = string.Template(rc.prompt_out) | |
169 | continuation_prompt_template = string.Template(rc.prompt_in2) |
|
169 | continuation_prompt_template = string.Template(rc.prompt_in2) | |
170 |
|
170 | |||
171 |
def __init__(self, |
|
171 | def __init__(self, shell=None, history=None): | |
172 | assert(engine==None or IEngineCore.providedBy(engine)) |
|
172 | self.shell = shell | |
173 | self.engine = IEngineCore(engine) |
|
|||
174 | if history is None: |
|
173 | if history is None: | |
175 | self.history = FrontEndHistory(input_cache=['']) |
|
174 | self.history = FrontEndHistory(input_cache=['']) | |
176 | else: |
|
175 | else: | |
@@ -233,7 +232,7 b' class FrontEndBase(object):' | |||||
233 |
|
232 | |||
234 |
|
233 | |||
235 | def execute(self, block, blockID=None): |
|
234 | def execute(self, block, blockID=None): | |
236 | """Execute the block and return result. |
|
235 | """Execute the block and return the result. | |
237 |
|
236 | |||
238 | Parameters: |
|
237 | Parameters: | |
239 | block : {str, AST} |
|
238 | block : {str, AST} | |
@@ -245,7 +244,24 b' class FrontEndBase(object):' | |||||
245 | Deferred result of self.interpreter.execute |
|
244 | Deferred result of self.interpreter.execute | |
246 | """ |
|
245 | """ | |
247 |
|
246 | |||
248 | pass |
|
247 | if(not self.is_complete(block)): | |
|
248 | raise Exception("Block is not compilable") | |||
|
249 | ||||
|
250 | if(blockID == None): | |||
|
251 | blockID = uuid.uuid4() #random UUID | |||
|
252 | ||||
|
253 | try: | |||
|
254 | result = self.shell.execute(block) | |||
|
255 | except Exception,e: | |||
|
256 | e = self._add_block_id_for_failure(e, blockID=blockID) | |||
|
257 | e = self.update_cell_prompt(e, blockID=blockID) | |||
|
258 | e = self.render_error(e) | |||
|
259 | else: | |||
|
260 | result = self._add_block_id_for_result(result, blockID=blockID) | |||
|
261 | result = self.update_cell_prompt(result, blockID=blockID) | |||
|
262 | result = self.render_result(result) | |||
|
263 | ||||
|
264 | return result | |||
249 |
|
265 | |||
250 |
|
266 | |||
251 | def _add_block_id_for_result(self, result, blockID): |
|
267 | def _add_block_id_for_result(self, result, blockID): | |
@@ -337,6 +353,15 b' class AsynchronousFrontEndBase(FrontEndBase):' | |||||
337 | zi.implements(IFrontEnd) |
|
353 | zi.implements(IFrontEnd) | |
338 | zi.classProvides(IFrontEndFactory) |
|
354 | zi.classProvides(IFrontEndFactory) | |
339 |
|
355 | |||
|
356 | def __init__(self, engine=None, history=None): | |||
|
357 | assert(engine==None or IEngineCore.providedBy(engine)) | |||
|
358 | self.engine = IEngineCore(engine) | |||
|
359 | if history is None: | |||
|
360 | self.history = FrontEndHistory(input_cache=['']) | |||
|
361 | else: | |||
|
362 | self.history = history | |||
|
363 | ||||
|
364 | ||||
340 | def execute(self, block, blockID=None): |
|
365 | def execute(self, block, blockID=None): | |
341 | """Execute the block and return the deferred result. |
|
366 | """Execute the block and return the deferred result. | |
342 |
|
367 |
General Comments 0
You need to be logged in to leave comments.
Login now