From 06883461f2daa616b2e3c842f53d9422703cd9c7 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 28 Aug 2012 23:08:39 +0900 Subject: eip_checks called from main app. removed "configuration" object. checks are called from conductor. --- src/leap/eip/checks.py | 12 +++++++++--- src/leap/eip/eipconnection.py | 24 +++++++++--------------- src/leap/eip/openvpnconnection.py | 3 +++ 3 files changed, 21 insertions(+), 18 deletions(-) (limited to 'src/leap/eip') diff --git a/src/leap/eip/checks.py b/src/leap/eip/checks.py index 7ef80cae..794e69e1 100644 --- a/src/leap/eip/checks.py +++ b/src/leap/eip/checks.py @@ -2,7 +2,9 @@ import json import logging import os +logging.basicConfig() logger = logging.getLogger(name=__name__) +logger.setLevel(logging.DEBUG) import requests @@ -31,7 +33,7 @@ class EIPChecker(object): self.config = None self.fetcher = fetcher - def run_all(self, checker=None): + def run_all(self, checker=None, skip_download=False): """ runs all checks in a row. will raise if some error encountered. @@ -50,8 +52,8 @@ class EIPChecker(object): checker.check_default_eipconfig() checker.check_is_there_default_provider() - checker.fetch_definition() - checker.fetch_eip_config() + checker.fetch_definition(skip_download=skip_download) + checker.fetch_eip_config(skip_download=skip_download) checker.check_complete_eip_config() #checker.ping_gateway() @@ -70,6 +72,7 @@ class EIPChecker(object): # dump it right now, we can get an in-memory # config object and dump it to disk in a # later moment + logger.debug('checking default eip config') if not self._is_there_default_eipconfig(): self._dump_default_eipconfig() @@ -84,6 +87,7 @@ class EIPChecker(object): # else: self.get_eipconfig # XXX parse EIPConfig. # XXX get default_provider. + logger.debug('checking default provider') eipcfg = self._get_default_eipconfig_path() with open(eipcfg, 'r') as fp: config = json.load(fp) @@ -103,8 +107,10 @@ class EIPChecker(object): # TODO: # - Implement diff # - overwrite if different. + logger.debug('fetching definition') if skip_download: + logger.debug('(fetching def skipped)') return True if config is None: config = self.config diff --git a/src/leap/eip/eipconnection.py b/src/leap/eip/eipconnection.py index 2dfc1503..aea560c9 100644 --- a/src/leap/eip/eipconnection.py +++ b/src/leap/eip/eipconnection.py @@ -8,7 +8,7 @@ logging.basicConfig() logger = logging.getLogger(name=__name__) logger.setLevel(logging.DEBUG) -from leap.base.connection import ConnectionError +from leap.eip.checks import EIPChecker from leap.eip import exceptions as eip_exceptions from leap.eip.openvpnconnection import OpenVPNConnection @@ -22,17 +22,23 @@ class EIPConnection(OpenVPNConnection): Status updates (connected, bandwidth, etc) are signaled to the GUI. """ - def __init__(self, *args, **kwargs): + def __init__(self, checker=EIPChecker, *args, **kwargs): self.settingsfile = kwargs.get('settingsfile', None) self.logfile = kwargs.get('logfile', None) self.error_queue = [] - #self.desired_con_state = None # not in use status_signals = kwargs.pop('status_signals', None) self.status = EIPConnectionStatus(callbacks=status_signals) + self.checker = checker() super(EIPConnection, self).__init__(*args, **kwargs) + def run_checks(self, skip_download=False): + """ + run all eip checks previous to attempting a connection + """ + self.checker.run_all(skip_download=skip_download) + def connect(self): """ entry point for connection process @@ -128,10 +134,6 @@ class EIPConnection(OpenVPNConnection): unicode(except_msg)) return conn_result -"""generic watcher object that keeps track of connection status""" -# This should be deprecated in favor of daemon mode + management -# interface. But we can leave it here for debug purposes. - class EIPConnectionStatus(object): """ @@ -272,11 +274,3 @@ class EIPConnectionStatus(object): for cb in self.callbacks: if callable(cb): cb(self) - - -# XXX move to exceptions -class EIPClientError(ConnectionError): - """ - base EIPClient Exception - """ - pass diff --git a/src/leap/eip/openvpnconnection.py b/src/leap/eip/openvpnconnection.py index 3972b617..5f67d27a 100644 --- a/src/leap/eip/openvpnconnection.py +++ b/src/leap/eip/openvpnconnection.py @@ -59,11 +59,14 @@ to be triggered for each one of them. self.port = None self.proto = None + # XXX move all error messages + # into a more encapsulated object. self.missing_pkexec = False self.missing_auth_agent = False self.bad_keyfile_perms = False self.missing_vpn_keyfile = False self.missing_provider = False + self.missing_definition = False self.bad_provider = False #XXX workaround for signaling -- cgit v1.2.3