[Pymoul-svn] SF.net SVN: pymoul: [76] pymoul/trunk
Status: Alpha
Brought to you by:
tiran
|
From: <ti...@us...> - 2007-01-25 15:25:34
|
Revision: 76
http://pymoul.svn.sourceforge.net/pymoul/?rev=76&view=rev
Author: tiran
Date: 2007-01-25 07:25:33 -0800 (Thu, 25 Jan 2007)
Log Message:
-----------
Some logging and Makefile tweaks. Redirect stdout/stderr if sys.frozen
Modified Paths:
--------------
pymoul/trunk/Makefile
pymoul/trunk/setup_win32.py
pymoul/trunk/src/moul/log.py
Modified: pymoul/trunk/Makefile
===================================================================
--- pymoul/trunk/Makefile 2007-01-25 14:21:20 UTC (rev 75)
+++ pymoul/trunk/Makefile 2007-01-25 15:25:33 UTC (rev 76)
@@ -16,12 +16,18 @@
py2exe:
PYTHONPATH="src" $(PYTHON) setup.py $(SETUPFLAGS) py2exe
+innosetup:
+ PYTHONPATH="src" INNOSETUP="yes" $(PYTHON) setup.py $(SETUPFLAGS) py2exe
+
bdist_egg:
PYTHONPATH="src" $(PYTHON) setup.py $(SETUPFLAGS) bdist_egg
run: compileui
PYTHONPATH="src" $(PYTHON) src/moul/qt/moulqt.py
+runexe: compileui py2exe
+ dist/moulqt.exe
+
compileui:
$(PYTHON) compileui.py
@@ -39,6 +45,8 @@
exe: py2exe
+installer: innosetup
+
egg: bdist_egg
doc: doc_html
Modified: pymoul/trunk/setup_win32.py
===================================================================
--- pymoul/trunk/setup_win32.py 2007-01-25 14:21:20 UTC (rev 75)
+++ pymoul/trunk/setup_win32.py 2007-01-25 15:25:33 UTC (rev 76)
@@ -71,11 +71,15 @@
pexe['includes'] = ['sip', 'PyQt4', 'encodings', 'encodings.*']
# SSL currently not in use but imported by socket
pexe['excludes'] = ['_ssl']
+ # added by platform but not yet required
+ pexe['excludes'].extend(('win32pipe', 'win32api', 'win32con', 'win32evtlog'))
+ # added by logging.handlers.SMTPHandler but not yet required
+ pexe['excludes'].append('smtplib')
# UPX
pexe['upx'] = True
pexe['upx_args'] = '--mono --best'
# InnoSetup
- pexe['innosetup'] = True
+ pexe['innosetup'] = os.environ.get('INNOSETUP') # TODO:
pexe['app_name'] = 'pyMoul'
# not required at the moment
pexe['includes'].extend(findPyTz())
Modified: pymoul/trunk/src/moul/log.py
===================================================================
--- pymoul/trunk/src/moul/log.py 2007-01-25 14:21:20 UTC (rev 75)
+++ pymoul/trunk/src/moul/log.py 2007-01-25 15:25:33 UTC (rev 76)
@@ -37,30 +37,46 @@
# copied from moul.config to prevent circular imports
__FROZEN__ = bool(getattr(sys, 'frozen', False))
__LOG_SIGNALS__ = not __FROZEN__
-if __FROZEN__:
- level = logging.ERROR
-else:
- level = logging.DEBUG
+class LoggingStdout(object):
+ """Replacement for stdout/stderr IO
+ """
+ __slot__ = ('_logfunc',)
+
+ def __init__(self, logfunc):
+ self._logfunc = logfunc
+
+ def write(self, value):
+ while value.endswith('\n'):
+ value = value[:-1]
+ if value:
+ self._logfunc(value)
+
format = logging.Formatter('%(asctime)s %(name)-8s %(levelname)-7s %(message)s',
#'%a, %d %b %Y %H:%M:%S'
'%m-%d %H:%M:%S')
root = getLogger()
-root.setLevel(level)
+root.setLevel(logging.DEBUG)
-# Add streaming handler for sys.stderr
-shdlr = logging.StreamHandler(sys.stderr)
-shdlr.setFormatter(format)
-shdlr.setLevel(level)
-root.addHandler(shdlr)
-
# setup a memory handler to store records before we have the infrastructure
# to log events to a file
mhdlr = handlers.MemoryHandler(capacity=16*1024) # MemoryHandler doesn't flush w/o a target
mhdlr.setFormatter(format)
-mhdlr.setLevel(logging.DEBUG)
root.addHandler(mhdlr)
+if not __FROZEN__:
+ # Add streaming handler to sys.stderr.
+ # Only log to stderr when the program is not frozen!
+ shdlr = logging.StreamHandler(sys.stderr)
+ shdlr.setFormatter(format)
+ root.addHandler(shdlr)
+else:
+ # Redirect stdout and stderr to logger when running as frozen app
+ sys.stdout = LoggingStdout(getLogger('stdout').info)
+ print "Stdout redirected"
+ sys.stderr = LoggingStdout(getLogger('stderr').error)
+ print >>sys.stderr, "Stderr redirected"
+
# DEBUG system infos
LOG = getLogger('pyMoul')
LOG.debug("pyMoul version: %s" % moul_version)
@@ -77,11 +93,10 @@
LOG.debug("Adding file logger: %s" % logFile)
fhdlr = handlers.RotatingFileHandler(logFile, backupCount=9)
fhdlr.setFormatter(format)
-fhdlr.setLevel(logging.DEBUG)
root.addHandler(fhdlr)
fhdlr.doRollover()
-# flush and remove remove memory handler
+# flush and remove memory handler
mhdlr.setTarget(fhdlr)
mhdlr.flush()
root.removeHandler(mhdlr)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|