def preload(modules, app=None): if not app: from qt import QtGui app = QtGui.qApp timer = Timer() logger = logging.getLogger('gsdview') for modname in modules: logger.info(app.tr('Importing %s module ...') % modname) app.processEvents() logging.debug('%s import: %d.%06ds' % ((modname,) + timer.update()))
def preload(modules, app=None): if not app: from qt import QtGui app = QtGui.qApp timer = Timer() logger = logging.getLogger('gsdview') for modname in modules: logger.info(app.tr('Importing %s module ...') % modname) app.processEvents() logging.debug('%s import: %d.%06ds' % ((modname, ) + timer.update()))
def main(): # @IMPORTANT: force numeric locale to 'C' in order to avoid problems # with GDAL and PPROJ4 # @SEEALSO: http://trac.osgeo.org/gdal/wiki/FAQMiscellaneous#DoesGDALworkindifferentinternationalnumericlocales import os os.environ['LC_NUMERIC'] = 'C' options, args = cmdline_ui() # logging.basicConfig(level=logging.DEBUG, logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s') logger = logging.getLogger('gsdview') logger.setLevel(logging.DEBUG) # @TODO: # * config logging using options.configfile, USER_CFG, SYS_CFG # * if options.debug: set rootlogger.level = logging.DEBUG # * maybe set loglevelfor other loggers timer = Timer() ### splash screen ######################################################### from qt import QtGui logging.debug('Qt4 import: %d.%06ds' % timer.update()) import sys from .info import name as NAME from .info import version as VERSION from .utils import getresource app = QtGui.QApplication(sys.argv) app.setApplicationName(NAME) app.setApplicationVersion(VERSION) pngfile = getresource(os.path.join('images', 'splash.png'), __name__) pixmap = QtGui.QPixmap(pngfile) splash = QtGui.QSplashScreen(pixmap) splash.show() app.processEvents() splash_loghandler = SplashLogHandler(splash, app) splash_loghandler.setFormatter(logging.Formatter('%(message)s')) logger.addHandler(splash_loghandler) logger.debug('Splash screen setup completed') logging.debug('splash screen setup: %d.%06ds' % timer.update()) ### modules loading ####################################################### preload(MODULES, app) ### GUI ################################################################### logger.info('Build GUI ...') from .app import GSDView mainwin = GSDView() # @TODO: pass plugins_path, loglevel?? mainwin.show() logger.info('GUI setup completed') logging.debug('GUI setup: %d.%06ds' % timer.update()) ### close splash and run app ############################################## logger.removeHandler(splash_loghandler) splash.finish(mainwin) app.processEvents() logger.info('Install the exception hook') sys.excepthook = mainwin.excepthook # @TODO: check logger.info('Enter main event loop') # @COMPATIBILITY: this will raise the window on Mac OS X mainwin.raise_() sys.exit(app.exec_())