summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-09-18 11:11:43 +0900
committerkali <kali@leap.se>2012-09-18 19:10:13 +0900
commit0d35f2a82bf15504ace2135af3e0c66ae1c16874 (patch)
tree1915d4f9326ec4f44c553ebad37032f57f6e636a /src
parent430b6326d06d81c44d534543c8e9684a5c0fcb15 (diff)
do_branding command added to setup
Diffstat (limited to 'src')
-rw-r--r--src/leap/__init__.py5
-rw-r--r--src/leap/app.py2
-rw-r--r--src/leap/base/config.py2
-rw-r--r--src/leap/base/constants.py15
-rw-r--r--src/leap/base/tests/test_config.py2
-rw-r--r--src/leap/baseapp/eip.py19
-rw-r--r--src/leap/certs/__init__.py7
-rw-r--r--src/leap/eip/checks.py14
-rw-r--r--src/leap/eip/eipconnection.py4
-rw-r--r--src/leap/eip/openvpnconnection.py7
-rw-r--r--src/leap/eip/specs.py10
11 files changed, 56 insertions, 31 deletions
diff --git a/src/leap/__init__.py b/src/leap/__init__.py
index 75bddd6d..5e003931 100644
--- a/src/leap/__init__.py
+++ b/src/leap/__init__.py
@@ -28,3 +28,8 @@ except ImportError:
pass
__full_version__ = __appname__ + '/' + str(__version__)
+
+try:
+ from leap._branding import BRANDING as __branding
+except ImportError:
+ __branding = {}
diff --git a/src/leap/app.py b/src/leap/app.py
index b721468f..1aebfca2 100644
--- a/src/leap/app.py
+++ b/src/leap/app.py
@@ -44,7 +44,7 @@ def main():
fileh.setFormatter(formatter)
logger.addHandler(fileh)
- logger.debug('args: %s' % opts)
+ #logger.debug('args: %s' % opts)
logger.info('Starting app')
logger.info('Running client version %s', VERSION)
diff --git a/src/leap/base/config.py b/src/leap/base/config.py
index 5a52637c..e896ffd2 100644
--- a/src/leap/base/config.py
+++ b/src/leap/base/config.py
@@ -239,7 +239,7 @@ def get_config_file(filename, folder=None):
def get_default_provider_path():
default_subpath = os.path.join("providers",
- constants.DEFAULT_TEST_PROVIDER)
+ constants.DEFAULT_PROVIDER)
default_provider_path = get_config_file(
'',
folder=default_subpath)
diff --git a/src/leap/base/constants.py b/src/leap/base/constants.py
index 6266c693..f3e24715 100644
--- a/src/leap/base/constants.py
+++ b/src/leap/base/constants.py
@@ -1,23 +1,26 @@
"""constants to be used in base module"""
-APP_NAME = "leap"
+from leap import __branding
+APP_NAME = __branding.get("short_name", "leap")
# default provider placeholder
# using `example.org` we make sure that this
# is not going to be resolved during the tests phases
# (we expect testers to add it to their /etc/hosts
-DEFAULT_TEST_PROVIDER = "testprovider.example.org"
+DEFAULT_PROVIDER = __branding.get(
+ "provider_domain",
+ "testprovider.example.org")
-DEFINITION_EXPECTED_PATH = "provider-definition.json"
+DEFINITION_EXPECTED_PATH = "definition.json"
DEFAULT_PROVIDER_DEFINITION = {
- u'api_uri': u'https://api.testprovider.example.org/',
+ u'api_uri': u'https://api.%s/' % DEFAULT_PROVIDER,
u'api_version': u'0.1.0',
u'ca_cert': u'8aab80ae4326fd30721689db813733783fe0bd7e',
- u'ca_cert_uri': u'https://testprovider.example.org/cacert.pem',
+ u'ca_cert_uri': u'https://%s/cacert.pem' % DEFAULT_PROVIDER,
u'description': {u'en': u'This is a test provider'},
u'display_name': {u'en': u'Test Provider'},
- u'domain': u'testprovider.example.org',
+ u'domain': u'%s' % DEFAULT_PROVIDER,
u'enrollment_policy': u'open',
u'public_key': u'cb7dbd679f911e85bc2e51bd44afd7308ee19c21',
u'serial': 1,
diff --git a/src/leap/base/tests/test_config.py b/src/leap/base/tests/test_config.py
index 40461b99..74b06119 100644
--- a/src/leap/base/tests/test_config.py
+++ b/src/leap/base/tests/test_config.py
@@ -218,7 +218,7 @@ class ConfigHelperFunctions(BaseLeapTest):
config.get_default_provider_path(),
os.path.expanduser(
'~/.config/leap/providers/%s/' %
- constants.DEFAULT_TEST_PROVIDER)
+ constants.DEFAULT_PROVIDER)
)
# validate ip
diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py
index 515ae58d..ff6a79ac 100644
--- a/src/leap/baseapp/eip.py
+++ b/src/leap/baseapp/eip.py
@@ -1,5 +1,7 @@
+from __future__ import print_function
import logging
import time
+import sys
from PyQt4 import QtCore
@@ -38,8 +40,9 @@ class EIPConductorAppMixin(object):
debug=self.debugmode,
ovpn_verbosity=opts.openvpn_verb)
- # XXX remove skip download when sample service is ready
- self.conductor.run_checks(skip_download=True)
+ # XXX get skip_download from cli flag
+ skip_download = False
+ self.conductor.run_checks(skip_download=skip_download)
self.error_check()
# XXX should receive "ready" signal
@@ -58,13 +61,11 @@ class EIPConductorAppMixin(object):
"""
logger.debug('error check')
- #####################################
- # XXX refactor in progress (by #504)
-
errq = self.conductor.error_queue
while errq.qsize() != 0:
logger.debug('%s errors left in conductor queue', errq.qsize())
- error = errq.get()
+ # we get exception and original traceback from queue
+ error, tb = errq.get()
# redundant log, debugging the loop.
logger.error('%s: %s', error.__class__.__name__, error.message)
@@ -73,10 +74,8 @@ class EIPConductorAppMixin(object):
self.handle_eip_error(error)
else:
- # This is not quite working. FIXME
- import traceback
- traceback.print_exc()
- raise error
+ # deprecated form of raising exception.
+ raise error, None, tb
if error.failfirst is True:
break
diff --git a/src/leap/certs/__init__.py b/src/leap/certs/__init__.py
new file mode 100644
index 00000000..c4d009b1
--- /dev/null
+++ b/src/leap/certs/__init__.py
@@ -0,0 +1,7 @@
+import os
+
+_where = os.path.split(__file__)[0]
+
+
+def where(filename):
+ return os.path.join(_where, filename)
diff --git a/src/leap/eip/checks.py b/src/leap/eip/checks.py
index f368c551..aea5a5d7 100644
--- a/src/leap/eip/checks.py
+++ b/src/leap/eip/checks.py
@@ -257,7 +257,7 @@ class ProviderCertChecker(object):
return True
def _get_client_cert_uri(self):
- return "https://%s/cert/get" % (baseconstants.DEFAULT_TEST_PROVIDER)
+ return "https://%s/cert/get" % (baseconstants.DEFAULT_PROVIDER)
def _get_client_cert_path(self):
# MVS+ : get provider path
@@ -414,14 +414,18 @@ class EIPConfigChecker(object):
def _get_provider_definition_uri(self, domain=None, path=None):
if domain is None:
- domain = baseconstants.DEFAULT_TEST_PROVIDER
+ domain = baseconstants.DEFAULT_PROVIDER
if path is None:
path = baseconstants.DEFINITION_EXPECTED_PATH
- return "https://%s/%s" % (domain, path)
+ uri = u"https://%s/%s" % (domain, path)
+ logger.debug('getting provider definition from %s' % uri)
+ return uri
def _get_eip_service_uri(self, domain=None, path=None):
if domain is None:
- domain = baseconstants.DEFAULT_TEST_PROVIDER
+ domain = baseconstants.DEFAULT_PROVIDER
if path is None:
path = eipconstants.EIP_SERVICE_EXPECTED_PATH
- return "https://%s/%s" % (domain, path)
+ uri = "https://%s/%s" % (domain, path)
+ logger.debug('getting eip service file from %s', uri)
+ return uri
diff --git a/src/leap/eip/eipconnection.py b/src/leap/eip/eipconnection.py
index 3a879f01..d1c84b2a 100644
--- a/src/leap/eip/eipconnection.py
+++ b/src/leap/eip/eipconnection.py
@@ -4,6 +4,7 @@ EIP Connection Class
from __future__ import (absolute_import,)
import logging
import Queue
+import sys
from leap.eip.checks import EIPConfigChecker
from leap.eip import config as eipconfig
@@ -48,7 +49,8 @@ class EIPConnection(OpenVPNConnection):
self.config_checker.run_all(skip_download=skip_download)
self.run_openvpn_checks()
except Exception as exc:
- self.error_queue.put(exc)
+ exc_traceback = sys.exc_info()[2]
+ self.error_queue.put((exc, exc_traceback))
def connect(self):
"""
diff --git a/src/leap/eip/openvpnconnection.py b/src/leap/eip/openvpnconnection.py
index c280f70d..65683485 100644
--- a/src/leap/eip/openvpnconnection.py
+++ b/src/leap/eip/openvpnconnection.py
@@ -117,11 +117,10 @@ to be triggered for each one of them.
"""
try:
eip_config.check_vpn_keys()
- except eip_exceptions.EIPInitNoKeyFileError:
- self.missing_vpn_keyfile = True
except eip_exceptions.EIPInitBadKeyFilePermError:
- logger.error('error while checking vpn keys')
- self.bad_keyfile_perms = True
+ logger.error('Bad VPN Keys permission!')
+ # do nothing now
+ # and raise the rest ...
def _launch_openvpn(self):
"""
diff --git a/src/leap/eip/specs.py b/src/leap/eip/specs.py
index e617574c..05aef590 100644
--- a/src/leap/eip/specs.py
+++ b/src/leap/eip/specs.py
@@ -1,15 +1,21 @@
from __future__ import (unicode_literals)
import os
+from leap import __branding
from leap.base import config as baseconfig
+PROVIDER_CA_CERT = __branding.get(
+ 'provider_ca_file',
+ 'testprovider-ca-cert.pem')
provider_ca_path = lambda: unicode(os.path.join(
baseconfig.get_default_provider_path(),
'keys', 'ca',
- 'testprovider-ca-cert.pem'
+ PROVIDER_CA_CERT
))
+PROVIDER_DOMAIN = __branding.get('provider_domain', 'testprovider.example.org')
+
client_cert_path = lambda: unicode(os.path.join(
baseconfig.get_default_provider_path(),
@@ -20,7 +26,7 @@ client_cert_path = lambda: unicode(os.path.join(
eipconfig_spec = {
'provider': {
'type': unicode,
- 'default': u"testprovider.example.org",
+ 'default': u"%s" % PROVIDER_DOMAIN,
'required': True,
},
'transport': {