From 5247c690b786f2b3e026fd3e17529f9fd6962d09 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 10 Oct 2012 05:32:54 +0900 Subject: use signals to pass eip errors across threads Closes #741 --- src/leap/baseapp/eip.py | 32 ++++---------------------------- src/leap/baseapp/mainwindow.py | 5 +++++ 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 22dc0dd7..b67e4444 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -76,7 +76,7 @@ class EIPConductorAppMixin(object): logger.error('%s: %s', error.__class__.__name__, error.message) if issubclass(error.__class__, eip_exceptions.EIPClientError): - self.handle_eip_error(error) + self.triggerEIPError.emit(error) else: # deprecated form of raising exception. @@ -85,32 +85,8 @@ class EIPConductorAppMixin(object): if error.failfirst is True: break - ############################################# - # old errors to check - # write test for them and them remove - # their corpses from here. - - #if self.conductor.missing_vpn_keyfile is True: - #dialog = ErrorDialog() - #dialog.criticalMessage( - #'Could not find the vpn keys file', - #'error') - - #if self.conductor.bad_keyfile_perms is True: - #dialog = ErrorDialog() - #dialog.criticalMessage( - #'The vpn keys file has bad permissions', - #'error') - - # deprecated. configchecker takes care of that. - #if self.conductor.missing_definition is True: - #dialog = ErrorDialog() - #dialog.criticalMessage( - #'The default ' - #'definition.json file cannot be found', - #'error') - - def handle_eip_error(self, error): + @QtCore.pyqtSlot(object) + def onEIPError(self, error): """ check severity and launches dialogs informing user about the errors. @@ -211,7 +187,7 @@ class EIPConductorAppMixin(object): self.conductor.connect() except eip_exceptions.EIPNoCommandError as exc: - self.handle_eip_error(exc) + self.triggerEIPError.emit(exc) except Exception as err: # raise generic exception (Bad Thing Happened?) diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index bbb5203c..87886767 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -26,10 +26,13 @@ class LeapWindow(QtGui.QMainWindow, that gets tricky otherwise. """ + # signals + newLogLine = QtCore.pyqtSignal([str]) mainappReady = QtCore.pyqtSignal([]) initReady = QtCore.pyqtSignal([]) networkError = QtCore.pyqtSignal([object]) + triggerEIPError = QtCore.pyqtSignal([object]) # XXX fix nomenclature here # this is eip status change got from vpn management @@ -71,6 +74,8 @@ class LeapWindow(QtGui.QMainWindow, lambda: self.onTimerTick()) self.networkError.connect( lambda exc: self.onNetworkError(exc)) + self.triggerEIPError.connect( + lambda exc: self.onEIPError(exc)) if self.debugmode: self.startStopButton.clicked.connect( -- cgit v1.2.3