Skip to content

Commit

Permalink
Fall back on requests module when urllib fails to load a URL (emscrip…
Browse files Browse the repository at this point in the history
…ten-core#8667)

This can happen on systems where OpenSSL is too old.
  • Loading branch information
dschuff authored and belraquib committed Dec 23, 2020
1 parent d9a62fa commit 6a3e7dc
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,12 +925,20 @@ def retrieve():
# retrieve from remote server
logger.warning('retrieving port: ' + name + ' from ' + url)
try:
from urllib.request import urlopen
import requests
response = requests.get(url)
data = response.content
except ImportError:
# Python 2 compatibility
from urllib2 import urlopen
f = urlopen(url)
data = f.read()
try:
from urllib.request import urlopen
f = urlopen(url)
data = f.read()
except ImportError:
# Python 2 compatibility
from urllib2 import urlopen
f = urlopen(url)
data = f.read()

open(fullpath, 'wb').write(data)
State.retrieved = True

Expand Down

0 comments on commit 6a3e7dc

Please sign in to comment.