summaryrefslogtreecommitdiff
path: root/wraptool.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-10-22 18:45:20 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2015-10-22 18:45:20 +0300
commit2056426b479e3a6343b9cf5701391feacbb64bbc (patch)
tree6dcb4089764e31f7978fb286e8572f34252832ad /wraptool.py
parent0c63556286661be83d64739d0a5422cca2d1b95e (diff)
downloadmeson-2056426b479e3a6343b9cf5701391feacbb64bbc.tar.gz
Open all wrapdb urls via the same code path.
Diffstat (limited to 'wraptool.py')
-rwxr-xr-xwraptool.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/wraptool.py b/wraptool.py
index bb0b464ac..68e98ec79 100755
--- a/wraptool.py
+++ b/wraptool.py
@@ -95,11 +95,14 @@ def build_ssl_context():
ctx.load_verify_locations(cadata=wrapdb_certificate)
return ctx
-def get_result(urlstring):
+def open_wrapdburl(urlstring):
if has_ssl:
- u = urllib.request.urlopen(urlstring, context=build_ssl_context())
+ return urllib.request.urlopen(urlstring, context=build_ssl_context())
else:
- u = urllib.request.urlopen(urlstring)
+ return urllib.request.urlopen(urlstring)
+
+def get_result(urlstring):
+ u = open_wrapdburl(urlstring)
data = u.read().decode('utf-8')
jd = json.loads(data)
if jd['output'] != 'ok':
@@ -141,7 +144,7 @@ def install(name):
print('Wrap file already exists.')
sys.exit(1)
(branch, revision) = get_latest_version(name)
- u = urllib.request.urlopen(API_ROOT + 'projects/%s/%s/%s/get_wrap' % (name, branch, revision))
+ u = open_wrapdburl(API_ROOT + 'projects/%s/%s/%s/get_wrap' % (name, branch, revision))
data = u.read()
open(wrapfile, 'wb').write(data)
print('Installed', name, 'branch', branch, 'revision', revision)
@@ -169,7 +172,7 @@ def update(name):
if new_branch == branch and new_revision == revision:
print('Project', name, 'is already up to date.')
sys.exit(0)
- u = urllib.request.urlopen(API_ROOT + 'projects/%s/%s/%d/get_wrap' % (name, new_branch, new_revision))
+ u = open_wrapdburl(API_ROOT + 'projects/%s/%s/%d/get_wrap' % (name, new_branch, new_revision))
data = u.read()
shutil.rmtree(os.path.join('subprojects', subdir), ignore_errors=True)
try: