[Pythonmac-SIG] uniformative Error when launching app

Paul Wiseman poalman at gmail.com
Mon Sep 24 21:38:00 CEST 2012


On 24 September 2012 18:02, Ronald Oussoren <ronaldoussoren at mac.com> wrote:

>
> On 24 Sep, 2012, at 18:39, Geoffrey Irving <irving at naml.us> wrote:
>
> > On Mon, Sep 24, 2012 at 12:21 AM, Ronald Oussoren
> > <ronaldoussoren at mac.com> wrote:
> >>
> >> On 21 Sep, 2012, at 21:36, Geoffrey Irving <irving at naml.us> wrote:
> >>
> >>> I am trying to package up a mixed Python/C++ application using py2app.
> >>> My setup.py is
> >>>
> >>>   from setuptools import setup
> >>>   setup(app=['voxpopuli.py'],data_files=[],options=
> >>>     {'py2app'{'argv_emulation':True}},setup_requires=['py2app'])
> >>>
> >>> and I invoke py2app via
> >>>
> >>>   python setup.py py2app --no-strip --iconfile
> >>> /Users/irving/otherlab/other/bin/OLicon.icns --resources
> >>> /opt/local/lib/Resources/qt_menu.nib
> >>>
> >>> This completes without warnings or errors, but when I try to run the
> >>> resuling app a window pops up that simply says "voxpopuli Error". It
> >>> has an "Open Console" button, but the only console messages are
> >>>
> >>>   9/21/12 11:43:14.691 AM voxpopuli[52765]: voxpopuli Error
> >>>   9/21/12 11:43:15.926 AM com.apple.launchd.peruser.501[158]:
> >>> ([0x0-0x177d77c].org.pythonmac.unspecified.voxpopuli[52765]) Exited
> >>> with code: 255
> >>>
> >>> Are there standard ways to get more information out of py2app to help
> >>> diagnosing this error?
> >>
> >> You can run the application from the commandline as
> "voxpopuli.app/Contents/MacOS/voxpopuli" and that should print the script
> output to the terminal window.
> >
> > When I do that the app runs fine with no errors or warnings.
>
> That's annoying. You could try to redirect sys.stdout/sys.stderrr to see
> that provides more information. There is a __boot__.py file in the bundle
> that is loaded early during startup of the application, adding lines like
> these should redirect that output to a temporary file:
>
> import sys
> sys.stdout = open('/tmp/program.out', 'w')
> sys.stderr = open('/tmp/program.err', 'w')
>
> Ronald
>
> >
> > Geoffrey
>
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
>
>
It's usually caused by an unhandled exception.

You should be able to write it out by overwriting sys.excepthook

import sys
import traceback

def _excepthook(e,v,tb):
    with open("error.log","w") as error_log:
        error_log.write(str(e))
        error_log.write(v)
        error_log.write("Traceback:\n"+"".join(traceback.format_tb(tb)))

sys.excepthook= _excepthook
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythonmac-sig/attachments/20120924/8ff6bf5a/attachment-0001.html>


More information about the Pythonmac-SIG mailing list