Skip to content

Commit 2ef6c31

Browse files
committed
Improvements based on feedback in the PR #593
1 parent bd78be2 commit 2ef6c31

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

mbed/mbed.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,12 @@ def progress():
180180
def show_progress(title, percent, max_width=80):
181181
percent = round(float(percent), 2)
182182
show_percent = '%.2f' % percent
183-
line = str(title) + ' |'
184-
bwidth = max_width - len(str(title)) - len(show_percent) - 6
185-
for i in range(0, bwidth):
186-
line += '#' if i <= (percent / 100 * bwidth) else '-'
187-
line += '| ' + show_percent + '%'
188-
sys.stdout.write(line+'\r')
183+
bwidth = max_width - len(str(title)) - len(show_percent) - 6 # 6 equals the spaces and paddings between title, progress bar and percentage
184+
sys.stdout.write('%s |%s%s| %s%%\r' % (str(title), '#' * int(percent * bwidth // 100), '-' * (bwidth - int(percent * bwidth // 100)), show_percent))
189185
sys.stdout.flush()
190186

191187
def hide_progress(max_width=80):
192-
line = ''
193-
for i in range(0, max_width):
194-
line += ' '
195-
sys.stdout.write("\r%s\r" % line)
188+
sys.stdout.write("\r%s\r" % (' ' * max_width))
196189

197190
# Process execution
198191
class ProcessException(Exception):
@@ -241,7 +234,7 @@ def pquery(command, output_callback=None, stdin=None, **kwargs):
241234
else:
242235
break
243236

244-
stdout, stderr = proc.communicate(stdin)
237+
stdout, _ = proc.communicate(stdin)
245238

246239
if very_verbose:
247240
log(str(stdout).strip()+"\n")

0 commit comments

Comments
 (0)