WIP: Project Tools: Remove Requests Module from studio scripts #279
@ -5,7 +5,7 @@ import glob
|
||||
import hashlib
|
||||
import os
|
||||
import pathlib
|
||||
import requests
|
||||
from urllib.request import urlretrieve, urlopen
|
||||
import shutil
|
||||
import json
|
||||
|
||||
@ -18,13 +18,7 @@ BLENDER_BRANCH = "main"
|
||||
def download_file(url, out_folder):
|
||||
print("Downloading: " + url)
|
||||
local_filename = out_folder / url.split('/')[-1]
|
||||
# NOTE the stream=True parameter below
|
||||
with requests.get(url, stream=True) as r:
|
||||
r.raise_for_status()
|
||||
with open(local_filename, 'wb') as f:
|
||||
for chunk in r.iter_content(chunk_size=None):
|
||||
if chunk:
|
||||
f.write(chunk)
|
||||
urlretrieve(url, str(local_filename))
|
||||
return local_filename
|
||||
|
||||
|
||||
@ -60,8 +54,8 @@ platforms_dict = {
|
||||
|
||||
download_info = []
|
||||
branch_string = "+" + BLENDER_BRANCH
|
||||
reqs = requests.get(BUILDS_INDEX)
|
||||
available_downloads = json.loads(reqs.text)
|
||||
reqs = urlopen(BUILDS_INDEX).read().decode()
|
||||
available_downloads = json.loads(reqs)
|
||||
for download in available_downloads:
|
||||
if download["branch"] != BLENDER_BRANCH:
|
||||
continue
|
||||
@ -81,7 +75,7 @@ for info in download_info:
|
||||
file_extension = platforms_dict[platform]
|
||||
url = info[1]
|
||||
url_sha = url + ".sha256"
|
||||
sha = requests.get(url_sha).text.strip().lower()
|
||||
sha = urlopen(url_sha).read().decode().strip().lower()
|
||||
arch = info[2]
|
||||
|
||||
current_platform_file = glob.glob(f"{download_folder_path}/*{platform}.{arch}*{file_extension}")
|
||||
|
Loading…
Reference in New Issue
Block a user