mirror of https://github.com/docker/docker-py.git
Merge pull request #15 from elbaschid/add_python3_support
Make docker-py compatible with python 3
This commit is contained in:
commit
d03d4fb5ca
|
@ -1,5 +1,8 @@
|
|||
build
|
||||
dist
|
||||
*.egg-info
|
||||
*.egg/
|
||||
*.pyc
|
||||
*.swp
|
||||
|
||||
.tox
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
import json
|
||||
import logging
|
||||
import re
|
||||
import six
|
||||
import shlex
|
||||
from StringIO import StringIO
|
||||
|
||||
if six.PY3:
|
||||
from io import StringIO
|
||||
else:
|
||||
from StringIO import StringIO
|
||||
|
||||
import requests
|
||||
from requests.exceptions import HTTPError
|
||||
|
@ -43,7 +48,7 @@ class Client(requests.Session):
|
|||
def _container_config(self, image, command, hostname=None, user=None,
|
||||
detach=False, stdin_open=False, tty=False, mem_limit=0, ports=None,
|
||||
environment=None, dns=None, volumes=None, volumes_from=None):
|
||||
if isinstance(command, basestring):
|
||||
if isinstance(command, six.string_types):
|
||||
command = shlex.split(command)
|
||||
return {
|
||||
'Hostname': hostname,
|
||||
|
@ -68,7 +73,7 @@ class Client(requests.Session):
|
|||
# so we do this disgusting thing here.
|
||||
data2 = {}
|
||||
if data is not None:
|
||||
for k, v in data.iteritems():
|
||||
for k, v in six.iteritems(data):
|
||||
if v is not None:
|
||||
data2[k] = v
|
||||
|
||||
|
@ -180,7 +185,7 @@ class Client(requests.Session):
|
|||
'repo': repository,
|
||||
'tag': tag
|
||||
}
|
||||
if type(src) == str or type(src) == unicode:
|
||||
if isinstance(src, six.string_types):
|
||||
params['fromSrc'] = src
|
||||
return self._result(self.post(u, None, params=params))
|
||||
|
||||
|
|
2
setup.py
2
setup.py
|
@ -11,7 +11,7 @@ setup(
|
|||
version='0.0.6',
|
||||
description="Python client for Docker.",
|
||||
packages=['docker'],
|
||||
install_requires=['requests'] + test_requirements,
|
||||
install_requires=['requests', 'six'] + test_requirements,
|
||||
zip_safe=False,
|
||||
classifiers=['Development Status :: 3 - Alpha',
|
||||
'Environment :: Other Environment',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import six
|
||||
import unittest
|
||||
import time
|
||||
|
||||
import docker
|
||||
|
||||
|
@ -66,7 +66,7 @@ class TestImages(BaseTestCase):
|
|||
class TestImageIds(BaseTestCase):
|
||||
def runTest(self):
|
||||
res1 = self.client.images(quiet=True)
|
||||
self.assertEqual(type(res1[0]), unicode)
|
||||
self.assertEqual(type(res1[0]), six.text_type)
|
||||
|
||||
class TestListContainers(BaseTestCase):
|
||||
def runTest(self):
|
||||
|
@ -230,7 +230,7 @@ class TestPull(BaseTestCase):
|
|||
self.assertIn('Images', info)
|
||||
img_count = info['Images']
|
||||
res = self.client.pull('joffrey/test001')
|
||||
self.assertEqual(type(res), unicode)
|
||||
self.assertEqual(type(res), six.text_type)
|
||||
self.assertEqual(img_count + 2, self.client.info()['Images'])
|
||||
img_info = self.client.inspect_image('joffrey/test001')
|
||||
self.assertIn('id', img_info)
|
||||
|
@ -328,4 +328,4 @@ class TestRunShlex(BaseTestCase):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue