mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-07-05 20:11:29 +00:00
Cleanup progress bar if there's an exception, too
This commit is contained in:
parent
ca2abaa613
commit
bf0709edf6
@ -326,23 +326,25 @@ class SourcePackage(object):
|
|||||||
|
|
||||||
downloaded = 0
|
downloaded = 0
|
||||||
bar_width = 60
|
bar_width = 60
|
||||||
with open(pathname, 'wb') as out:
|
try:
|
||||||
while True:
|
with open(pathname, 'wb') as out:
|
||||||
block = in_.read(10240)
|
while True:
|
||||||
if block == '':
|
block = in_.read(10240)
|
||||||
break
|
if block == '':
|
||||||
downloaded += len(block)
|
break
|
||||||
out.write(block)
|
downloaded += len(block)
|
||||||
if not self.quiet:
|
out.write(block)
|
||||||
percent = downloaded * 100 // size
|
if not self.quiet:
|
||||||
bar = '=' * int(round(downloaded * bar_width / size))
|
percent = downloaded * 100 // size
|
||||||
bar = (bar + '>' + ' ' * bar_width)[:bar_width]
|
bar = '=' * int(round(downloaded * bar_width / size))
|
||||||
Logger.stdout.write('[%s] %#3i%%\r' % (bar, percent))
|
bar = (bar + '>' + ' ' * bar_width)[:bar_width]
|
||||||
Logger.stdout.flush()
|
Logger.stdout.write('[%s] %#3i%%\r' % (bar, percent))
|
||||||
in_.close()
|
Logger.stdout.flush()
|
||||||
if not self.quiet:
|
in_.close()
|
||||||
Logger.stdout.write(' ' * (bar_width + 7) + '\r')
|
finally:
|
||||||
Logger.stdout.flush()
|
if not self.quiet:
|
||||||
|
Logger.stdout.write(' ' * (bar_width + 7) + '\r')
|
||||||
|
Logger.stdout.flush()
|
||||||
if not self.dsc.verify_file(pathname):
|
if not self.dsc.verify_file(pathname):
|
||||||
Logger.error('Checksum for %s does not match.', filename)
|
Logger.error('Checksum for %s does not match.', filename)
|
||||||
return False
|
return False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user