Skip to content

Commit

Permalink
Merge pull request #108 from mboersma/hotfix-ubuntu-damage
Browse files Browse the repository at this point in the history
fix(*): move to python3
  • Loading branch information
mboersma authored Dec 1, 2016
2 parents 36d17dc + 0b6d8a9 commit 463b537
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
8 changes: 4 additions & 4 deletions rootfs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM quay.io/deis/base:v0.3.5

RUN buildDeps='gcc git libffi-dev libssl-dev python-dev python-pip python-wheel python-setuptools'; \
RUN buildDeps='gcc git libffi-dev libssl-dev python3-dev python3-pip python3-wheel python3-setuptools'; \
apt-get update && \
apt-get install -y --no-install-recommends \
$buildDeps \
libffi6 \
libssl1.0.0 \
python && \
pip install --disable-pip-version-check --no-cache-dir docker-py==1.10.6 && \
python3-minimal && \
pip3 install --disable-pip-version-check --no-cache-dir docker-py==1.10.6 && \
# cleanup
apt-get purge -y --auto-remove $buildDeps && \
apt-get autoremove -y && \
Expand Down Expand Up @@ -35,4 +35,4 @@ RUN chmod +x /bin/objstorage

COPY . /

CMD ["python", "/deploy.py"]
CMD ["python3", "/deploy.py"]
17 changes: 10 additions & 7 deletions rootfs/deploy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import docker
import os
import sys
import tarfile
import time
import requests
Expand All @@ -12,19 +13,21 @@
def log_output(stream, decode):
error = False
for chunk in stream:
if isinstance(chunk, bytes):
# Convert to dict, since docker-py returns some errors as raw bytes.
chunk = eval(chunk)
if 'error' in chunk:
error = True
if isinstance(chunk, basestring): # Change "basestring" to "str" for Python3
print(chunk.decode('utf-8'))
else:
print(chunk['error'].decode('utf-8'))
print(chunk['error'])
elif decode:
stream_chunk = chunk.get('stream')
if stream_chunk:
stream_chunk = stream_chunk.encode('utf-8').strip()
print(stream_chunk.replace('\n', ''))
# Must handle chunks as bytes to avoid UnicodeEncodeError.
encoded_chunk = stream_chunk.encode('utf-8')
sys.stdout.buffer.write(encoded_chunk)
elif DEBUG:
print(chunk.decode('utf-8'))
print(chunk)
sys.stdout.flush()
if error:
# HACK: delay so stderr is logged before this dockerbuilder pod exits.
time.sleep(3)
Expand Down

0 comments on commit 463b537

Please sign in to comment.