-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap.py
53 lines (40 loc) · 1.52 KB
/
bootstrap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import shutil
import tempfile
import requests
from pathlib import Path
from tqdm import tqdm
umodel_url = 'https://seafile.darklightgames.com/d/69b3b60f652b4cef8b4c/files/?p=%2Fumodel_64.exe&dl=1'
blender_url = 'https://seafile.darklightgames.com/d/69b3b60f652b4cef8b4c/files/?p=%2Fblender-3.6-bdk.zip&dl=1'
bdk_addon_url = 'https://seafile.darklightgames.com/d/69b3b60f652b4cef8b4c/files/?p=%2Fbdk.zip&dl=1'
def download(url, filename, desc=None):
response = requests.get(url, stream=True)
chunk_size = 1024
if response.status_code != 200:
response.raise_for_status()
raise RuntimeError('Bad response from server')
file_size = int(response.headers.get('content-length', 0))
path = Path(filename).expanduser().resolve()
path.parent.mkdir(parents=True, exist_ok=True)
with open(filename, 'wb') as file, tqdm(
desc=desc,
total=file_size,
unit='iB',
unit_scale=True,
unit_divisor=1024,
) as bar:
for data in response.iter_content(chunk_size):
size = file.write(data)
bar.update(size)
def install_umodel():
umodel_filename = './bin/umodel.exe'
download(umodel_url, umodel_filename, 'umodel')
def install_blender():
blender_filename = tempfile.mktemp(suffix='.zip')
download(blender_url, blender_filename, 'blender')
shutil.unpack_archive(blender_filename, './bin/blender')
Path(blender_filename).unlink()
def install_bdk_cli():
pass
if __name__ == '__main__':
install_umodel()
install_blender()