mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
[#206 state:fixed] Moved stdout wrapping under cxfreeze sooner at startup.
This commit is contained in:
parent
26c77a18fd
commit
c321427a8f
@ -7,10 +7,8 @@
|
|||||||
# http://www.hardcoded.net/licenses/bsd_license
|
# http://www.hardcoded.net/licenses/bsd_license
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
import os.path as op
|
import os.path as op
|
||||||
import io
|
|
||||||
|
|
||||||
from PyQt4.QtCore import QTimer, QObject, QCoreApplication, QUrl, QProcess, SIGNAL, pyqtSignal
|
from PyQt4.QtCore import QTimer, QObject, QCoreApplication, QUrl, QProcess, SIGNAL, pyqtSignal
|
||||||
from PyQt4.QtGui import QDesktopServices, QFileDialog, QDialog, QMessageBox, QApplication
|
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.about_box import AboutBox
|
||||||
from qtlib.recent import Recent
|
from qtlib.recent import Recent
|
||||||
from qtlib.reg import Registration
|
from qtlib.reg import Registration
|
||||||
from qtlib.util import createActions
|
from qtlib.util import createActions, getAppData
|
||||||
|
|
||||||
from . import platform
|
from . import platform
|
||||||
from .result_window import ResultWindow
|
from .result_window import ResultWindow
|
||||||
@ -44,11 +42,6 @@ JOBID2TITLE = {
|
|||||||
JobType.Delete: tr("Sending files to the recycle bin"),
|
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):
|
class DupeGuru(QObject):
|
||||||
MODELCLASS = None
|
MODELCLASS = None
|
||||||
LOGO_NAME = '<replace this>'
|
LOGO_NAME = '<replace this>'
|
||||||
@ -62,19 +55,9 @@ class DupeGuru(QObject):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
QObject.__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 = self.PREFERENCES_CLASS()
|
||||||
self.prefs.load()
|
self.prefs.load()
|
||||||
self.model = self.MODELCLASS(view=self, appdata=appdata)
|
self.model = self.MODELCLASS(view=self, appdata=getAppData())
|
||||||
self._setup()
|
self._setup()
|
||||||
self.prefsChanged.emit(self.prefs)
|
self.prefsChanged.emit(self.prefs)
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ from PyQt4.QtGui import QApplication, QIcon, QPixmap
|
|||||||
from hscommon.plat import ISWINDOWS
|
from hscommon.plat import ISWINDOWS
|
||||||
from hscommon.trans import install_gettext_trans_under_qt
|
from hscommon.trans import install_gettext_trans_under_qt
|
||||||
from qtlib.error_report_dialog import install_excepthook
|
from qtlib.error_report_dialog import install_excepthook
|
||||||
|
from qtlib.util import setupQtLogging
|
||||||
from qt.base import dg_rc
|
from qt.base import dg_rc
|
||||||
from qt.base.platform import BASE_PATH
|
from qt.base.platform import BASE_PATH
|
||||||
from core_{{edition}} import __version__, __appname__
|
from core_{{edition}} import __version__, __appname__
|
||||||
@ -26,6 +27,7 @@ if __name__ == "__main__":
|
|||||||
QCoreApplication.setOrganizationName('Hardcoded Software')
|
QCoreApplication.setOrganizationName('Hardcoded Software')
|
||||||
QCoreApplication.setApplicationName(__appname__)
|
QCoreApplication.setApplicationName(__appname__)
|
||||||
QCoreApplication.setApplicationVersion(__version__)
|
QCoreApplication.setApplicationVersion(__version__)
|
||||||
|
setupQtLogging()
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
lang = settings.value('Language')
|
lang = settings.value('Language')
|
||||||
locale_folder = op.join(BASE_PATH, 'locale')
|
locale_folder = op.join(BASE_PATH, 'locale')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user