def start(self): try: self._setup_thread() except Exception, e: exc_info = register_exception( logger, 'Exception when setting up the NoThreadModelThread', e) self.setup_exception_signal.emit(exc_info)
def post( self, request, response = None, exception = None, args=() ): try: result = request(*args) response( result ) except Exception, e: if exception: exception_info = register_exception(logger, 'Exception caught in model thread while executing %s'%request.__name__, e ) exception(exception_info)
def post( self, request, response = None, exception = None, args=() ): try: result = request(*args) response( result ) except Exception as e: if exception: exception_info = register_exception(logger, 'Exception caught in model thread while executing %s'%request.__name__, e ) exception(exception_info)
def delete_function(): """Remove all rows from the underlying collection :return: the number of rows left in the collection""" try: objects_to_remove = [self._get_object(row) for row in rows] self.remove_objects(objects_to_remove, delete) self.rows_removed_signal.emit() except Exception, exc: exc_info = register_exception(logger, "exception while removing rows", exc) self.exception_signal.emit(exc_info)
def run( self ): self.logger.debug( 'model thread started' ) self._task_handler = TaskHandler(self) self._task_handler.task_handler_busy_signal.connect(self._thread_busy, QtCore.Qt.QueuedConnection) self._thread_busy(True) try: self._setup_thread() except Exception, e: exc_info = register_exception(logger, 'Exception when setting up the SignalSlotModelThread', e) self.setup_exception_signal.emit( exc_info )
def execute(self): logger.debug('executing %s' % (self._name)) try: result = self._request() self.finished.emit( result ) except Exception, e: name, trace = register_exception(logger, 'exception caught in model thread while executing %s'%self._name, e) self.exception.emit( (name, trace) ) # the stack might contain references to QT objects which could be kept alive this way sys.exc_clear()
def delete_function(): """Remove all rows from the underlying collection :return: the number of rows left in the collection""" try: objects_to_remove = [self._get_object(row) for row in rows] self.remove_objects(objects_to_remove, delete) self.rows_removed_signal.emit() except Exception, exc: exc_info = register_exception( logger, 'exception while removing rows', exc) self.exception_signal.emit(exc_info)
def execute(self): logger.debug('executing %s' % (self._name)) try: result = self._request() self.finished.emit(result) except Exception, e: name, trace = register_exception( logger, 'exception caught in model thread while executing %s' % self._name, e) self.exception.emit((name, trace)) # the stack might contain references to QT objects which could be kept alive this way sys.exc_clear()
def run(self): self.logger.debug('model thread started') self._task_handler = TaskHandler(self) self._task_handler.task_handler_busy_signal.connect( self._thread_busy, QtCore.Qt.QueuedConnection) self._thread_busy(True) try: self._setup_thread() except Exception, e: name, trace = register_exception( logger, 'Exception when setting up the SignalSlotModelThread', e) self.setup_exception_signal.emit(name, trace)
def execute(self): logger.debug('executing %s' % (self._name)) try: result = self._request( *self._args ) self.finished.emit( result ) # # don't handle StopIteration as a normal exception, but return a new # instance of StopIteration (in order to not keep alive a stack trace), # and to signal to the caller that an iterator has ended # except StopIteration: self.finished.emit( StopIteration() ) except Exception, e: exc_info = register_exception(logger, 'exception caught in model thread while executing %s'%self._name, e) self.exception.emit( exc_info ) # the stack might contain references to QT objects which could be kept alive this way sys.exc_clear()
def execute(self): logger.debug('executing %s' % (self._name)) try: result = self._request(*self._args) self.finished.emit(result) # # don't handle StopIteration as a normal exception, but return a new # instance of StopIteration (in order to not keep alive a stack trace), # and to signal to the caller that an iterator has ended # except StopIteration: self.finished.emit(StopIteration()) except Exception, e: exc_info = register_exception( logger, 'exception caught in model thread while executing %s' % self._name, e) self.exception.emit(exc_info) # the stack might contain references to QT objects which could be kept alive this way sys.exc_clear()
def start(self): try: self._setup_thread() except Exception, e: exc_info = register_exception(logger, 'Exception when setting up the NoThreadModelThread', e) self.setup_exception_signal.emit(exc_info)
def main(self): """the main function of the application, this will call all other functions before starting the event loop""" import logging logger = logging.getLogger('camelot.view.main') try: # # before anything else happens or is imported, the splash screen should be there # import sys from PyQt4 import QtGui, QtCore app = QtGui.QApplication([a for a in sys.argv if a]) splash_window = self.show_splashscreen() self.show_splash_message(splash_window, _('Initialize application')) # regularly call processEvents to keep the splash alive app.processEvents() # font = app.font() # font.setStyleStrategy(QtGui.QFont.PreferAntialias) # font.setPointSize(font.pointSize()+1) # app.setFont(font) if hasattr( QtCore, 'QT_MAJOR_VERSION'): QT_MAJOR_VERSION = float('.'.join(str(QtCore.QT_VERSION_STR).split('.')[0:2])) logger.debug('qt version %s, pyqt version %s' % (QtCore.QT_VERSION_STR, QtCore.PYQT_VERSION_STR)) logger.debug('qt major version %f' % QT_MAJOR_VERSION) app.processEvents() import sqlalchemy logger.debug('sqlalchemy version %s'%sqlalchemy.__version__) app.processEvents() self.set_application_attributes(app) self.pre_initialization() app.processEvents() # regularly call processEvents to keep the splash alive self.show_splash_message(splash_window, _('Setup database')) app.processEvents() self.start_model_thread() app.processEvents() # # WEIRD, if we put this code in a method, the translations # don't work # from camelot.core.utils import load_translations from camelot.view.model_thread import post self.show_splash_message(splash_window, _('Load translations')) app.processEvents() post(load_translations) self.show_splash_message(splash_window, _('Create translator')) app.processEvents() translator = self.application_admin.get_translator() self.show_splash_message(splash_window, _('Install translator')) if isinstance(translator, list): for t in translator: app.installTranslator( t ) else: app.installTranslator( translator ) app.processEvents() # Set the style sheet self.show_splash_message(splash_window, _('Create main window')) app.processEvents() stylesheet = self.application_admin.get_stylesheet() if stylesheet: app.setStyleSheet(stylesheet) app.processEvents() self.initialization() app.processEvents() main_window = self.create_main_window() main_window.splash_screen = splash_window main_window.show() return self.start_event_loop(app) except Exception, e: from camelot.view.controls import exception exc_info = exception.register_exception( logger, 'exception in initialization', e ) self.initialization_exception( exc_info )