wrap.py: catch connection error with WrapException

fixes #6130

wrap: more error verbosity
pull/6148/head
Michael Hirsch, Ph.D 5 years ago committed by Jussi Pakkanen
parent a47c1374b9
commit d080917561
  1. 16
      mesonbuild/wrap/wrap.py
  2. 4
      mesonbuild/wrap/wraptool.py
  3. 2
      test cases/common/91 dep fallback/tester.c

@ -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'])

@ -124,11 +124,11 @@ def update(options):
raise SystemExit('Subprojects dir not found. Run this command in your source root directory.')
wrapfile = os.path.join('subprojects', name + '.wrap')
if not os.path.exists(wrapfile):
raise SystemExit('Project', name, 'is not in use.')
raise SystemExit('Project ' + name + ' is not in use.')
(branch, revision, subdir, src_file, patch_file) = get_current_version(wrapfile)
(new_branch, new_revision) = get_latest_version(name)
if new_branch == branch and new_revision == revision:
print('Project', name, 'is already up to date.')
print('Project ' + name + ' is already up to date.')
raise SystemExit
update_wrap_file(wrapfile, name, new_branch, new_revision)
shutil.rmtree(os.path.join('subprojects', subdir), ignore_errors=True)

@ -3,7 +3,7 @@
#include<string.h>
#include<stdio.h>
int main(int argc, char **argv) {
int main(void) {
if(strcmp("bob", get_bob()) == 0) {
printf("Bob is indeed bob.\n");
} else {

Loading…
Cancel
Save