diff options
Diffstat (limited to 'src/leap/baseapp')
-rw-r--r-- | src/leap/baseapp/mainwindow.py | 2 | ||||
-rw-r--r-- | src/leap/baseapp/network.py | 25 |
2 files changed, 22 insertions, 5 deletions
diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index e48666a4..fdbaf693 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -52,6 +52,8 @@ class LeapWindow(QtGui.QMainWindow, lambda status: self.onStatusChange(status)) self.timer.timeout.connect( lambda: self.onTimerTick()) + self.networkError.connect( + lambda exc: self.onNetworkError(exc)) # ... all ready. go! diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py index fbf9376f..077d5164 100644 --- a/src/leap/baseapp/network.py +++ b/src/leap/baseapp/network.py @@ -1,10 +1,13 @@ from __future__ import print_function import logging + logger = logging.getLogger(name=__name__) +from PyQt4 import QtCore + +from leap.baseapp.dialogs import ErrorDialog from leap.base.network import NetworkCheckerThread -#from leap.baseapp.dialogs import ErrorDialog class NetworkCheckerAppMixin(object): @@ -15,11 +18,23 @@ class NetworkCheckerAppMixin(object): def __init__(self, *args, **kwargs): self.network_checker = NetworkCheckerThread( - # XXX watcher? remove ----- - watcher_cb=self.newLogLine.emit, - # XXX what callback? ------ - error_cb=None, + error_cb=self.networkError.emit, debug=self.debugmode) # XXX move run_checks to slot self.network_checker.run_checks() + + @QtCore.pyqtSlot(object) + def onNetworkError(self, exc): + """ + slot that receives a network exceptions + and raises a user error message + """ + logger.debug('handling network exception') + logger.error(exc.message) + dialog = ErrorDialog(parent=self) + + if exc.critical: + dialog.criticalMessage(exc.usermessage, "network error") + else: + dialog.warningMessage(exc.usermessage, "network error") |