1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

replace compare_versions() with distutils.version

This commit is contained in:
objectified 2015-08-25 02:18:37 -04:00
parent c39fb43ad9
commit b1785a0361

View file

@ -26,6 +26,8 @@ import subprocess
import time
import re
from distutils.version import LooseVersion
import ansible.constants as C
from ansible import errors
@ -46,7 +48,7 @@ class Connection(ConnectionBase):
self.can_copy_bothways = False
docker_version = self._get_docker_version()
if self.compare_versions(docker_version, '1.8.0') >= 0:
if LooseVersion(docker_version) >= LooseVersion('1.8.0'):
self.can_copy_bothways = True
def _get_docker_version(self):
@ -76,12 +78,6 @@ class Connection(ConnectionBase):
def transport(self):
return 'docker'
def compare_versions(self, version1, version2):
# Source: https://stackoverflow.com/questions/1714027/version-number-comparison
def normalize(v):
return [int(x) for x in re.sub(r'(\.0+)*$','', v).split(".")]
return cmp(normalize(version1), normalize(version2))
def _connect(self, port=None):
""" Connect to the container. Nothing to do """
if not self._connected: