summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/leap/base/checks.py5
-rw-r--r--src/leap/base/network.py13
-rw-r--r--src/leap/base/tests/test_checks.py3
-rw-r--r--src/leap/baseapp/mainwindow.py5
-rw-r--r--src/leap/baseapp/network.py5
5 files changed, 18 insertions, 13 deletions
diff --git a/src/leap/base/checks.py b/src/leap/base/checks.py
index a775e162..d02c9a3d 100644
--- a/src/leap/base/checks.py
+++ b/src/leap/base/checks.py
@@ -3,6 +3,7 @@
import logging
import platform
+import netifaces
import ping
import requests
@@ -11,6 +12,7 @@ from leap.base import exceptions
logger = logging.getLogger(name=__name__)
+
class LeapNetworkChecker(object):
"""
all network related checks
@@ -51,7 +53,7 @@ class LeapNetworkChecker(object):
def check_tunnel_default_interface(self):
"""
- Raises an TunnelNotDefaultRouteError
+ Raises an TunnelNotDefaultRouteError
(including when no routes are present)
"""
if not platform.system() == "Linux":
@@ -71,7 +73,6 @@ class LeapNetworkChecker(object):
if not destination == '00000000' or not iface == 'tun0':
raise exceptions.TunnelNotDefaultRouteError()
-
def get_default_interface_gateway(self):
"""only impletemented for linux so far."""
if not platform.system() == "Linux":
diff --git a/src/leap/base/network.py b/src/leap/base/network.py
index 159e9b21..4a90f2f4 100644
--- a/src/leap/base/network.py
+++ b/src/leap/base/network.py
@@ -21,13 +21,15 @@ class NetworkChecker(object):
def __init__(self, *args, **kwargs):
self.status_signals = kwargs.pop('status_signals', None)
self.watcher_cb = kwargs.pop('status_signals', None)
- self.error_cb = kwargs.pop('error_cb',
- lambda exc: logger.error("%s", exc.message))
+ self.error_cb = kwargs.pop(
+ 'error_cb',
+ lambda exc: logger.error("%s", exc.message))
self.shutdown = threading.Event()
self.checker = LeapNetworkChecker()
def start(self):
- self.process_handle = self._launch_recurrent_network_checks((self.error_cb,))
+ self.process_handle = self._launch_recurrent_network_checks(
+ (self.error_cb,))
def stop(self):
self.shutdown.set()
@@ -51,7 +53,8 @@ class NetworkChecker(object):
sleep(1)
observer_dict = dict(((
- observer, process_events(observer)) for observer in fail_callbacks))
+ observer,
+ process_events(observer)) for observer in fail_callbacks))
while not self.shutdown.is_set():
try:
self.checker.check_tunnel_default_interface()
@@ -65,7 +68,7 @@ class NetworkChecker(object):
self.shutdown.clear()
def _launch_recurrent_network_checks(self, fail_callbacks):
- #we need to wrap the fail callback in a turple
+ #we need to wrap the fail callback in a tuple
watcher = launch_thread(
self._network_checks_thread,
(fail_callbacks,))
diff --git a/src/leap/base/tests/test_checks.py b/src/leap/base/tests/test_checks.py
index 30746991..bec09ce6 100644
--- a/src/leap/base/tests/test_checks.py
+++ b/src/leap/base/tests/test_checks.py
@@ -74,7 +74,8 @@ class LeapNetworkCheckTest(BaseLeapTest):
"Iface\tDestination Gateway\t"
"Flags\tRefCntd\tUse\tMetric\t"
"Mask\tMTU\tWindow\tIRTT\n"
- "wlan0\t00000000\t0102A8C0\t0003\t0\t0\t0\t00000000\t0\t0\t0")
+ "wlan0\t00000000\t0102A8C0\t"
+ "0003\t0\t0\t0\t00000000\t0\t0\t0")
checker.check_tunnel_default_interface()
with patch('leap.base.checks.open', create=True) as mock_open:
diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py
index 000db8c9..e48666a4 100644
--- a/src/leap/baseapp/mainwindow.py
+++ b/src/leap/baseapp/mainwindow.py
@@ -10,6 +10,7 @@ from leap.baseapp.log import LogPaneMixin
from leap.baseapp.systray import StatusAwareTrayIconMixin
from leap.baseapp.network import NetworkCheckerAppMixin
from leap.baseapp.leap_app import MainWindowMixin
+from leap.baseapp import dialogs
logger = logging.getLogger(name=__name__)
@@ -68,6 +69,6 @@ class LeapWindow(QtGui.QMainWindow,
# check headless = False before
# launching dialog.
# (so Qt tests can assert stuff)
-
- dialog = ErrorDialog()
+
+ dialog = dialogs.ErrorDialog()
dialog.warningMessage(message, 'error')
diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py
index c73e8062..f1859c7a 100644
--- a/src/leap/baseapp/network.py
+++ b/src/leap/baseapp/network.py
@@ -1,10 +1,10 @@
from __future__ import print_function
+
import logging
-import time
logger = logging.getLogger(name=__name__)
from leap.base.network import NetworkChecker
-from leap.baseapp.dialogs import ErrorDialog
+#from leap.baseapp.dialogs import ErrorDialog
class NetworkCheckerAppMixin(object):
@@ -20,4 +20,3 @@ class NetworkCheckerAppMixin(object):
debug=self.debugmode)
self.network_checker.run_checks()
-