mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-19 06:40:21 -07:00
Fix docker_image archive features to work with Python 3
Without binary mode, ansible shows a "write() argument must be str, not bytes" error when using Python 3.
This commit is contained in:
parent
8759d97071
commit
2653bd3f50
1 changed files with 2 additions and 2 deletions
|
@ -402,7 +402,7 @@ class ImageManager(DockerBaseClass):
|
||||||
self.fail("Error getting image %s - %s" % (image_name, str(exc)))
|
self.fail("Error getting image %s - %s" % (image_name, str(exc)))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(self.archive_path, 'w') as fd:
|
with open(self.archive_path, 'wb') as fd:
|
||||||
if HAS_DOCKER_PY_3:
|
if HAS_DOCKER_PY_3:
|
||||||
for chunk in image:
|
for chunk in image:
|
||||||
fd.write(chunk)
|
fd.write(chunk)
|
||||||
|
@ -553,7 +553,7 @@ class ImageManager(DockerBaseClass):
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
self.log("Opening image %s" % self.load_path)
|
self.log("Opening image %s" % self.load_path)
|
||||||
image_tar = open(self.load_path, 'r')
|
image_tar = open(self.load_path, 'rb')
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self.fail("Error opening image %s - %s" % (self.load_path, str(exc)))
|
self.fail("Error opening image %s - %s" % (self.load_path, str(exc)))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue