aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/wrap/wrap.py
diff options
context:
space:
mode:
authorMichael Hirsch, Ph.D <scivision@users.noreply.github.com>2019-11-06 04:36:30 -0500
committerJussi Pakkanen <jpakkane@gmail.com>2019-11-07 22:14:59 +0200
commitd08091756191981f1bd3c7741b412b95f965fe0a (patch)
tree00406fafdc8b0311e02366963d217bae932c9a04 /mesonbuild/wrap/wrap.py
parenta47c1374b96e49b5fe617baee3ea85a94cd96ae6 (diff)
downloadmeson-d08091756191981f1bd3c7741b412b95f965fe0a.zip
meson-d08091756191981f1bd3c7741b412b95f965fe0a.tar.gz
meson-d08091756191981f1bd3c7741b412b95f965fe0a.tar.bz2
wrap.py: catch connection error with WrapException
fixes #6130 wrap: more error verbosity
Diffstat (limited to 'mesonbuild/wrap/wrap.py')
-rw-r--r--mesonbuild/wrap/wrap.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py
index 8ad3418..c8c42e7 100644
--- a/mesonbuild/wrap/wrap.py
+++ b/mesonbuild/wrap/wrap.py
@@ -68,17 +68,20 @@ def open_wrapdburl(urlstring: str) -> 'http.client.HTTPResponse':
return urllib.request.urlopen(urlstring, timeout=req_timeout)# , context=build_ssl_context())
except urllib.error.URLError:
if not ssl_warning_printed:
- print('SSL connection failed. Falling back to unencrypted connections.')
+ print('SSL connection failed. Falling back to unencrypted connections.', file=sys.stderr)
ssl_warning_printed = True
if not ssl_warning_printed:
- print('Warning: SSL not available, traffic not authenticated.',
- file=sys.stderr)
+ print('Warning: SSL not available, traffic not authenticated.', file=sys.stderr)
ssl_warning_printed = True
# Trying to open SSL connection to wrapdb fails because the
# certificate is not known.
if urlstring.startswith('https'):
urlstring = 'http' + urlstring[5:]
- return urllib.request.urlopen(urlstring, timeout=req_timeout)
+ try:
+ return urllib.request.urlopen(urlstring, timeout=req_timeout)
+ except urllib.error.URLError:
+ raise WrapException('failed to get {} is the internet available?'.format(urlstring))
+
class WrapException(MesonException):
pass
@@ -306,7 +309,10 @@ class Resolver:
if url.startswith('https://wrapdb.mesonbuild.com'):
resp = open_wrapdburl(url)
else:
- resp = urllib.request.urlopen(url, timeout=req_timeout)
+ try:
+ resp = urllib.request.urlopen(url, timeout=req_timeout)
+ except urllib.error.URLError:
+ raise WrapException('could not get {} is the internet available?'.format(url))
with contextlib.closing(resp) as resp:
try:
dlsize = int(resp.info()['Content-Length'])