We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi @verigak,
How do you integrate this library with urllib.request.urlretrieve?
The text was updated successfully, but these errors were encountered:
Probably something like this:
from urllib.request import urlretrieve from progress.bar import Bar from progress.spinner import Spinner class Getter: def get(self, url, to): self.p = None def update(blocks, bs, size): if not self.p: if size < 0: print("spinner") self.p = Spinner(to) else: print("bar") self.p = Bar(to, max=size) else: if size < 0: self.p.update() else: self.p.goto(blocks * bs) urlretrieve(url, to, update) self.p.finish() Getter().get("https://www.python.org/ftp/python/3.6.3/python-3.6.3.exe", "py3.exe")
But you really should use requests:
import requests from progress.bar import Bar from progress.spinner import Spinner r = requests.get("https://www.python.org/ftp/python/3.6.3/python-3.6.3.exe", stream=True) size = r.headers['content-length'] if size: p = Bar('py3.exe', max=int(size)) else: p = Spinner('py3.exe') with open('py3.exe', 'wb') as f: for chunk in r.iter_content(chunk_size=1024*50): if chunk: # filter out keep-alive new chunks p.next(len(chunk)) f.write(chunk) p.finish()
Both Spinner-codepaths are not tested...
Sorry, something went wrong.
No branches or pull requests
Hi @verigak,
How do you integrate this library with urllib.request.urlretrieve?
The text was updated successfully, but these errors were encountered: