@@ -180,19 +180,12 @@ def progress():
180
180
def show_progress (title , percent , max_width = 80 ):
181
181
percent = round (float (percent ), 2 )
182
182
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 ))
189
185
sys .stdout .flush ()
190
186
191
187
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 ))
196
189
197
190
# Process execution
198
191
class ProcessException (Exception ):
@@ -241,7 +234,7 @@ def pquery(command, output_callback=None, stdin=None, **kwargs):
241
234
else :
242
235
break
243
236
244
- stdout , stderr = proc .communicate (stdin )
237
+ stdout , _ = proc .communicate (stdin )
245
238
246
239
if very_verbose :
247
240
log (str (stdout ).strip ()+ "\n " )
0 commit comments