Skip to content

Commit

Permalink
Fixed unicode progress indicator for python2
Browse files Browse the repository at this point in the history
  • Loading branch information
bpmweel committed Apr 3, 2017
1 parent dcae6e6 commit 72867e6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
22 changes: 9 additions & 13 deletions boatswain/boatswain.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ def build_list(self, names, images, dryrun=False, force=False,
self.progress_bar.update(self.step, imagename=name)
built.append(name)

if verbose == 1:
self._stop_progress()
self._stop_progress()
return built

def clean_list(self, names, images, dryrun=False, verbose=1):
Expand All @@ -282,8 +281,7 @@ def clean_list(self, names, images, dryrun=False, verbose=1):
self.step += 1
self.progress_bar.update(self.step, imagename=name)
cleaned.append(name)
if verbose == 1:
self._stop_progress()
self._stop_progress()
return cleaned

def push_list(self, names, images, dryrun=False, verbose=1):
Expand All @@ -309,8 +307,7 @@ def push_list(self, names, images, dryrun=False, verbose=1):
self.step += 1
self.progress_bar.update(self.step, imagename=name)
pushed.append(name)
if verbose == 1:
self._stop_progress()
self._stop_progress()
return pushed

def before_command(self, definition, verbose=1, dryrun=False):
Expand Down Expand Up @@ -474,8 +471,6 @@ def _docker_progress(self, name, generator, has_step=True, verbose=1):
# are on (e.g. the layer)
# and whether it was successfully built, although if it does not
# build successfully we will get an Exception
if verbose > 1:
print(bcolors.blue(name))
if verbose > 2:
print(bcolors.warning(name + ": "), end="")

Expand Down Expand Up @@ -517,7 +512,7 @@ def _docker_progress(self, name, generator, has_step=True, verbose=1):

if verbose > 1:
self.create_progress_bar(self.step, self.total, name)
self.progress_bar.update(self.step)
self.progress_bar.update(self.step, name)

if line.startswith('Successfully built'):
ident = extract_id(line)
Expand Down Expand Up @@ -545,12 +540,13 @@ def create_progress_bar(self, start, total, name):
self.total = total + 1
if self.total is None:
self.total = progressbar.UnknownLength
widgets = [Counter(), ' ', BouncingBar(marker=u'\u2588',
left=u'\u2502', right=u'\u2502'), ' ', Timer()]
widgets = [DynamicStringMessage('imagename'), ' ', Counter(), ' ',
BouncingBar(marker=u'\u2588', left=u'\u2502', right=u'\u2502'),
' ', Timer()]
else:
widgets = [DynamicStringMessage('imagename'), ' ', Percentage(), ' (', SimpleProgress(), ')',
' ', Bar(marker=u'\u2588',
left=u'\u2502', right=u'\u2502'), ' ', Timer()]
' ', Bar(marker=u'\u2588', left=u'\u2502', right=u'\u2502'),
' ', Timer()]

self.progress_bar = progressbar.ProgressBar(
max_value=self.total, redirect_stdout=True,
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.6.0
current_version = 0.7.0

[bdist_wheel]
universal = 1
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ def read(*names, **kwargs):

setup(
name='boatswain',
version='0.6.0',
version='0.7.0',
url='https://github.com/nlesc-sherlock/boatswain',
license='Apache Software License',
author='Berend Weel',
tests_require=['pytest'],
install_requires=[
'docker>=2.0.0, <3.0.0',
'PyYAML>=3.12, <4.0',
'progressbar2>=3.12.0, <4.0.0'
'progressbar2>=3.16.0, <4.0.0'
],
extras_require={
'registry': ['docker-registry-client>=0.5.1'],
Expand Down

0 comments on commit 72867e6

Please sign in to comment.