[#206 state:fixed] Moved stdout wrapping under cxfreeze sooner at startup.

This commit is contained in:
Virgil Dupras 2012-08-07 12:37:17 -04:00
parent 26c77a18fd
commit c321427a8f
2 changed files with 4 additions and 19 deletions

View File

@ -7,10 +7,8 @@
# http://www.hardcoded.net/licenses/bsd_license
import sys
import logging
import os
import os.path as op
import io
from PyQt4.QtCore import QTimer, QObject, QCoreApplication, QUrl, QProcess, SIGNAL, pyqtSignal
from PyQt4.QtGui import QDesktopServices, QFileDialog, QDialog, QMessageBox, QApplication
@ -25,7 +23,7 @@ from core.app import JobType
from qtlib.about_box import AboutBox
from qtlib.recent import Recent
from qtlib.reg import Registration
from qtlib.util import createActions
from qtlib.util import createActions, getAppData
from . import platform
from .result_window import ResultWindow
@ -44,11 +42,6 @@ JOBID2TITLE = {
JobType.Delete: tr("Sending files to the recycle bin"),
}
class SysWrapper(io.IOBase):
def write(self, s):
if s.strip(): # don't log empty stuff
logging.warning(s)
class DupeGuru(QObject):
MODELCLASS = None
LOGO_NAME = '<replace this>'
@ -62,19 +55,9 @@ class DupeGuru(QObject):
def __init__(self):
QObject.__init__(self)
appdata = str(QDesktopServices.storageLocation(QDesktopServices.DataLocation))
if not op.exists(appdata):
os.makedirs(appdata)
# For basicConfig() to work, we have to be sure that no logging has taken place before this call.
logging.basicConfig(filename=op.join(appdata, 'debug.log'), level=logging.WARNING,
format='%(asctime)s - %(levelname)s - %(message)s')
if sys.stderr is None: # happens under a cx_freeze environment
sys.stderr = SysWrapper()
if sys.stdout is None:
sys.stdout = SysWrapper()
self.prefs = self.PREFERENCES_CLASS()
self.prefs.load()
self.model = self.MODELCLASS(view=self, appdata=appdata)
self.model = self.MODELCLASS(view=self, appdata=getAppData())
self._setup()
self.prefsChanged.emit(self.prefs)

View File

@ -14,6 +14,7 @@ from PyQt4.QtGui import QApplication, QIcon, QPixmap
from hscommon.plat import ISWINDOWS
from hscommon.trans import install_gettext_trans_under_qt
from qtlib.error_report_dialog import install_excepthook
from qtlib.util import setupQtLogging
from qt.base import dg_rc
from qt.base.platform import BASE_PATH
from core_{{edition}} import __version__, __appname__
@ -26,6 +27,7 @@ if __name__ == "__main__":
QCoreApplication.setOrganizationName('Hardcoded Software')
QCoreApplication.setApplicationName(__appname__)
QCoreApplication.setApplicationVersion(__version__)
setupQtLogging()
settings = QSettings()
lang = settings.value('Language')
locale_folder = op.join(BASE_PATH, 'locale')