procedural-3d-engine/download_assets.py
Ciro Santilli 848310ffdb Allow Linux users to build Android even if Python 2 is their default Python
After this commit, users who have the `python` executable as Python 2 can do simply:

    cd android/
    ./build-all.py
    ./build.py

Previously, the following would fail:

    python3 build-all.py

since build-all.py did subcalls to `python build.py`.

Remove install-all.py as it is redundant with `build-all.py -deploy`,
instead of fixing it as well.

Introduce argparse since we are separating argument parsing out of
the `main()` function.

Tested in Ubuntu 16.04, behaviour should be unchanged for Windows.
2017-10-26 17:09:59 +01:00

31 lines
896 B
Python
Executable file

#!/usr/bin/env python3
import sys
from urllib.request import urlretrieve
from zipfile import ZipFile
ASSET_PACK_URL = 'http://vulkan.gpuinfo.org/downloads/vulkan_asset_pack.zip'
ASSET_PACK_FILE_NAME = 'vulkan_asset_pack.zip'
print("Downloading asset pack from '%s'" % ASSET_PACK_URL)
def reporthook(blocknum, blocksize, totalsize):
bytesread = blocknum * blocksize
if totalsize > 0:
percent = bytesread * 1e2 / totalsize
s = "\r%5.1f%% (%*d / %d bytes)" % (percent, len(str(totalsize)), bytesread, totalsize)
sys.stderr.write(s)
if bytesread >= totalsize:
sys.stderr.write("\n")
else:
sys.stderr.write("read %d\n" % (bytesread,))
urlretrieve(ASSET_PACK_URL, ASSET_PACK_FILE_NAME, reporthook)
print("Download finished")
print("Extracting assets")
zip = ZipFile(ASSET_PACK_FILE_NAME, 'r')
zip.extractall("./")
zip.close()