!F (CE-14343) (Animation) added an explicit sleep speed setting for character ropes
[CRYENGINE.git] / download_sdks.py
blobfc578433dc40e7bc7a58a8f3113d3054210b152d
1 #!/usr/bin/env python3
2 from zipfile import ZipFile
3 from tarfile import TarFile
4 from urllib import request
6 import os
7 import platform
10 def print_progress(current, maxprogress):
11 status = "%10d [%3.2f%%]" % (current, current * 100. / maxprogress)
12 print(status, end='\r')
15 def read_chunks(url, block_sz=8192 * 8):
16 with request.urlopen(url) as openurl:
17 while True:
18 data = openurl.read(block_sz)
19 if data:
20 yield data
21 else:
22 return
25 BASE_URL = 'https://github.com/CRYTEK/CRYENGINE/releases/download/5.4.0/CRYENGINE_v5.4.0_SDKs'
28 def main():
29 # use ZIP on windows and tar on other platforms
30 if platform.system() == 'Windows':
31 url = BASE_URL + '.zip'
32 ArchiveFile = ZipFile
33 list_archive = ZipFile.namelist
34 else:
35 url = BASE_URL + '.tar.gz'
36 ArchiveFile = TarFile.open
37 list_archive = TarFile.getnames
39 temp_folder = '.'
40 file_name = url.split('/')[-1]
41 temp_file = os.path.join(temp_folder, file_name)
43 u = request.urlopen(url)
44 meta = u.info()
45 file_size = int(u.getheader("Content-Length"))
47 print("Downloading: %s Bytes: %s" % (file_name, file_size))
49 with open(temp_file, 'wb') as tfile:
50 downloaded_bytes = 0
51 for chunk in read_chunks(url):
52 downloaded_bytes += len(chunk)
53 tfile.write(chunk)
55 print_progress(downloaded_bytes, file_size)
57 print()
59 with ArchiveFile(temp_file) as zf:
60 nameList = list_archive(zf)
61 num_files = len(nameList)
62 output_path = 'Code/SDKs'
64 print('Extracting %d files to:"%s"' % (num_files, output_path))
66 for counter, item in enumerate(nameList, start=1):
67 zf.extract(item, output_path)
68 print_progress(counter, num_files)
70 print()
71 os.remove(temp_file)
73 if __name__== '__main__':
74 main()