Been trying to figure out how to get py2exe to handle errors more gracefully. There are basically 2 weird things happening:
1) Popup message after shutting down the program => want to suppress (not show up) this popup
- Use try/except => doesn't work
- http://osdir.com/ml/python.py2exe/2006-09/msg00016.html
- Not sure where to put this code
2) Log file getting created in c:\Program Files\AppName\AppName.exe.log (sometimes has permission errors writing to this folder) => redirect log to c:\ProgramData
- Use sys.stdout and sys.stderr => doesn't work
- http://www.dreamincode.net/forums/topic/234318-py2exe-do-not-show-errors-occurred-prompt-to-user/
- Not sure where to put this code
I'm thinking that I may just be putting the code in the wrong spot and the py2exe bootstrap code is firing AFTER I've set these up but I'm not sure. I've tried putting this code right before the error log is generate but it still goes to where py2exe is bootstrapping them to (the StdErr objects)
The structure of my program is as follows
src/python/gui/__main__.py
main.py
if __name__ == "__main__":# Redirect py2exe log to somewhere else if windowsif hasattr(sys,"frozen") and sys.frozen in ("windows_exe", "console_exe"):stdout_file = "c:\ProgramData\AppName\out.log"stderr_file = "c:\ProgramData\AppName\err.log"sys.stdout = open(stdout_file, "w")sys.stderr = open(stderr_file, "w")try:gui = AppNameGui()gui.main()except:traceback.print_exc()