takluyver / pynsist

Build Windows installers for Python applications
https://pynsist.readthedocs.io/
Other
896 stars 119 forks source link

Display errors when running in a console #36

Closed takluyver closed 9 years ago

takluyver commented 9 years ago

Currently, errors are logged to a file, which is useful for GUIs where there's no stderr to write to, but somewhat confusing for developers who try running the application in a console, and find it fails with no output.

Thanks @latusrepo for pointing this out.

(I thought the location of the log file wasn't documented, but it is: http://pynsist.readthedocs.org/en/latest/installers.html#uncaught-exceptions)

takluyver commented 9 years ago

Now if there is a console, the traceback will print in the console too.

If there isn't a console, it will redirect stdout/stderr to the log file, so you may get extra information. This also avoids the problem where programs can lock up because they've filled up an invisible stdout/stderr buffer and are trying to write more data to it.

This caused me some concern because now the application has the log file open all the time it's running, and I thought that would cause a problem if you launched two copies of the application at once. But it seemed to work OK. After reading Windows docs, Python source code, this issue and wine source code in this file, I'm pretty confident that opening a file in Python ends up setting the sharing options FILE_SHARE_READ | FILE_SHARE_WRITE, which makes it OK to reopen the file in another process.

If multiple processes are running together, the log file may well get garbled. In most cases, I assume that developers will debug applications with only one copy open at a time. If an application needs to be debugged with multiple copies running and not in the console, developers can redirect the logs within their own application to somewhere else.

takluyver commented 9 years ago

By the way @latusrepo, are you using Pynsist from Github, or the released version 1.0 from PyPI? I'm thinking I should probably do a new release.

jamesabel commented 9 years ago

I'm using Pynsist from PyPI. (although I could get it from github if need be)

Thanks for the enhancement!

takluyver commented 9 years ago

When you've got a few minutes to spare, can you install it from Github and give it a test run? Since 1.0 I replaced the templating engine for NSI files - I switched from my own custom template code to Jinja, one of the popular Python template systems. I'm testing it with the examples, but with a change like that it's good to get as much testing as possible.

If all goes well, I'll make a 1.5 release some time over the weekend or next week.

jamesabel commented 9 years ago

I just tried it - it worked for me!

takluyver commented 9 years ago

Superb, thanks!

takluyver commented 9 years ago

OK, 1.5 is up on PyPI. :-)