Skip to content

Commit 33880c7

Browse files
author
arch
committed
add test code to win installer
1 parent 96f72ed commit 33880c7

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

contrib/windows_installer.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import zipfile
66
import os
77
import sys
8+
import shutil
89

910
from packaging import version
1011
from bs4 import BeautifulSoup # beautifulsoup4
@@ -23,6 +24,9 @@ def download_url(url, output_path):
2324
urllib.request.urlretrieve(url, filename=output_path, reporthook=t.update_to)
2425

2526

27+
# NOTE: this file is currently not working for this installer!
28+
extension_url = "https://raw.githubusercontent.com/michael-mueller-git/Python-Funscript-Editor/main/contrib/OpenFunscripter/extensions/Funscript%20Generator%20Windows/main.lua"
29+
2630
if platform.system() != "Windows":
2731
print("ERROR: This installer only work on Windows")
2832
sys.exit()
@@ -41,15 +45,22 @@ def download_url(url, output_path):
4145
if link.get('href').endswith(".zip") and "/releases/" in link.get('href')]
4246
}
4347
latest = max(download_urls)
44-
zip_file = os.path.join(ofs_extension_dir, "Funscript Generator Windows", "funscript-editor-v" + str(latest) + ".zip")
45-
dest_dir = os.path.dirname(zip_file)
46-
os.makedirs(dest_dir, exist_ok = True)
48+
extension_dir = os.path.join(ofs_extension_dir, "Funscript Generator Windows")
49+
zip_file = os.path.join(extension_dir, "funscript-editor-v" + str(latest) + ".zip")
50+
dest_dir = os.path.join(os.path.dirname(zip_file), "funscript-editor")
4751

52+
os.makedirs(os.path.dirname(zip_file), exist_ok = True)
4853
if not os.path.exists(zip_file):
4954
download_url(download_urls[latest], zip_file)
5055

56+
if os.path.exists(dest_dir):
57+
try: shutil.rmtree(dest_dir)
58+
except: print('Error while deleting old Version')
59+
60+
os.makedirs(dest_dir, exist_ok = True)
5161
with zipfile.ZipFile(zip_file) as zf:
5262
for member in tqdm(zf.infolist(), desc='Extracting '):
53-
zf.extract(member, "funscript-editor")
63+
zf.extract(member, dest_dir)
5464

55-
# TODO download the main.lua to the extension dir
65+
with open(os.path.join(extension_dir, "main.lua"), "wb") as f:
66+
f.write(requests.get(extension_url).content)

0 commit comments

Comments
 (0)