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