-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QUESTION: progress bar with download #236
Comments
I have figured out how to do the chunks part but now I am stuck on finding the content size of the received content. |
If the server set a |
Perhaps we should be exporting the parsed |
I am struggling with the same thing. I can't figure out how to get
|
I figured it out, maybe it's useful to someone: currentbytes = 0
totalbytes = None
def headers(response):
if response.length != twisted.web.iweb.UNKNOWN_LENGTH:
totalbytes = response.length
return response
def progress(packet):
# f.write(packet)
if totalbytes is not None:
currentbytes += len(packet)
percent = 100 * currentbytes / totalbytes
treq.get(url, unbuffered=True).addCallback(headers).addCallback(treq.collect, progress) |
Hi, I am trying to make a progress bar with treq download this is the code that I have written so far but there's a problem in line 14 because I can't find anything equivalent of
response.iter_content(chunk_size=1024), expected_size=(total_length/1024) + 1)
(this is from requests) in treq.Is there any other way of making this possible or is there any other way to make progress bars with treq download?
The text was updated successfully, but these errors were encountered: