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>
This commit is contained in:
Christian Heimes
2016-11-21 10:24:17 +01:00
committed by Martin Babinsky
parent 526bcea705
commit 2cbaf15604
7 changed files with 67 additions and 34 deletions

View File

@@ -4,7 +4,6 @@
from __future__ import print_function
from distutils.version import LooseVersion
import dns.exception as dnsexception
import dns.name as dnsname
import dns.resolver as dnsresolver
@@ -15,6 +14,7 @@ import socket
import tempfile
import traceback
from pkg_resources import parse_version
import six
from ipapython import ipaldap, ipautil, sysrestore
@@ -510,12 +510,12 @@ def check_remote_version(api):
finally:
client.disconnect()
remote_version = env['version']
version = api.env.version
if LooseVersion(remote_version) > LooseVersion(version):
remote_version = parse_version(env['version'])
api_version = parse_version(api.env.version)
if remote_version > api_version:
raise RuntimeError(
"Cannot install replica of a server of higher version ({}) than"
"the local version ({})".format(remote_version, version))
"the local version ({})".format(remote_version, api_version))
def common_check(no_ntp):