Show More
@@ -24,6 +24,7 b' __docformat__ = "restructuredtext en"' | |||
|
24 | 24 | # Imports |
|
25 | 25 | #----------------------------------------------------------------------------- |
|
26 | 26 | |
|
27 | import sys | |
|
27 | 28 | import objc |
|
28 | 29 | import uuid |
|
29 | 30 | |
@@ -56,12 +57,29 b' from twisted.python.failure import Failure' | |||
|
56 | 57 | class AutoreleasePoolWrappedThreadedEngineService(ThreadedEngineService): |
|
57 | 58 | """Wrap all blocks in an NSAutoreleasePool""" |
|
58 | 59 | |
|
59 | def wrapped_execute(self, lines): | |
|
60 | def wrapped_execute(self, msg, lines): | |
|
60 | 61 | """wrapped_execute""" |
|
61 | ||
|
62 | p = NSAutoreleasePool.alloc().init() | |
|
63 | result = self.shell.execute(lines) | |
|
64 | p.drain() | |
|
62 | try: | |
|
63 | p = NSAutoreleasePool.alloc().init() | |
|
64 | result = self.shell.execute(lines) | |
|
65 | except Exception,e: | |
|
66 | # This gives the following: | |
|
67 | # et=exception class | |
|
68 | # ev=exception class instance | |
|
69 | # tb=traceback object | |
|
70 | et,ev,tb = sys.exc_info() | |
|
71 | # This call adds attributes to the exception value | |
|
72 | et,ev,tb = self.shell.formatTraceback(et,ev,tb,msg) | |
|
73 | # Add another attribute | |
|
74 | ||
|
75 | # Create a new exception with the new attributes | |
|
76 | e = et(ev._ipython_traceback_text) | |
|
77 | e._ipython_engine_info = msg | |
|
78 | ||
|
79 | # Re-raise | |
|
80 | raise e | |
|
81 | finally: | |
|
82 | p.drain() | |
|
65 | 83 | |
|
66 | 84 | return result |
|
67 | 85 | |
@@ -73,7 +91,7 b' class AutoreleasePoolWrappedThreadedEngineService(ThreadedEngineService):' | |||
|
73 | 91 | 'method':'execute', |
|
74 | 92 | 'args':[lines]} |
|
75 | 93 | |
|
76 | d = threads.deferToThread(self.wrapped_execute, lines) | |
|
94 | d = threads.deferToThread(self.wrapped_execute, msg, lines) | |
|
77 | 95 | d.addCallback(self.addIDToResult) |
|
78 | 96 | return d |
|
79 | 97 | |
@@ -241,7 +259,7 b' class IPythonCocoaController(NSObject, FrontEndBase):' | |||
|
241 | 259 | |
|
242 | 260 | #print inputRange,self.current_block_range() |
|
243 | 261 | self.insert_text('\n' + |
|
244 | self.output_prompt(result) + | |
|
262 | self.output_prompt(number=result['number']) + | |
|
245 | 263 | result.get('display',{}).get('pprint','') + |
|
246 | 264 | '\n\n', |
|
247 | 265 | textRange=NSMakeRange(inputRange.location+inputRange.length, |
@@ -250,7 +268,11 b' class IPythonCocoaController(NSObject, FrontEndBase):' | |||
|
250 | 268 | |
|
251 | 269 | |
|
252 | 270 | def render_error(self, failure): |
|
253 |
self.insert_text('\n |
|
|
271 | self.insert_text('\n' + | |
|
272 | self.output_prompt() + | |
|
273 | '\n' + | |
|
274 | failure.getErrorMessage() + | |
|
275 | '\n\n') | |
|
254 | 276 | self.start_new_block() |
|
255 | 277 | return failure |
|
256 | 278 |
@@ -106,13 +106,13 b' class IFrontEnd(zi.Interface):' | |||
|
106 | 106 | pass |
|
107 | 107 | |
|
108 | 108 | |
|
109 |
def input_prompt(number= |
|
|
109 | def input_prompt(number=''): | |
|
110 | 110 | """Returns the input prompt by subsituting into |
|
111 | 111 | self.input_prompt_template |
|
112 | 112 | """ |
|
113 | 113 | pass |
|
114 | 114 | |
|
115 |
def output_prompt(number= |
|
|
115 | def output_prompt(number=''): | |
|
116 | 116 | """Returns the output prompt by subsituting into |
|
117 | 117 | self.output_prompt_template |
|
118 | 118 | """ |
@@ -180,7 +180,7 b' class FrontEndBase(object):' | |||
|
180 | 180 | self.history = history |
|
181 | 181 | |
|
182 | 182 | |
|
183 |
def input_prompt(self, number= |
|
|
183 | def input_prompt(self, number=''): | |
|
184 | 184 | """Returns the current input prompt |
|
185 | 185 | |
|
186 | 186 | It would be great to use ipython1.core.prompts.Prompt1 here |
@@ -193,7 +193,7 b' class FrontEndBase(object):' | |||
|
193 | 193 | |
|
194 | 194 | return self.continuation_prompt_template.safe_substitute() |
|
195 | 195 | |
|
196 |
def output_prompt(self, number= |
|
|
196 | def output_prompt(self, number=''): | |
|
197 | 197 | """Returns the output prompt for result""" |
|
198 | 198 | |
|
199 | 199 | return self.output_prompt_template.safe_substitute({'number':number}) |
General Comments 0
You need to be logged in to leave comments.
Login now