suppress download progress output to stdout in OSX (fixes #203)

This commit is contained in:
Micah Lee 2015-06-16 13:03:04 -07:00
parent e6db3c27e4
commit ba424fa427

View file

@ -152,7 +152,7 @@ def download(slug_candidate):
done = False
canceled = False
while not done:
chunk = fp.read(102400)
chunk = fp.read(chunk_size)
if chunk == '':
done = True
else:
@ -162,9 +162,13 @@ def download(slug_candidate):
# tell GUI the progress
downloaded_bytes = fp.tell()
percent = (1.0 * downloaded_bytes / zip_filesize) * 100
# suppress stdout platform on OSX (#203)
if helpers.get_platform() != 'Darwin':
sys.stdout.write(
"\r{0:s}, {1:.2f}% ".format(helpers.human_readable_filesize(downloaded_bytes), percent))
sys.stdout.flush()
add_request(REQUEST_PROGRESS, path, {'id': download_id, 'bytes': downloaded_bytes})
except:
# looks like the download was canceled
@ -175,6 +179,8 @@ def download(slug_candidate):
add_request(REQUEST_CANCELED, path, {'id': download_id})
fp.close()
if helpers.get_platform() != 'Darwin':
sys.stdout.write("\n")
# download is finished, close the server