aboutsummaryrefslogtreecommitdiff
path: root/meson/wrap.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-01-15 21:43:15 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2016-01-15 21:43:15 +0200
commita5508d3fd362ea33633d9706a6257ef0f0c2bbc0 (patch)
treed1b35f622aa5feae62dee35eaef33df19b2b9d40 /meson/wrap.py
parent8b1039fa30a405e2d07ac70eb0284ee4654c619a (diff)
downloadmeson-a5508d3fd362ea33633d9706a6257ef0f0c2bbc0.zip
meson-a5508d3fd362ea33633d9706a6257ef0f0c2bbc0.tar.gz
meson-a5508d3fd362ea33633d9706a6257ef0f0c2bbc0.tar.bz2
Can run most of test suite (with hacks).
Diffstat (limited to 'meson/wrap.py')
-rw-r--r--meson/wrap.py30
1 files changed, 28 insertions, 2 deletions
diff --git a/meson/wrap.py b/meson/wrap.py
index e55d3db..ac9c9ce 100644
--- a/meson/wrap.py
+++ b/meson/wrap.py
@@ -17,7 +17,33 @@ import urllib.request, os, hashlib, shutil
import subprocess
import sys
-from . import wraptool
+try:
+ import ssl
+ has_ssl = True
+ API_ROOT = 'https://wrapdb.mesonbuild.com/v1/'
+except ImportError:
+ has_ssl = False
+ API_ROOT = 'http://wrapdb.mesonbuild.com/v1/'
+
+def open_wrapdburl(urlstring):
+ global ssl_warning_printed
+ if has_ssl:
+ try:
+ return urllib.request.urlopen(urlstring)#, context=build_ssl_context())
+ except urllib.error.URLError:
+ if not ssl_warning_printed:
+ print('SSL connection failed. Falling back to unencrypted connections.')
+ ssl_warning_printed = True
+ if not ssl_warning_printed:
+ 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)
+
class PackageDefinition:
def __init__(self, fname):
@@ -94,7 +120,7 @@ class Resolver:
def get_data(self, url):
blocksize = 10*1024
if url.startswith('https://wrapdb.mesonbuild.com'):
- resp = wraptool.open_wrapdburl(url)
+ resp = open_wrapdburl(url)
else:
resp = urllib.request.urlopen(url)
dlsize = int(resp.info()['Content-Length'])