summaryrefslogtreecommitdiffstats
path: root/ipalib/frontend.py
diff options
context:
space:
mode:
authorChristian Heimes <cheimes@redhat.com>2016-11-21 10:24:17 +0100
committerMartin Babinsky <mbabinsk@redhat.com>2016-11-24 15:46:40 +0100
commit2cbaf156045769b54150e4d4c3c1071f164a16fb (patch)
treee56ed216116635fb02adae9a58fc8b6e2e6ce1d5 /ipalib/frontend.py
parent526bcea705d04895aa6b09bce996ac340783d1d0 (diff)
downloadfreeipa-2cbaf156045769b54150e4d4c3c1071f164a16fb.tar.gz
freeipa-2cbaf156045769b54150e4d4c3c1071f164a16fb.tar.xz
freeipa-2cbaf156045769b54150e4d4c3c1071f164a16fb.zip
Replace LooseVersion
pylint is having a hard time with distutils.version in tox's virtual envs. virtualenv uses some tricks to provide a virtual distutils package, pylint can't cope with. https://github.com/PyCQA/pylint/issues/73 suggests to use pkg_resources instead. pkg_resources' version parser has some more benefits, e.g. PEP 440 conformity. But pkg_resources.parse_version() is a heavy weight solution with reduced functionality, e.g. no access to major version. For API_VERSION and plugin version we can use a much simpler and faster approach. https://fedorahosted.org/freeipa/ticket/6468 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com> Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
Diffstat (limited to 'ipalib/frontend.py')
-rw-r--r--ipalib/frontend.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index c94d17467..dfa6cdf58 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -20,12 +20,10 @@
"""
Base classes for all front-end plugins.
"""
-
-from distutils import version
-
import six
from ipapython.version import API_VERSION
+from ipapython.ipautil import APIVersion
from ipapython.ipa_log_manager import root_logger
from ipalib.base import NameSpace
from ipalib.plugable import Plugin, APINameSpace
@@ -770,16 +768,19 @@ class Command(HasParam):
If the client minor version is less than or equal to the server
then let the request proceed.
"""
- server_ver = version.LooseVersion(API_VERSION)
- ver = version.LooseVersion(client_version)
- if len(ver.version) < 2:
- raise VersionError(cver=ver.version, sver=server_ver.version, server= self.env.xmlrpc_uri)
- client_major = ver.version[0]
-
- server_major = server_ver.version[0]
-
- if server_major != client_major:
- raise VersionError(cver=client_version, sver=API_VERSION, server=self.env.xmlrpc_uri)
+ server_apiver = APIVersion(self.api_version)
+ try:
+ client_apiver = APIVersion(client_version)
+ except ValueError:
+ raise VersionError(cver=client_version,
+ sver=self.api_version,
+ server=self.env.xmlrpc_uri)
+
+ if (client_apiver.major != server_apiver.major
+ or client_apiver > server_apiver):
+ raise VersionError(cver=client_version,
+ sver=self.api_version,
+ server=self.env.xmlrpc_uri)
def run(self, *args, **options):
"""