summaryrefslogtreecommitdiff
path: root/src/leap/baseapp/network.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-10-08 07:57:42 +0900
committerkali <kali@leap.se>2012-10-08 07:57:42 +0900
commit4d195cd5b6e6600ccf0df78946cab6038a1fcaec (patch)
tree1362b2844f7e008cad8c29f26861566129af6edd /src/leap/baseapp/network.py
parent3a77603eae5fea0b1efb226860e0264ccf96f41b (diff)
parent6728eb9afb21bad867e4052a6190a9bdb34c928a (diff)
Merge branch 'feature/network_check' into develop
Conflicts: src/leap/baseapp/mainwindow.py src/leap/eip/tests/test_checks.py
Diffstat (limited to 'src/leap/baseapp/network.py')
-rw-r--r--src/leap/baseapp/network.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py
new file mode 100644
index 00000000..077d5164
--- /dev/null
+++ b/src/leap/baseapp/network.py
@@ -0,0 +1,40 @@
+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
+
+
+class NetworkCheckerAppMixin(object):
+ """
+ initialize an instance of the Network Checker,
+ which gathers error and passes them on.
+ """
+
+ def __init__(self, *args, **kwargs):
+ self.network_checker = NetworkCheckerThread(
+ 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")