Add project-tools #142

Merged
Francesco Siddi merged 26 commits from ZedDB/blender-studio-pipeline:project-helper-tools into main 2023-08-31 20:33:04 +02:00
2 changed files with 49 additions and 1 deletions
Showing only changes of commit cdab755497 - Show all commits

View File

@ -0,0 +1,48 @@
#!/usr/bin/env python3
import requests
import pathlib
import os
import glob
import hashlib
DOWNLOAD_DIR = "../../shared/artifacts/addons/"
def download_file(url, out_folder, filename):
print("Downloading: " + url)
local_filename = out_folder / filename
# TODO Can't check any shasums before downloading so always remove and redownload everything for now
prev_downloaded_files = glob.glob(f"{local_filename}*")
for file in prev_downloaded_files:
os.remove(file)
# 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)
local_hash_filename = local_filename.with_suffix(".zip.sha256")
with open(local_filename, "rb") as f:
digest = hashlib.file_digest(f, "sha256")
with open(local_hash_filename, "w") as hash_file:
hash_file.write(digest.hexdigest())
return local_filename
current_file_folder_path = pathlib.Path(__file__).parent
download_folder_path = (current_file_folder_path / DOWNLOAD_DIR).resolve()
# Ensure that the download directory exists
os.makedirs(download_folder_path, exist_ok=True)
download_file(
"https://projects.blender.org/studio/blender-studio-pipeline/archive/main.zip",
download_folder_path,
"blender-studio-pipeline-main.zip",
)

View File

@ -17,7 +17,7 @@ download_addon() {
# Download the addons repo
wget $URL -O $OUT_NAME
sha256sum *.zip > $OUT_NAME.sha256
sha256sum $OUT_NAME > $OUT_NAME.sha256
popd
}