Skip to content

Commit cae8169

Browse files
author
arch
committed
improve installer
1 parent 4b02113 commit cae8169

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

contrib/windows_installer.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,24 @@ def download_url(url, output_path):
6969
except: print('Error while deleting old Version')
7070

7171
os.makedirs(dest_dir, exist_ok = True)
72-
with zipfile.ZipFile(zip_file) as zf:
73-
for member in tqdm(zf.infolist(), desc='Extracting '):
74-
zf.extract(member, dest_dir)
72+
trial = 0
73+
while True:
74+
try:
75+
with zipfile.ZipFile(zip_file) as zf:
76+
for member in tqdm(zf.infolist(), desc='Extracting '):
77+
zf.extract(member, dest_dir)
78+
break
79+
except:
80+
trial += 1
81+
if trial < 2:
82+
print("local version is corrupt redownloading")
83+
os.remove(zip_file)
84+
download_url(download_urls[latest], zip_file)
85+
else:
86+
print("installation failed")
87+
sys.exit()
7588

7689
with open(os.path.join(extension_dir, "main.lua"), "wb") as f:
7790
f.write(requests.get(lua_extension_url).content)
91+
92+
print("installation completed")

0 commit comments

Comments
 (0)