Skip to content

Commit

Permalink
Ensure that UTF-8 output works even without a terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
cmihai committed May 4, 2016
1 parent eff771b commit 648124f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion docktree/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
import sys
import locale
import argparse
import codecs

try:
from docker import Client
except ImportError:
print("Cannot import Docker API, is docker_py installed?", file=sys.stderr)
sys.exit(1)

if sys.version_info < (3,):
sys.stdout = codecs.getwriter('utf8')(sys.stdout)


# Pseudographics
ZERO, ONE, TWO, THREE = (
Expand Down Expand Up @@ -88,7 +92,7 @@ def prune(branch):
def draw_branch(branch, marks=[]):
for i, (img, chldrn) in enumerate(branch):
for x in marks:
print(ONE if x else ZERO, end='', file=self.file)
print(ONE if x else ZERO, end=u'', file=self.file)
if i < len(branch) - 1:
print(THREE + img.name, file=self.file)
draw_branch(chldrn, marks + [1])
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name='docktree',
version='0.3.0',
version='0.3.1',
description='Display the local Docker image layers as a tree',
long_description=long_description,
url='https://github.com/cmihai/docktree',
Expand Down

0 comments on commit 648124f

Please sign in to comment.