summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/config
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2013-09-18 14:27:15 -0300
committerIvan Alejandro <ivanalejandro0@gmail.com>2013-09-18 18:24:20 -0300
commit6cd19c3b67d76268bab5f93d3168164ec02f603d (patch)
treee86a305064345aab3ea29c356bf281411c331bca /src/leap/bitmask/config
parente0734dd4c3c529c99b7c90d8db1dfb9f09551b24 (diff)
Move STANDALONE flag to a module and unify paths queries.
Diffstat (limited to 'src/leap/bitmask/config')
-rw-r--r--src/leap/bitmask/config/flags.py32
-rw-r--r--src/leap/bitmask/config/leapsettings.py15
-rw-r--r--src/leap/bitmask/config/providerconfig.py11
3 files changed, 40 insertions, 18 deletions
diff --git a/src/leap/bitmask/config/flags.py b/src/leap/bitmask/config/flags.py
new file mode 100644
index 00000000..98395def
--- /dev/null
+++ b/src/leap/bitmask/config/flags.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+# flags.py
+# Copyright (C) 2013 LEAP
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+This file is meant to be used to store global flags that affect the
+application.
+
+WARNING: You should NOT use this kind of flags unless you're sure of what
+ you're doing, and someone else tells you that you're right.
+ Most of the times there is a better and safer alternative.
+"""
+
+# The STANDALONE flag is used to:
+# - define a different set of messages for the application when is running
+# inside of a bundle or installed system wide.
+# - use a relative or system wide path to find the configuration files.
+# - search for binaries inside the bundled app instead of the system ones.
+# e.g.: openvpn, gpg
+STANDALONE = False
diff --git a/src/leap/bitmask/config/leapsettings.py b/src/leap/bitmask/config/leapsettings.py
index 7d8b5977..338fa475 100644
--- a/src/leap/bitmask/config/leapsettings.py
+++ b/src/leap/bitmask/config/leapsettings.py
@@ -24,7 +24,7 @@ import logging
from PySide import QtCore
from leap.common.check import leap_assert, leap_assert_type
-from leap.common.config import get_path_prefix
+from leap.bitmask.util import get_path_prefix
logger = logging.getLogger(__name__)
@@ -71,15 +71,8 @@ class LeapSettings(object):
# values
GATEWAY_AUTOMATIC = "Automatic"
- def __init__(self, standalone=False):
- """
- Constructor
-
- :param standalone: parameter used to define the location of the config.
- :type standalone: bool
- """
- self._path_prefix = get_path_prefix(standalone=standalone)
- settings_path = os.path.join(self._path_prefix,
+ def __init__(self):
+ settings_path = os.path.join(get_path_prefix(),
"leap", self.CONFIG_NAME)
self._settings = QtCore.QSettings(settings_path,
@@ -132,7 +125,7 @@ class LeapSettings(object):
# other things, not just the directories
providers = []
try:
- providers_path = os.path.join(self._path_prefix,
+ providers_path = os.path.join(get_path_prefix(),
"leap", "providers")
providers = os.listdir(providers_path)
except Exception as e:
diff --git a/src/leap/bitmask/config/providerconfig.py b/src/leap/bitmask/config/providerconfig.py
index a7808399..c8c8a59e 100644
--- a/src/leap/bitmask/config/providerconfig.py
+++ b/src/leap/bitmask/config/providerconfig.py
@@ -21,10 +21,11 @@ Provider configuration
import logging
import os
-from leap.bitmask.config.provider_spec import leap_provider_spec
from leap.common.check import leap_check
from leap.common.config.baseconfig import BaseConfig, LocalizedKey
+from leap.bitmask.config.provider_spec import leap_provider_spec
from leap.bitmask.services import get_service_display_name
+from leap.bitmask.util import get_path_prefix
logger = logging.getLogger(__name__)
@@ -151,13 +152,9 @@ class ProviderConfig(BaseConfig):
:type about_to_download: bool
"""
- cert_path = os.path.join(self.get_path_prefix(),
- "leap",
- "providers",
+ cert_path = os.path.join(get_path_prefix(), "leap", "providers",
self.get_domain(),
- "keys",
- "ca",
- "cacert.pem")
+ "keys", "ca", "cacert.pem")
if not about_to_download:
cert_exists = os.path.exists(cert_path)