From 3d8876bf59ed20635cdc25de7a2da0d17210c944 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Fri, 9 Sep 2016 22:10:31 +0300 Subject: [PATCH] Download without status updates if server does not report file size. Closes #771. --- mesonbuild/wrap/wrap.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index f03af6704..16293e882 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -139,7 +139,13 @@ class Resolver: else: resp = urllib.request.urlopen(url) with contextlib.closing(resp) as resp: - dlsize = int(resp.info()['Content-Length']) + try: + dlsize = int(resp.info()['Content-Length']) + except TypeError: + dlsize = None + if dlsize is None: + print('Downloading file of unknown size.') + return resp.read() print('Download size:', dlsize) print('Downloading: ', end='') sys.stdout.flush()