[Pkg-privacy-commits] [onionshare] 25/33: suppress download progress output to stdout in OSX (fixes #203)
Ximin Luo
infinity0 at debian.org
Mon Oct 19 14:15:42 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch debian
in repository onionshare.
commit ba424fa4273a200a6f75c3328fd239be7aaa15db
Author: Micah Lee <micah at micahflee.com>
Date: Tue Jun 16 13:03:04 2015 -0700
suppress download progress output to stdout in OSX (fixes #203)
---
onionshare/web.py | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/onionshare/web.py b/onionshare/web.py
index a72f1f7..059475a 100644
--- a/onionshare/web.py
+++ b/onionshare/web.py
@@ -146,13 +146,13 @@ def download(slug_candidate):
basename = os.path.basename(zip_filename)
def generate():
- chunk_size = 102400 # 100kb
+ chunk_size = 102400 # 100kb
fp = open(zip_filename, 'rb')
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
- sys.stdout.write(
- "\r{0:s}, {1:.2f}% ".format(helpers.human_readable_filesize(downloaded_bytes), percent))
- sys.stdout.flush()
+
+ # 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,7 +179,9 @@ def download(slug_candidate):
add_request(REQUEST_CANCELED, path, {'id': download_id})
fp.close()
- sys.stdout.write("\n")
+
+ if helpers.get_platform() != 'Darwin':
+ sys.stdout.write("\n")
# download is finished, close the server
if not stay_open and not canceled:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git
More information about the Pkg-privacy-commits
mailing list