38 |
from messages import SESSION_REPLACED |
from messages import SESSION_REPLACED |
39 |
|
|
40 |
|
|
|
|
|
41 |
class ThubanApplication(wxApp, Publisher): |
class ThubanApplication(wxApp, Publisher): |
42 |
|
|
43 |
""" |
""" |
49 |
""" |
""" |
50 |
|
|
51 |
def OnInit(self): |
def OnInit(self): |
52 |
|
sys.excepthook = show_exception_dialog |
53 |
self.splash = self.splash_screen() |
self.splash = self.splash_screen() |
54 |
if self.splash is not None: |
if self.splash is not None: |
55 |
self.splash.Show() |
self.splash.Show() |
225 |
else: |
else: |
226 |
self.top.SetMap(None) |
self.top.SetMap(None) |
227 |
|
|
228 |
in_exception_dialog = 0 # flag: are we already inside the exception dialog? |
in_exception_dialog = 0 # flag: are we already inside the exception dialog? |
229 |
|
|
230 |
|
def show_exception_dialog(exc_type, exc_value, exc_traceback): |
231 |
|
"""Show a message box with information about an exception. |
232 |
|
|
233 |
def ShowExceptionDialog(self, exc_type, exc_value, exc_traceback): |
The parameters are the usual values describing an exception in |
234 |
"""Show a message box with information about an exception. |
Python, the exception type, the value and the traceback. |
235 |
|
|
236 |
The parameters are the usual values describing an exception in |
This method can be used as a value for the sys.excepthook. |
237 |
Python, the exception type, the value and the traceback. |
""" |
238 |
|
global in_exception_dialog |
239 |
|
|
240 |
This method can be used as a value for the sys.excepthook. |
if in_exception_dialog: |
241 |
""" |
return |
242 |
if self.in_exception_dialog: |
in_exception_dialog = 1 |
243 |
return |
while wxIsBusy(): |
244 |
self.in_exception_dialog = 1 |
wxEndBusyCursor() # reset the mouse cursor |
245 |
while wxIsBusy(): |
|
246 |
wxEndBusyCursor() # reset the mouse cursor |
try: |
247 |
|
lines = traceback.format_exception(exc_type, exc_value, |
248 |
try: |
exc_traceback) |
249 |
lines = traceback.format_exception(exc_type, exc_value, |
message = "An unhandled exception occurred:\n%s\n" % exc_value+\ |
250 |
exc_traceback) |
"(please report to " \ |
251 |
message = "An unhandled exception occurred:\n%s\n" % exc_value+\ |
"http://thuban.intevation.org/bugtracker.html)"\ |
252 |
"(please report to " \ |
"\n\n\n"+\ |
253 |
"http://thuban.intevation.org/bugtracker.html)"\ |
"".join(lines) |
254 |
"\n\n\n"+\ |
print message |
255 |
"".join(lines) |
|
256 |
print message |
# We don't use an explicit parent here because this method might |
257 |
|
# be called in circumstances where the main window doesn't exist |
258 |
# We don't use an explicit parent here because this method might |
# anymore. |
259 |
# be called in circumstances where the main window doesn't exist |
dlg = wxScrolledMessageDialog(None, message, |
260 |
# anymore. |
"Thuban: Internal Error") |
261 |
dlg = wxScrolledMessageDialog(None, message, |
dlg.ShowModal() |
262 |
"Thuban: Internal Error") |
dlg.Destroy() |
263 |
dlg.ShowModal() |
|
264 |
dlg.Destroy() |
finally: |
265 |
|
in_exception_dialog = 0 |
266 |
finally: |
# delete the last exception info that python keeps in |
267 |
self.in_exception_dialog = 0 |
# sys.last_* because especially last_traceback keeps |
268 |
# delete the last exception info that python keeps in |
# indirect references to all objects bound to local |
269 |
# sys.last_* because especially last_traceback keeps |
# variables and this might prevent some object from being |
270 |
# indirect references to all objects bound to local |
# collected early enough. |
271 |
# variables and this might prevent some object from being |
sys.last_type = sys.last_value = sys.last_traceback = None |
|
# collected early enough. |
|
|
sys.last_type = sys.last_value = sys.last_traceback = None |
|
272 |
|
|