[wxPython] Catching error logs

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] Catching error logs

Pieter Claerhout-3
Hello,

does anyone know how to catch Python exceptions, before the program
kicks out. I want to be able to show them in a dialog box, and let the
user quit the program after that. The reason why is because I built an
application using wxPyhon, and I made an exe with the installer package
from Gordon McMillan, and I want to be able to catch all the errors that
are still in the program, without letting the users having an extra window
open which shows all messages (the standard dos window).

Any ideas??


Pieter

Pieter Claerhout - [hidden email]
Response Center - Applications Support

Creo Europe - Excelsiorlaan 21 - 1930 Zaventem - Belgium
Tel: +32 (2) 711 14 00 - Fax: +32 (2) 720 96 71


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Catching error logs

Nigel Linnett-2
At 12:02 PM 1/6/00 , Pieter Claerhout wrote:
>Hello,
>
>does anyone know how to catch Python exceptions, before the program
>kicks out. I want to be able to show them in a dialog box, and let the
>user quit the program after that. The reason why is because I built an
>application using wxPyhon, and I made an exe with the installer package
>from Gordon McMillan, and I want to be able to catch all the errors that
>are still in the program, without letting the users having an extra window
>open which shows all messages (the standard dos window).

Hi Pieter,

   It sounds as if what you want to do is wrap your whole program in a try:
... except: wrapper. Not sure how you catch the specific exception that was
thrown, but the python docs should be able to help you with that.

Nigel


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Catching error logs

Robin Dunn
In reply to this post by Pieter Claerhout-3
> does anyone know how to catch Python exceptions, before the program
> kicks out. I want to be able to show them in a dialog box, and let the
> user quit the program after that. The reason why is because I built an
> application using wxPyhon, and I made an exe with the installer package
> from Gordon McMillan, and I want to be able to catch all the errors that
> are still in the program, without letting the users having an extra window
> open which shows all messages (the standard dos window).
>
> Any ideas??
>
>

Create a class that has a write(self, string) method, create an instance of
it and assign it to sys.stderr.  Now anyhtin written to that output stream
(including exception messages) will actiually be written to your object.  You
can do whatever you want with it, display in a window, write to a file, send
it in an email to yourself...

Take a look near the end of wx.py for an example, wxPyOnDemandOutputWindow.
One of these is created if you construct your wxApp object without the zero,
IOW, "app = MyApp(1)"

The one problem with redirecting sys.stdout and sys.stderr is that it tends
to make debugging with pdb very difficult, so you'll want to make it
something that is optional or easily disabled forwhen you want to debug.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!




_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users