aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/wrap/wrap.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2019-07-20 14:02:15 +0000
committerJussi Pakkanen <jpakkane@gmail.com>2019-07-20 17:02:15 +0300
commit9c2724bce5c6a904d1bffdb55921071163812a0e (patch)
tree57cd3503d9b72839162fee20154559bee181e472 /mesonbuild/wrap/wrap.py
parent4200afc74d1e6ba6d117e900799d0d82a85bae8a (diff)
downloadmeson-9c2724bce5c6a904d1bffdb55921071163812a0e.zip
meson-9c2724bce5c6a904d1bffdb55921071163812a0e.tar.gz
meson-9c2724bce5c6a904d1bffdb55921071163812a0e.tar.bz2
Add optional progress bar when generating build.ninja
Diffstat (limited to 'mesonbuild/wrap/wrap.py')
-rw-r--r--mesonbuild/wrap/wrap.py18
1 files changed, 6 insertions, 12 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py
index 55f86bc..4b2a323 100644
--- a/mesonbuild/wrap/wrap.py
+++ b/mesonbuild/wrap/wrap.py
@@ -18,8 +18,9 @@ import urllib.request, os, hashlib, shutil, tempfile, stat
import subprocess
import sys
import configparser
+
from . import WrapMode
-from ..mesonlib import MesonException
+from ..mesonlib import ProgressBar, MesonException
try:
import ssl
@@ -278,24 +279,17 @@ class Resolver:
tmpfile.write(block)
hashvalue = h.hexdigest()
return hashvalue, tmpfile.name
- print('Download size:', dlsize)
- print('Downloading: ', end='')
sys.stdout.flush()
- printed_dots = 0
- downloaded = 0
+ progress_bar = ProgressBar(bar_type='download', total=dlsize,
+ desc='Downloading')
while True:
block = resp.read(blocksize)
if block == b'':
break
- downloaded += len(block)
h.update(block)
tmpfile.write(block)
- ratio = int(downloaded / dlsize * 10)
- while printed_dots < ratio:
- print('.', end='')
- sys.stdout.flush()
- printed_dots += 1
- print('')
+ progress_bar.update(len(block))
+ progress_bar.close()
hashvalue = h.hexdigest()
return hashvalue, tmpfile.name