mirror of
https://github.com/pyenv/pyenv.git
synced 2025-12-07 10:28:35 +00:00
add progress bar
This commit is contained in:
parent
602bb7a8e6
commit
00fd0d5595
@ -24,6 +24,7 @@ import packaging.version
|
|||||||
import requests
|
import requests
|
||||||
import requests_html
|
import requests_html
|
||||||
import sortedcontainers
|
import sortedcontainers
|
||||||
|
import tqdm
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -306,6 +307,7 @@ class Re:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
class Url:
|
class Url:
|
||||||
|
logger = logging.getLogger("Url")
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def sha256_url(url, session=None):
|
def sha256_url(url, session=None):
|
||||||
if session is None:
|
if session is None:
|
||||||
@ -313,7 +315,10 @@ class Url:
|
|||||||
logger.info(f"Downloading and computing hash of {url}")
|
logger.info(f"Downloading and computing hash of {url}")
|
||||||
h=hashlib.sha256()
|
h=hashlib.sha256()
|
||||||
r=session.get(url,stream=True)
|
r=session.get(url,stream=True)
|
||||||
for c in r.iter_content(None):
|
total_bytes=int(r.headers.get('content-length',0)) or float('inf')
|
||||||
|
with tqdm.tqdm(total=total_bytes, unit='B', unit_scale=True, unit_divisor=1024) as t:
|
||||||
|
for c in r.iter_content(1024):
|
||||||
|
t.update(len(c))
|
||||||
h.update(c)
|
h.update(c)
|
||||||
return h.hexdigest()
|
return h.hexdigest()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user