Hi Paul,
and py2exe by default outputs error logs there.
thanks for that, how can i redirect this to the os.environ.get(“APPDATA”)
folder…
I see the snippet
import sys
sys.stdout = open(my_stdout.log, w)
sys.stderr = open(my_stderr.log, w)
in [http://www.py2exe.org/index.cgi/StderrLog](http://www.py2exe.org/index.cgi/StderrLog)
I tried something in the lines of
class Stderr(object):
softspace = 0
userDataDir = os.environ.get("APPDATA")+'\\Application Name';
_file = None
_error = None
def write(self, text, alert=sys._MessageBox, fname=sys.executable + '.log'):
if self._file is None and self._error is None:
try:
if (not os.path.isdir(userDataDir)):
os.mkdir(userDataDir)
self._file = open(fname, 'a')
except Exception, details:
self._error = details
import atexit
atexit.register(alert, 0,
"The logfile '%s' could not be opened:\n %s" % \
(fname, details),
"Errors occurred")
else:
import atexit
atexit.register(alert, 0,
"See the logfile '%s' for details" % fname,
"Errors occurred")
if self._file is not None:
self._file.write(text)
self._file.flush()
def flush(self):
if self._file is not None:
self._file.flush()
sys.stderr = Stderr()
del sys._MessageBox
del Stderr
I added the above class in setup.py script..
I am getting the error
AttributeError: 'module' object has no attribute '_MessageBox'
cheers
Thomas