get-toolchain: Work on both Python 2 + Python 3

This commit is contained in:
Tim 'mithro' Ansell 2020-01-03 19:25:40 +00:00
parent 1f931af94d
commit e505d27f43

View File

@ -66,7 +66,7 @@ def check_files(to_download):
filename = os.path.basename(path)
hasher = hashlib.sha1()
with open(filename, 'r') as f:
with open(filename, 'rb') as f:
while True:
data = f.read(4096)
if not data:
@ -95,7 +95,10 @@ TOOLCHAIN = "https://api.github.com/repos/im-tomu/fomu-toolchain/releases/latest
def get_toolchain_data():
if sys.version_info.major == 2:
from urllib2 import urlopen, Request
elif sys.version_info.major == 3:
from urllib.request import urlopen, Request
request = Request(TOOLCHAIN)