diff options
Diffstat (limited to 'src/leap/baseapp/network.py')
-rw-r--r-- | src/leap/baseapp/network.py | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py index a33265e5..dc5182a4 100644 --- a/src/leap/baseapp/network.py +++ b/src/leap/baseapp/network.py @@ -17,14 +17,17 @@ class NetworkCheckerAppMixin(object): initialize an instance of the Network Checker, which gathers error and passes them on. """ + ERR_NETERR = False + def __init__(self, *args, **kwargs): provider = kwargs.pop('provider', None) + self.network_checker = None if provider: self.init_network_checker(provider) def init_network_checker(self, provider): null_check(provider, "provider_domain") - if not hasattr(self, 'network_checker'): + if not self.network_checker: self.network_checker = NetworkCheckerThread( error_cb=self.networkError.emit, debug=self.debugmode, @@ -33,6 +36,7 @@ class NetworkCheckerAppMixin(object): @QtCore.pyqtSlot(object) def runNetworkChecks(self): + logger.debug('running checks (from NetworkChecker Mixin slot)') self.network_checker.run_checks() @QtCore.pyqtSlot(object) @@ -41,11 +45,19 @@ class NetworkCheckerAppMixin(object): 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) + # FIXME this should not HANDLE anything after + # the network check thread has been stopped. - if exc.critical: - dialog.criticalMessage(exc.usermessage, "network error") - else: - dialog.warningMessage(exc.usermessage, "network error") + logger.debug('handling network exception') + if not self.ERR_NETERR: + self.ERR_NETERR = True + + logger.error(exc.message) + dialog = ErrorDialog(parent=self) + if exc.critical: + dialog.criticalMessage(exc.usermessage, "network error") + else: + dialog.warningMessage(exc.usermessage, "network error") + + self.start_or_stopVPN() + self.network_checker.stop() |