Show More
@@ -168,9 +168,8 b' class FrontEndBase(object):' | |||
|
168 | 168 | output_prompt_template = string.Template(rc.prompt_out) |
|
169 | 169 | continuation_prompt_template = string.Template(rc.prompt_in2) |
|
170 | 170 | |
|
171 |
def __init__(self, |
|
|
172 | assert(engine==None or IEngineCore.providedBy(engine)) | |
|
173 | self.engine = IEngineCore(engine) | |
|
171 | def __init__(self, shell=None, history=None): | |
|
172 | self.shell = shell | |
|
174 | 173 | if history is None: |
|
175 | 174 | self.history = FrontEndHistory(input_cache=['']) |
|
176 | 175 | else: |
@@ -233,7 +232,7 b' class FrontEndBase(object):' | |||
|
233 | 232 | |
|
234 | 233 | |
|
235 | 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 | 237 | Parameters: |
|
239 | 238 | block : {str, AST} |
@@ -245,7 +244,24 b' class FrontEndBase(object):' | |||
|
245 | 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 | 267 | def _add_block_id_for_result(self, result, blockID): |
@@ -337,6 +353,15 b' class AsynchronousFrontEndBase(FrontEndBase):' | |||
|
337 | 353 | zi.implements(IFrontEnd) |
|
338 | 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 | 365 | def execute(self, block, blockID=None): |
|
341 | 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