From f5948577939dce4f85dd86f37c0823a0a852e074 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 21 Aug 2012 03:11:32 +0900 Subject: fix imports + style cleaning --- src/leap/base/connection.py | 7 +++++-- src/leap/baseapp/mainwindow.py | 2 +- src/leap/eip/eipconnection.py | 13 +++++++++---- src/leap/eip/openvpnconnection.py | 35 +++++++++++++++++++++-------------- 4 files changed, 36 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/leap/base/connection.py b/src/leap/base/connection.py index 6e5086b3..cd0ae565 100644 --- a/src/leap/base/connection.py +++ b/src/leap/base/connection.py @@ -2,6 +2,9 @@ Base Connection Classs """ from __future__ import (division, unicode_literals, print_function) + +#XXX move these imports to util.coroutines!!! + #import threading #from functools import partial import logging @@ -11,8 +14,8 @@ import logging #from leap.eip.vpnwatcher import EIPConnectionStatus, status_watcher from leap.eip.vpnmanager import ConnectionRefusedError -from leap.configuration import Configuration -from leap.authentication import Authentication +from leap.base.configuration import Configuration +from leap.base.authentication import Authentication logger = logging.getLogger(name=__name__) diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 544667f4..4d1eee79 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -19,7 +19,7 @@ from leap.eip.config import (EIPInitBadKeyFilePermError) # from leap.eip import exceptions as eip_exceptions from leap.gui import mainwindow_rc -from leap.EIPConnection import EIPConnection +from leap.eip.eipconnection import EIPConnection class LeapWindow(QMainWindow): diff --git a/src/leap/eip/eipconnection.py b/src/leap/eip/eipconnection.py index f16f01f5..a0fdd77d 100644 --- a/src/leap/eip/eipconnection.py +++ b/src/leap/eip/eipconnection.py @@ -1,9 +1,15 @@ """ EIP Connection Class """ +from __future__ import (absolute_import,) +import logging + +logger = logging.getLogger(name=__name__) + +from leap.eip.openvpnconnection import ( + OpenVPNConnection, ConnectionRefusedError) +from leap.base.connection import ConnectionError -from leap.OpenVPNConnection import OpenVPNConnection, MissingSocketError, ConnectionRefusedError -from leap.Connection import ConnectionError class EIPConnection(OpenVPNConnection): """ @@ -39,7 +45,6 @@ class EIPConnection(OpenVPNConnection): """ self._disconnect() self.status.change_to(self.status.DISCONNECTED) - pass def shutdown(self): """ @@ -262,7 +267,7 @@ class EIPConnectionStatus(object): cb(self) - +# XXX move to exceptions class EIPClientError(ConnectionError): """ base EIPClient Exception diff --git a/src/leap/eip/openvpnconnection.py b/src/leap/eip/openvpnconnection.py index a26059a7..d3ce3578 100644 --- a/src/leap/eip/openvpnconnection.py +++ b/src/leap/eip/openvpnconnection.py @@ -12,9 +12,10 @@ from functools import partial logger = logging.getLogger(name=__name__) -from leap.utils.coroutines import spawn_and_watch_process -from leap.baseapp.config import get_config -from leap.Connection import Connection +from leap.util.coroutines import spawn_and_watch_process +from leap.eip.config import get_config +from leap.base.connection import Connection + class OpenVPNConnection(Connection): """ @@ -23,7 +24,13 @@ class OpenVPNConnection(Connection): """ # Connection Methods - def __init__(self, config_file=None, watcher_cb=None,host="/tmp/.eip.sock", port="unix", password=None): + def __init__(self, config_file=None, + watcher_cb=None, + debug=False, + host="/tmp/.eip.sock", + port="unix", + password=None, + *args, **kwargs): #XXX FIXME #change watcher_cb to line_observer """ @@ -66,20 +73,20 @@ to be triggered for each one of them. #manage a connection error self.with_errors = False - - def _set_command_mockup(self): - """ - sets command and args for a command mockup - that just mimics the output from the real thing - """ - command, args = get_vpn_stdout_mockup() - self.command, self.args = command, args + #def _set_command_mockup(self): + #""" + #sets command and args for a command mockup + #that just mimics the output from the real thing + #""" + #command, args = get_vpn_stdout_mockup() + #self.command, self.args = command, args def _get_config(self): """ retrieves the config options from defaults or home file, or config file passed in command line. """ + #XXX merge! was changed in test-eip branch!!! config = get_config(config_file=self.config_file) self.config = config @@ -97,8 +104,8 @@ to be triggered for each one of them. self.command = command #print("debug: command = %s" % command) self.args = args - else: - self._set_command_mockup() + #else: + #self._set_command_mockup() if config.has_option('openvpn', 'autostart'): autostart = config.get('openvpn', 'autostart') -- cgit v1.2.3