aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-03-17 00:03:41 -0400
committerXavier Claessens <xclaesse@gmail.com>2022-03-27 18:57:07 -0400
commitfaafcc15e2562c2847004903423d70aff4372e96 (patch)
tree8c9f691902e8926a9d40ddad01a82b6b73a4879f
parentb28e6aead4708a100d60b56a044f36b28a112326 (diff)
downloadmeson-faafcc15e2562c2847004903423d70aff4372e96.zip
meson-faafcc15e2562c2847004903423d70aff4372e96.tar.gz
meson-faafcc15e2562c2847004903423d70aff4372e96.tar.bz2
wrap: use shared function to connect to wrapdb with better errors
We currently inconsistently handle connection, `has_ssl`, and printing errors on urlopen failure between `meson subprojects` and `meson wrap`. Make the latter work more like the former.
-rw-r--r--mesonbuild/wrap/wraptool.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/mesonbuild/wrap/wraptool.py b/mesonbuild/wrap/wraptool.py
index ca14315..b87ae3f 100644
--- a/mesonbuild/wrap/wraptool.py
+++ b/mesonbuild/wrap/wraptool.py
@@ -20,8 +20,7 @@ import typing as T
from glob import glob
from urllib.parse import urlparse
-from urllib.request import urlopen
-from .wrap import WrapException
+from .wrap import open_wrapdburl, WrapException
from .. import mesonlib
@@ -59,7 +58,7 @@ def add_arguments(parser: 'argparse.ArgumentParser') -> None:
p.set_defaults(wrap_func=promote)
def get_releases() -> T.Dict[str, T.Any]:
- url = urlopen('https://wrapdb.mesonbuild.com/v2/releases.json')
+ url = open_wrapdburl('https://wrapdb.mesonbuild.com/v2/releases.json')
return T.cast('T.Dict[str, T.Any]', json.loads(url.read().decode()))
def list_projects(options: 'argparse.Namespace') -> None:
@@ -97,7 +96,7 @@ def install(options: 'argparse.Namespace') -> None:
if os.path.exists(wrapfile):
raise SystemExit('Wrap file already exists.')
(version, revision) = get_latest_version(name)
- url = urlopen(f'https://wrapdb.mesonbuild.com/v2/{name}_{version}-{revision}/{name}.wrap')
+ url = open_wrapdburl(f'https://wrapdb.mesonbuild.com/v2/{name}_{version}-{revision}/{name}.wrap')
with open(wrapfile, 'wb') as f:
f.write(url.read())
print(f'Installed {name} version {version} revision {revision}')
@@ -140,7 +139,7 @@ def get_current_version(wrapfile: str) -> T.Tuple[str, str, str, str, T.Optional
return branch, revision, wrap_data['directory'], wrap_data['source_filename'], patch_filename
def update_wrap_file(wrapfile: str, name: str, new_version: str, new_revision: str) -> None:
- url = urlopen(f'https://wrapdb.mesonbuild.com/v2/{name}_{new_version}-{new_revision}/{name}.wrap')
+ url = open_wrapdburl(f'https://wrapdb.mesonbuild.com/v2/{name}_{new_version}-{new_revision}/{name}.wrap')
with open(wrapfile, 'wb') as f:
f.write(url.read())