From df8422d0791d7d03cd3e1efe37a9c72f242f1f78 Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Wed, 31 Jan 2018 14:32:32 -0800 Subject: Refuse API version < 1.21 ; Remove associated code paths Signed-off-by: Joffrey F --- docker/api/client.py | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'docker/api/client.py') diff --git a/docker/api/client.py b/docker/api/client.py index 07bcfae..e69d143 100644 --- a/docker/api/client.py +++ b/docker/api/client.py @@ -1,6 +1,5 @@ import json import struct -import warnings from functools import partial import requests @@ -27,7 +26,7 @@ from ..constants import ( MINIMUM_DOCKER_API_VERSION ) from ..errors import ( - DockerException, TLSParameterError, + DockerException, InvalidVersion, TLSParameterError, create_api_error_from_http_exception ) from ..tls import TLSConfig @@ -160,11 +159,9 @@ class APIClient( ) ) if utils.version_lt(self._version, MINIMUM_DOCKER_API_VERSION): - warnings.warn( - 'The minimum API version supported is {}, but you are using ' - 'version {}. It is recommended you either upgrade Docker ' - 'Engine or use an older version of Docker SDK for ' - 'Python.'.format(MINIMUM_DOCKER_API_VERSION, self._version) + raise InvalidVersion( + 'API versions below {} are no longer supported by this ' + 'library.'.format(MINIMUM_DOCKER_API_VERSION) ) def _retrieve_server_version(self): @@ -353,17 +350,8 @@ class APIClient( break yield data - def _stream_raw_result_old(self, response): - ''' Stream raw output for API versions below 1.6 ''' - self._raise_for_status(response) - for line in response.iter_lines(chunk_size=1, - decode_unicode=True): - # filter out keep-alive new lines - if line: - yield line - def _stream_raw_result(self, response): - ''' Stream result for TTY-enabled container above API 1.6 ''' + ''' Stream result for TTY-enabled container ''' self._raise_for_status(response) for out in response.iter_content(chunk_size=1, decode_unicode=True): yield out @@ -419,11 +407,6 @@ class APIClient( return self._get_result_tty(stream, res, self._check_is_tty(container)) def _get_result_tty(self, stream, res, is_tty): - # Stream multi-plexing was only introduced in API v1.6. Anything - # before that needs old-style streaming. - if utils.compare_version('1.6', self._version) < 0: - return self._stream_raw_result_old(res) - # We should also use raw streaming (without keep-alives) # if we're dealing with a tty-enabled container. if is_tty: -- cgit v1.2.1