Skip to content

Commit c8fba21

Browse files
committed
Remove support to pre python 3.6
Signed-off-by: Ulysses Souza <[email protected]>
1 parent 31775a1 commit c8fba21

19 files changed

+88
-182
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
max-parallel: 1
1010
matrix:
11-
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]
11+
python-version: [3.6, 3.7, 3.8, 3.9]
1212

1313
steps:
1414
- uses: actions/checkout@v2
@@ -18,8 +18,8 @@ jobs:
1818
python-version: ${{ matrix.python-version }}
1919
- name: Install dependencies
2020
run: |
21-
python -m pip install --upgrade pip
22-
pip install -r test-requirements.txt -r requirements.txt
21+
python3 -m pip install --upgrade pip
22+
pip3 install -r test-requirements.txt -r requirements.txt
2323
- name: Test with pytest
2424
run: |
2525
docker logout

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sphinx:
44
configuration: docs/conf.py
55

66
python:
7-
version: 3.5
7+
version: 3.6
88
install:
99
- requirements: docs-requirements.txt
1010
- requirements: requirements.txt

Dockerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
ARG PYTHON_VERSION=2.7
1+
ARG PYTHON_VERSION=3.7
22

33
FROM python:${PYTHON_VERSION}
44

5-
# Add SSH keys and set permissions
6-
COPY tests/ssh-keys /root/.ssh
7-
RUN chmod -R 600 /root/.ssh
8-
95
RUN mkdir /src
106
WORKDIR /src
117

Dockerfile-py3

Lines changed: 0 additions & 15 deletions
This file was deleted.

Jenkinsfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!groovy
22

33
def imageNameBase = "dockerpinata/docker-py"
4-
def imageNamePy2
54
def imageNamePy3
65
def imageDindSSH
76
def images = [:]
@@ -22,12 +21,10 @@ def buildImages = { ->
2221
stage("build image") {
2322
checkout(scm)
2423

25-
imageNamePy2 = "${imageNameBase}:py2-${gitCommit()}"
2624
imageNamePy3 = "${imageNameBase}:py3-${gitCommit()}"
2725
imageDindSSH = "${imageNameBase}:sshdind-${gitCommit()}"
2826
withDockerRegistry(credentialsId:'dockerbuildbot-index.docker.io') {
2927
buildImage(imageDindSSH, "-f tests/Dockerfile-ssh-dind .", "")
30-
buildImage(imageNamePy2, "-f tests/Dockerfile --build-arg PYTHON_VERSION=2.7 .", "py2.7")
3128
buildImage(imageNamePy3, "-f tests/Dockerfile --build-arg PYTHON_VERSION=3.7 .", "py3.7")
3229
}
3330
}
@@ -73,7 +70,7 @@ def runTests = { Map settings ->
7370
throw new Exception("Need Docker version to test, e.g.: `runTests(dockerVersion: '19.03.12')`")
7471
}
7572
if (!pythonVersion) {
76-
throw new Exception("Need Python version being tested, e.g.: `runTests(pythonVersion: 'py2.7')`")
73+
throw new Exception("Need Python version being tested, e.g.: `runTests(pythonVersion: 'py3.7')`")
7774
}
7875

7976
{ ->

Makefile

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@ all: test
66

77
.PHONY: clean
88
clean:
9-
-docker rm -f dpy-dind-py2 dpy-dind-py3 dpy-dind-certs dpy-dind-ssl
9+
-docker rm -f dpy-dind-py3 dpy-dind-certs dpy-dind-ssl
1010
find -name "__pycache__" | xargs rm -rf
1111

12-
.PHONY: build
13-
build:
14-
docker build -t docker-sdk-python -f tests/Dockerfile --build-arg PYTHON_VERSION=2.7 --build-arg APT_MIRROR .
15-
1612
.PHONY: build-dind-ssh
1713
build-dind-ssh:
1814
docker build -t docker-dind-ssh -f tests/Dockerfile-ssh-dind --build-arg ENGINE_VERSION=${TEST_ENGINE_VERSION} --build-arg API_VERSION=${TEST_API_VERSION} --build-arg APT_MIRROR .
@@ -30,20 +26,12 @@ build-dind-certs:
3026
docker build -t dpy-dind-certs -f tests/Dockerfile-dind-certs .
3127

3228
.PHONY: test
33-
test: flake8 unit-test unit-test-py3 integration-dind integration-dind-ssl
34-
35-
.PHONY: unit-test
36-
unit-test: build
37-
docker run -t --rm docker-sdk-python py.test tests/unit
29+
test: flake8 unit-test-py3 integration-dind integration-dind-ssl
3830

3931
.PHONY: unit-test-py3
4032
unit-test-py3: build-py3
4133
docker run -t --rm docker-sdk-python3 py.test tests/unit
4234

43-
.PHONY: integration-test
44-
integration-test: build
45-
docker run -t --rm -v /var/run/docker.sock:/var/run/docker.sock docker-sdk-python py.test -v tests/integration/${file}
46-
4735
.PHONY: integration-test-py3
4836
integration-test-py3: build-py3
4937
docker run -t --rm -v /var/run/docker.sock:/var/run/docker.sock docker-sdk-python3 py.test -v tests/integration/${file}
@@ -53,16 +41,7 @@ setup-network:
5341
docker network inspect dpy-tests || docker network create dpy-tests
5442

5543
.PHONY: integration-dind
56-
integration-dind: integration-dind-py2 integration-dind-py3
57-
58-
.PHONY: integration-dind-py2
59-
integration-dind-py2: build setup-network
60-
docker rm -vf dpy-dind-py2 || :
61-
docker run -d --network dpy-tests --name dpy-dind-py2 --privileged\
62-
docker:${TEST_ENGINE_VERSION}-dind dockerd -H tcp://0.0.0.0:2375 --experimental
63-
docker run -t --rm --env="DOCKER_HOST=tcp://dpy-dind-py2:2375" --env="DOCKER_TEST_API_VERSION=${TEST_API_VERSION}"\
64-
--network dpy-tests docker-sdk-python py.test tests/integration/${file}
65-
docker rm -vf dpy-dind-py2
44+
integration-dind: integration-dind-py3
6645

6746
.PHONY: integration-dind-py3
6847
integration-dind-py3: build-py3 setup-network
@@ -73,16 +52,6 @@ integration-dind-py3: build-py3 setup-network
7352
--network dpy-tests docker-sdk-python3 py.test tests/integration/${file}
7453
docker rm -vf dpy-dind-py3
7554

76-
.PHONY: integration-ssh-py2
77-
integration-ssh-py2: build-dind-ssh build setup-network
78-
docker rm -vf dpy-dind-py2 || :
79-
docker run -d --network dpy-tests --name dpy-dind-py2 --privileged\
80-
docker-dind-ssh dockerd --experimental
81-
# start SSH daemon
82-
docker exec dpy-dind-py2 sh -c "/usr/sbin/sshd"
83-
docker run -t --rm --env="DOCKER_HOST=ssh://dpy-dind-py2" --env="DOCKER_TEST_API_VERSION=${TEST_API_VERSION}"\
84-
--network dpy-tests docker-sdk-python py.test tests/ssh/${file}
85-
docker rm -vf dpy-dind-py2
8655

8756
.PHONY: integration-ssh-py3
8857
integration-ssh-py3: build-dind-ssh build-py3 setup-network
@@ -97,7 +66,7 @@ integration-ssh-py3: build-dind-ssh build-py3 setup-network
9766

9867

9968
.PHONY: integration-dind-ssl
100-
integration-dind-ssl: build-dind-certs build build-py3
69+
integration-dind-ssl: build-dind-certs build-py3
10170
docker rm -vf dpy-dind-certs dpy-dind-ssl || :
10271
docker run -d --name dpy-dind-certs dpy-dind-certs
10372
docker run -d --env="DOCKER_HOST=tcp://localhost:2375" --env="DOCKER_TLS_VERIFY=1"\
@@ -106,22 +75,19 @@ integration-dind-ssl: build-dind-certs build build-py3
10675
docker:${TEST_ENGINE_VERSION}-dind\
10776
dockerd --tlsverify --tlscacert=/certs/ca.pem --tlscert=/certs/server-cert.pem\
10877
--tlskey=/certs/server-key.pem -H tcp://0.0.0.0:2375 --experimental
109-
docker run -t --rm --volumes-from dpy-dind-ssl --env="DOCKER_HOST=tcp://docker:2375"\
110-
--env="DOCKER_TLS_VERIFY=1" --env="DOCKER_CERT_PATH=/certs" --env="DOCKER_TEST_API_VERSION=${TEST_API_VERSION}"\
111-
--network dpy-tests docker-sdk-python py.test tests/integration/${file}
11278
docker run -t --rm --volumes-from dpy-dind-ssl --env="DOCKER_HOST=tcp://docker:2375"\
11379
--env="DOCKER_TLS_VERIFY=1" --env="DOCKER_CERT_PATH=/certs" --env="DOCKER_TEST_API_VERSION=${TEST_API_VERSION}"\
11480
--network dpy-tests docker-sdk-python3 py.test tests/integration/${file}
11581
docker rm -vf dpy-dind-ssl dpy-dind-certs
11682

11783
.PHONY: flake8
118-
flake8: build
119-
docker run -t --rm docker-sdk-python flake8 docker tests
84+
flake8: build-py3
85+
docker run -t --rm docker-sdk-python3 flake8 docker tests
12086

12187
.PHONY: docs
12288
docs: build-docs
12389
docker run --rm -t -v `pwd`:/src docker-sdk-python-docs sphinx-build docs docs/_build
12490

12591
.PHONY: shell
126-
shell: build
127-
docker run -it -v /var/run/docker.sock:/var/run/docker.sock docker-sdk-python python
92+
shell: build-py3
93+
docker run -it -v /var/run/docker.sock:/var/run/docker.sock docker-sdk-python3 python

docker/api/client.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import json
22
import struct
3+
import urllib
34
from functools import partial
45

56
import requests
67
import requests.exceptions
7-
import six
88
import websocket
99

1010
from .. import auth
@@ -192,12 +192,12 @@ def __init__(self, base_url=None, version=None,
192192
# version detection needs to be after unix adapter mounting
193193
if version is None or (isinstance(
194194
version,
195-
six.string_types
195+
str
196196
) and version.lower() == 'auto'):
197197
self._version = self._retrieve_server_version()
198198
else:
199199
self._version = version
200-
if not isinstance(self._version, six.string_types):
200+
if not isinstance(self._version, str):
201201
raise DockerException(
202202
'Version parameter must be a string or None. Found {0}'.format(
203203
type(version).__name__
@@ -246,13 +246,13 @@ def _delete(self, url, **kwargs):
246246

247247
def _url(self, pathfmt, *args, **kwargs):
248248
for arg in args:
249-
if not isinstance(arg, six.string_types):
249+
if not isinstance(arg, str):
250250
raise ValueError(
251251
'Expected a string but found {0} ({1}) '
252252
'instead'.format(arg, type(arg))
253253
)
254254

255-
quote_f = partial(six.moves.urllib.parse.quote, safe="/:")
255+
quote_f = partial(urllib.parse.quote, safe="/:")
256256
args = map(quote_f, args)
257257

258258
if kwargs.get('versioned_api', True):
@@ -284,7 +284,7 @@ def _post_json(self, url, data, **kwargs):
284284
# so we do this disgusting thing here.
285285
data2 = {}
286286
if data is not None and isinstance(data, dict):
287-
for k, v in six.iteritems(data):
287+
for k, v in iter(data.items()):
288288
if v is not None:
289289
data2[k] = v
290290
elif data is not None:
@@ -320,12 +320,10 @@ def _get_raw_response_socket(self, response):
320320
sock = response.raw._fp.fp.raw.sock
321321
elif self.base_url.startswith('http+docker://ssh'):
322322
sock = response.raw._fp.fp.channel
323-
elif six.PY3:
323+
else:
324324
sock = response.raw._fp.fp.raw
325325
if self.base_url.startswith("https://"):
326326
sock = sock._sock
327-
else:
328-
sock = response.raw._fp.fp._sock
329327
try:
330328
# Keep a reference to the response to stop it being garbage
331329
# collected. If the response is garbage collected, it will
@@ -465,7 +463,7 @@ def _get_result_tty(self, stream, res, is_tty):
465463
self._result(res, binary=True)
466464

467465
self._raise_for_status(res)
468-
sep = six.binary_type()
466+
sep = b''
469467
if stream:
470468
return self._multiplexed_response_stream_helper(res)
471469
else:

docker/context/context.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
class Context:
1313
"""A context."""
14+
1415
def __init__(self, name, orchestrator=None, host=None, endpoints=None,
1516
tls=False):
1617
if not name:
@@ -128,9 +129,9 @@ def _load_certs(self):
128129
key = os.path.join(tls_dir, endpoint, filename)
129130
if all([ca_cert, cert, key]):
130131
verify = None
131-
if endpoint == "docker":
132-
if not self.endpoints["docker"].get("SkipTLSVerify", False):
133-
verify = True
132+
if endpoint == "docker" and not self.endpoints["docker"].get(
133+
"SkipTLSVerify", False):
134+
verify = True
134135
certs[endpoint] = TLSConfig(
135136
client_cert=(cert, key), ca_cert=ca_cert, verify=verify)
136137
self.tls_cfg = certs

docker/transport/sshconn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def f():
5353
signal.signal(signal.SIGINT, signal.SIG_IGN)
5454
preexec_func = f
5555

56-
env = dict(os.environ)
56+
env = dict(os.environ)
5757

5858
# drop LD_LIBRARY_PATH and SSL_CERT_FILE
5959
env.pop('LD_LIBRARY_PATH', None)
@@ -65,7 +65,7 @@ def f():
6565
shell=True,
6666
stdout=subprocess.PIPE,
6767
stdin=subprocess.PIPE,
68-
preexec_fn=preexec_func)
68+
preexec_fn=None if constants.IS_WINDOWS_PLATFORM else preexec_func)
6969

7070
def _write(self, data):
7171
if not self.proc or self.proc.stdin.closed:

0 commit comments

Comments
 (0)