summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2014-01-09 14:24:33 -0300
committerIvan Alejandro <ivanalejandro0@gmail.com>2014-01-09 14:27:53 -0300
commit785380dfa7b3f6205b52be2a90afa9b0afa04c5e (patch)
treeb110ec0606c7e63ea5f6963f25691c5c79ccb803
parentc9644f1bdbd26e3c54d8849433d8cfb9fc05a3e7 (diff)
Add flag to disable version check.
-rw-r--r--src/leap/bitmask/app.py3
-rw-r--r--src/leap/bitmask/config/flags.py9
-rw-r--r--src/leap/bitmask/provider/providerbootstrapper.py34
-rw-r--r--src/leap/bitmask/util/leap_argparse.py8
4 files changed, 39 insertions, 15 deletions
diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py
index b16a51aa..d50743d6 100644
--- a/src/leap/bitmask/app.py
+++ b/src/leap/bitmask/app.py
@@ -200,6 +200,9 @@ def main():
from leap.common.config.baseconfig import BaseConfig
flags.STANDALONE = standalone
flags.MAIL_LOGFILE = mail_logfile
+ flags.APP_VERSION_CHECK = opts.app_version_check
+ flags.API_VERSION_CHECK = opts.api_version_check
+
BaseConfig.standalone = standalone
logger = add_logger_handlers(debug, logfile)
diff --git a/src/leap/bitmask/config/flags.py b/src/leap/bitmask/config/flags.py
index ba1b65b9..b1576c32 100644
--- a/src/leap/bitmask/config/flags.py
+++ b/src/leap/bitmask/config/flags.py
@@ -32,3 +32,12 @@ WARNING: You should NOT use this kind of flags unless you're sure of what
STANDALONE = False
MAIL_LOGFILE = None
+
+# The APP/API version check flags are used to provide a way to skip
+# that checks.
+# This can be used for:
+# - allow the use of a client that is not compatible with a provider.
+# - use a development version of the client with an older version number
+# since it's not released yet, and it is compatible with a newer provider.
+APP_VERSION_CHECK = True
+API_VERSION_CHECK = True
diff --git a/src/leap/bitmask/provider/providerbootstrapper.py b/src/leap/bitmask/provider/providerbootstrapper.py
index 52ebacd2..531d255e 100644
--- a/src/leap/bitmask/provider/providerbootstrapper.py
+++ b/src/leap/bitmask/provider/providerbootstrapper.py
@@ -24,6 +24,7 @@ import sys
import requests
+from leap.bitmask.config import flags
from leap.bitmask.config.providerconfig import ProviderConfig, MissingCACert
from leap.bitmask.util.request_helpers import get_content
from leap.bitmask import util
@@ -206,9 +207,11 @@ class ProviderBootstrapper(AbstractBootstrapper):
# end refactor, more or less...
# XXX Watch out, have to check the supported api yet.
else:
- if not provider.supports_client(min_client_version):
- self._signaler.signal(self._signaler.PROV_UNSUPPORTED_CLIENT)
- raise UnsupportedClientVersionError()
+ if flags.APP_VERSION_CHECK:
+ if not provider.supports_client(min_client_version):
+ self._signaler.signal(
+ self._signaler.PROV_UNSUPPORTED_CLIENT)
+ raise UnsupportedClientVersionError()
provider_definition, mtime = get_content(res)
@@ -217,18 +220,19 @@ class ProviderBootstrapper(AbstractBootstrapper):
provider_config.save(["leap", "providers",
domain, "provider.json"])
- api_version = provider_config.get_api_version()
- if provider.supports_api(api_version):
- logger.debug("Provider definition has been modified")
- else:
- api_supported = ', '.join(provider.SUPPORTED_APIS)
- error = ('Unsupported provider API version. '
- 'Supported versions are: {0}. '
- 'Found: {1}.').format(api_supported, api_version)
-
- logger.error(error)
- self._signaler.signal(self._signaler.PROV_UNSUPPORTED_API)
- raise UnsupportedProviderAPI(error)
+ if flags.API_VERSION_CHECK:
+ api_version = provider_config.get_api_version()
+ if provider.supports_api(api_version):
+ logger.debug("Provider definition has been modified")
+ else:
+ api_supported = ', '.join(provider.SUPPORTED_APIS)
+ error = ('Unsupported provider API version. '
+ 'Supported versions are: {0}. '
+ 'Found: {1}.').format(api_supported, api_version)
+
+ logger.error(error)
+ self._signaler.signal(self._signaler.PROV_UNSUPPORTED_API)
+ raise UnsupportedProviderAPI(error)
def run_provider_select_checks(self, domain, download_if_needed=False):
"""
diff --git a/src/leap/bitmask/util/leap_argparse.py b/src/leap/bitmask/util/leap_argparse.py
index 6703b600..280573f1 100644
--- a/src/leap/bitmask/util/leap_argparse.py
+++ b/src/leap/bitmask/util/leap_argparse.py
@@ -62,6 +62,14 @@ Launches Bitmask""", epilog=epilog)
help='Repair mailboxes for a given account. '
'Use when upgrading versions after a schema '
'change.')
+ parser.add_argument('-N', '--no-app-version-check', default=True,
+ action="store_false", dest="app_version_check",
+ help='Skip the app version compatibility check with '
+ 'the provider.')
+ parser.add_argument('-M', '--no-api-version-check', default=True,
+ action="store_false", dest="api_version_check",
+ help='Skip the api version compatibility check with '
+ 'the provider.')
# Not in use, we might want to reintroduce them.
#parser.add_argument('-i', '--no-provider-checks',