See the custom-boot-script option at http://www.py2exe.org/index.cgi/ListOfOptions
Is there a way to override boot_common.py without replacing the file in the py2exe installation directory?
Here is my version of boot_common.py. I wrote it to have the stderr into the popup screen instead of into a log file:
if sys.frozen == "windows_exe":
softspace = 0
_file = None
_alert = sys._MessageBox
text = 'Captured stderr:\n%s' % self._file.getvalue()
def write(self, text, alert=None, fname=None):
if self._file is None:
from StringIO import StringIO
self._file = StringIO()
sys.stderr = Stderr()
softspace = 0
def write(self, text):
sys.stdout = Blackhole()
This worked fine in a test I did by replacing boot_common.py in c:/Python26/Lib/site-packages/py2exe/.
Thanks a lot,
Note1: The reasons I have for not generating a log file are
1) The executable is in a folder where the users don't have the permission to write. I could have changed the log directory in boot_common but I couldn't imagine an alternative directory which would be safe to create a log file. We could perhaps use %TEMP%, but I believe that users could be afraid to look there for log files...
2) I believe that it is easier for a user to send us the capture of the screen (in our experience every user knows how to do this) than to look for a log file in a directory (%TEMP% or another).
The inconvenience of the proposed approach could be to have a very big popup if there are too many messages are sent to stderr. But I my case I believe that this is unlikely to happen, because -- after parsing the command line, opening the logging handlers and creating the output directory where several logs and output files go -- our application redirects stderr to a file in this output directory. So the mechanism in boot_common.py is important only for the startup (i.e. to the errors that might happen before this redirection) and should not contain more information than a traceback in the case of a unforeseen exception.
Note 2: In order to test it I just wrote a hello.py with an exception:
and a standard setup.py
from distutils.core import setup
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
Py2exe-users mailing list