diff options
author | Kali Kaneko <kali@leap.se> | 2015-08-12 12:17:30 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2015-08-12 12:17:30 -0400 |
commit | bb808bb42046eb71411b2a4528e1820801428a7a (patch) | |
tree | aa9179230bdfbf0db86daae364f384141dbd3e7f | |
parent | 612deb39f759d9c5a86b78fc012b8a8b56fcb838 (diff) |
[bug] fail more clearly if we got incorrect version string
on the sumo tarball, the _version file for leap/bitmask submodule wasn't
being frozen, and hence BITMASK_VERSION was None. this was breaking the
provider tests w/o any clear error message.
- Related: #7322
-rw-r--r-- | src/leap/bitmask/provider/__init__.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/leap/bitmask/provider/__init__.py b/src/leap/bitmask/provider/__init__.py index 89ff5d95..4385a92f 100644 --- a/src/leap/bitmask/provider/__init__.py +++ b/src/leap/bitmask/provider/__init__.py @@ -17,6 +17,7 @@ """ Provider utilities. """ +import logging import os from pkg_resources import parse_version @@ -24,6 +25,8 @@ from pkg_resources import parse_version from leap.bitmask import __short_version__ as BITMASK_VERSION from leap.common.check import leap_assert +logger = logging.getLogger(__name__) + # The currently supported API versions by the client. SUPPORTED_APIS = ["1"] @@ -62,4 +65,12 @@ def supports_client(minimum_version): :returns: True if that version is supported or False otherwise. :return type: bool """ - return parse_version(minimum_version) <= parse_version(BITMASK_VERSION) + try: + min_ver = parse_version(minimum_version) + cur_ver = parse_version(BITMASK_VERSION) + supported = min_ver <= cur_ver + except TypeError as exc: + logger.error("Error while parsing versions") + logger.exception(exc) + supported = False + return supported |