WIP: Project Tools: Remove Requests Module from studio scripts #279

Closed
Nick Alberelli wants to merge 4 commits from TinyNick/blender-studio-pipeline:fix/remove-request-from-update-addons into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Showing only changes of commit cc7f59728a - Show all commits

View File

@ -2,9 +2,8 @@
import hashlib import hashlib
from pathlib import Path from pathlib import Path
from urllib.request import urlretrieve from urllib.request import urlretrieve, urlopen
import sys import sys
import requests
import glob import glob
import os import os
@ -23,7 +22,7 @@ def update_blender_studio_addons(download_folder_path: Path):
url_zip = "https://projects.blender.org/studio/blender-studio-pipeline/releases/download/latest/blender_studio_add-ons_latest.zip" url_zip = "https://projects.blender.org/studio/blender-studio-pipeline/releases/download/latest/blender_studio_add-ons_latest.zip"
# Check current sha and early return if match # Check current sha and early return if match
web_sha = requests.get(url_sha).text.strip().lower() web_sha = urlopen(url_sha).read().decode()
if sha_file.exists() & zip_file.exists(): if sha_file.exists() & zip_file.exists():
if shasum_matches(zip_file, web_sha): if shasum_matches(zip_file, web_sha):
print(f"{zip_file.name} already up to date, canceling update") print(f"{zip_file.name} already up to date, canceling update")
@ -67,13 +66,7 @@ def download_file(url, out_folder, filename):
for file in prev_downloaded_files: for file in prev_downloaded_files:
os.remove(file) os.remove(file)
# 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)
local_hash_filename = local_filename.with_suffix(".zip.sha256") local_hash_filename = local_filename.with_suffix(".zip.sha256")
with open(local_filename, "rb") as f: with open(local_filename, "rb") as f: