Skip to content

Commit 463b537

Browse files
authored
Merge pull request #108 from mboersma/hotfix-ubuntu-damage
fix(*): move to python3
2 parents 36d17dc + 0b6d8a9 commit 463b537

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

rootfs/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
FROM quay.io/deis/base:v0.3.5
22

3-
RUN buildDeps='gcc git libffi-dev libssl-dev python-dev python-pip python-wheel python-setuptools'; \
3+
RUN buildDeps='gcc git libffi-dev libssl-dev python3-dev python3-pip python3-wheel python3-setuptools'; \
44
apt-get update && \
55
apt-get install -y --no-install-recommends \
66
$buildDeps \
77
libffi6 \
88
libssl1.0.0 \
9-
python && \
10-
pip install --disable-pip-version-check --no-cache-dir docker-py==1.10.6 && \
9+
python3-minimal && \
10+
pip3 install --disable-pip-version-check --no-cache-dir docker-py==1.10.6 && \
1111
# cleanup
1212
apt-get purge -y --auto-remove $buildDeps && \
1313
apt-get autoremove -y && \
@@ -35,4 +35,4 @@ RUN chmod +x /bin/objstorage
3535

3636
COPY . /
3737

38-
CMD ["python", "/deploy.py"]
38+
CMD ["python3", "/deploy.py"]

rootfs/deploy.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import docker
22
import os
3+
import sys
34
import tarfile
45
import time
56
import requests
@@ -12,19 +13,21 @@
1213
def log_output(stream, decode):
1314
error = False
1415
for chunk in stream:
16+
if isinstance(chunk, bytes):
17+
# Convert to dict, since docker-py returns some errors as raw bytes.
18+
chunk = eval(chunk)
1519
if 'error' in chunk:
1620
error = True
17-
if isinstance(chunk, basestring): # Change "basestring" to "str" for Python3
18-
print(chunk.decode('utf-8'))
19-
else:
20-
print(chunk['error'].decode('utf-8'))
21+
print(chunk['error'])
2122
elif decode:
2223
stream_chunk = chunk.get('stream')
2324
if stream_chunk:
24-
stream_chunk = stream_chunk.encode('utf-8').strip()
25-
print(stream_chunk.replace('\n', ''))
25+
# Must handle chunks as bytes to avoid UnicodeEncodeError.
26+
encoded_chunk = stream_chunk.encode('utf-8')
27+
sys.stdout.buffer.write(encoded_chunk)
2628
elif DEBUG:
27-
print(chunk.decode('utf-8'))
29+
print(chunk)
30+
sys.stdout.flush()
2831
if error:
2932
# HACK: delay so stderr is logged before this dockerbuilder pod exits.
3033
time.sleep(3)

0 commit comments

Comments
 (0)