From ddf5e546916ad94c62b1e42b6f03831f906b2f29 Mon Sep 17 00:00:00 2001 From: antialias Date: Mon, 24 Sep 2012 17:34:25 -0400 Subject: improved network checks on the way to a network checker. --- src/leap/eip/checks.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/leap/eip/checks.py') diff --git a/src/leap/eip/checks.py b/src/leap/eip/checks.py index 9b7b1cee..82940fd3 100644 --- a/src/leap/eip/checks.py +++ b/src/leap/eip/checks.py @@ -70,21 +70,20 @@ class LeapNetworkChecker(object): checker.is_internet_up() checker.ping_gateway() - def test_internet_connection(self): - # XXX we're not passing the error anywhere. - # XXX we probably should raise an exception here? - # unless we use this as smoke test + def check_internet_connection(self): try: # XXX remove this hardcoded random ip requests.get('http://216.172.161.165') except (requests.HTTPError, requests.RequestException) as e: - self.error = e.message - except requests.ConenctionError as e: + raise eipexceptions.NoInternetConnection(e.message) + except requests.ConnectionError as e: + error = "Unidentified Connection Error" if e.message == "[Errno 113] No route to host": if not self.is_internet_up(): - self.error = "No valid internet connection found." + error = "No valid internet connection found." else: - self.error = "Provider server appears to be down." + error = "Provider server appears to be down." + raise eipexceptions.NoInternetConnection(error) def is_internet_up(self): iface, gateway = self.get_default_interface_gateway() -- cgit v1.2.3