Added download script for blender

This commit is contained in:
2022-06-15 00:55:18 +02:00
parent c8c06c42bc
commit 4d84861b62
6 changed files with 71 additions and 16 deletions

9
.gitignore vendored
View File

@@ -263,8 +263,9 @@ out/
output/
blender-win/
blender-linux/
blender/
dependencies/windows/
dependencies/darwin/
dependencies/linux/
index.build.js
index.build.js
index.build.js.LICENSE.txt

View File

@@ -1,10 +1,11 @@
{
"version": "0.6.2",
"version": "0.8.1",
"name": "stickexportertx",
"productName": "StickExporterTX",
"description": "3D stick exporter for EdgeTX/OpenTX logs",
"main": "src/index.build.js",
"scripts": {
"install:deps": "python ./scripts/download-blender.py",
"build:main": "cross-env NODE_ENV=production webpack --config configs/webpack.main.prod.config.babel.js",
"build:renderer": "cross-env NODE_ENV=production webpack --config configs/webpack.renderer.prod.config.babel.js",
"build": "cross-env npm run build:main && cross-env npm run build:renderer",
@@ -29,8 +30,8 @@
"package.json"
],
"extraFiles": [
"assets/template.blend",
"assets/blenderScript.py"
"dependencies/template.blend",
"dependencies/blenderScript.py"
],
"win": {
"icon": "icon.png",
@@ -39,8 +40,8 @@
],
"extraFiles": [
{
"from": "assets/blender/",
"to": "assets/blender/",
"from": "dependencies/windows/",
"to": "dependencies/windows/",
"filter": [
"**/*"
]
@@ -62,8 +63,8 @@
],
"extraFiles": [
{
"from": "assets/blender/",
"to": "assets/blender/",
"from": "dependencies/linux/",
"to": "dependencies/linux/",
"filter": [
"**/*"
]
@@ -78,8 +79,8 @@
],
"extraFiles": [
{
"from": "assets/blender/",
"to": "assets/blender/",
"from": "dependencies/darwin/",
"to": "dependencies/darwin/",
"filter": [
"**/*"
]

View File

@@ -0,0 +1,44 @@
from io import BytesIO
import urllib.request
from zipfile import ZipFile
import tarfile
import os
import shutil
import time
windowsURL = 'https://ftp.halifax.rwth-aachen.de/blender/release/Blender3.2/blender-3.2.0-windows-x64.zip'
linuxURL = 'https://ftp.halifax.rwth-aachen.de/blender/release/Blender3.2/blender-3.2.0-linux-x64.tar.xz'
# Windows
if(os.path.exists('./dependencies/windows')):
print("Removing old windows folder")
shutil.rmtree('./dependencies/windows')
print("Downloading windows version")
with urllib.request.urlopen(windowsURL) as zipresp:
with ZipFile(BytesIO(zipresp.read())) as zfile:
zfile.extractall('./dependencies/windows')
print("Adjust windows version")
oldWindowsName = windowsURL.split('/')[-1].replace('.zip', '')
os.rename('./dependencies/windows/' + oldWindowsName, './dependencies/windows/blender')
# Linux
if(os.path.exists('./dependencies/linux')):
print("Removing old linux folder")
shutil.rmtree('./dependencies/linux')
print("Downloading linux version")
os.mkdir('./dependencies/linux')
urllib.request.urlretrieve(linuxURL, './dependencies/linux/blender.tar.xz')
print("Extracting linux version")
with tarfile.open('./dependencies/linux/blender.tar.xz') as tfile:
tfile.extractall('./dependencies/linux')
print("Adjust linux version")
oldLinuxName = linuxURL.split('/')[-1].replace('.tar.xz', '')
os.rename('./dependencies/linux/' + oldLinuxName, './dependencies/linux/blender')
print("Clean up linux folder")
os.remove('./dependencies/linux/blender.tar.xz')

View File

@@ -6,6 +6,15 @@ export const SettingPath = path.join(dataPath, "settings.xml");
export const defaultOutputPath = path.join(app.getPath('videos'), "StickExporterTX");
export const blenderPath = path.join("assets", "blender", "blender");
export const templatePath = path.join("assets", "template.blend");
export const blenderScriptPath = path.join("assets", "blenderScript.py");
let platformFolder = "";
if(process.platform === "win32"){
platformFolder = "windows";
} else if(process.platform === "darwin"){
platformFolder = "darwin";
} else if(process.platform === "linux"){
platformFolder = "linux";
}
export const blenderPath = path.join("dependencies", platformFolder, "blender", "blender");
export const templatePath = path.join("dependencies", "template.blend");
export const blenderScriptPath = path.join("dependencies", "blenderScript.py");