summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/leap/gui/mainwindow.py24
-rw-r--r--src/leap/services/eip/vpnlaunchers.py9
2 files changed, 22 insertions, 11 deletions
diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py
index 78ff9101..8464d313 100644
--- a/src/leap/gui/mainwindow.py
+++ b/src/leap/gui/mainwindow.py
@@ -29,6 +29,7 @@ from ui_mainwindow import Ui_MainWindow
from leap.config.providerconfig import ProviderConfig
from leap.crypto.srpauth import SRPAuth
from leap.services.eip.vpn import VPN
+from leap.services.eip.vpnlaunchers import VPNLauncherException
from leap.services.eip.providerbootstrapper import ProviderBootstrapper
from leap.services.eip.eipbootstrapper import EIPBootstrapper
from leap.services.eip.eipconfig import EIPConfig
@@ -546,17 +547,20 @@ class MainWindow(QtGui.QMainWindow):
self._download_eip_config()
def _start_eip(self):
- self._vpn.start(eipconfig=self._eip_config,
- providerconfig=self._provider_config,
- socket_host="localhost",
- socket_port=str(random.randint(1000, 9999)))
- self._vpn_systray.setVisible(True)
+ try:
+ self._vpn.start(eipconfig=self._eip_config,
+ providerconfig=self._provider_config,
+ socket_host="localhost",
+ socket_port=str(random.randint(1000, 9999)))
+ self._vpn_systray.setVisible(True)
+ self.ui.btnEipStartStop.setText(self.tr("Stop EIP"))
+ self.ui.btnEipStartStop.clicked.disconnect(
+ self._start_eip)
+ self.ui.btnEipStartStop.clicked.connect(
+ self._stop_eip)
+ except VPNLauncherException as e:
+ self._set_eip_status("%s" % (e,))
self.ui.btnEipStartStop.setEnabled(True)
- self.ui.btnEipStartStop.setText(self.tr("Stop EIP"))
- self.ui.btnEipStartStop.clicked.disconnect(
- self._start_eip)
- self.ui.btnEipStartStop.clicked.connect(
- self._stop_eip)
def _stop_eip(self):
self._vpn.set_should_quit()
diff --git a/src/leap/services/eip/vpnlaunchers.py b/src/leap/services/eip/vpnlaunchers.py
index cf817321..9f2967aa 100644
--- a/src/leap/services/eip/vpnlaunchers.py
+++ b/src/leap/services/eip/vpnlaunchers.py
@@ -34,6 +34,10 @@ from leap.util.check import leap_assert, leap_assert_type
logger = logging.getLogger(__name__)
+class VPNLauncherException(Exception):
+ pass
+
+
class VPNLauncher:
"""
Abstract launcher class
@@ -153,6 +157,8 @@ class LinuxVPNLauncher(VPNLauncher):
"""
Returns the platform dependant vpn launching command
+ Might raise VPNException.
+
@param eipconfig: eip configuration object
@type eipconfig: EIPConfig
@param providerconfig: provider specific configuration
@@ -174,7 +180,8 @@ class LinuxVPNLauncher(VPNLauncher):
leap_assert(socket_port, "We need a socket port!")
openvpn_possibilities = which(self.OPENVPN_BIN)
- leap_assert(len(openvpn_possibilities) > 0, "We couldn't find openvpn")
+ if len(openvpn_possibilities) == 0:
+ raise VPNLauncherException("We couldn't find openvpn")
openvpn = openvpn_possibilities[0]
args = []