diff --git a/README.md b/README.md
index 5bab829..c85e8dd 100644
--- a/README.md
+++ b/README.md
@@ -6,9 +6,11 @@
instead of losing track of every sole version they use.
## Dependencies
-
You need **[requests](https://pypi.org/project/requests/)** for the application to work.
Pyinstaller is only needed for building.
+
+Windows only :
+To implement the icon, install pillow pip install pillow and add -i img/icon.svg to the pyinstaller command.
## Building from source
diff --git a/backend.py b/backend.py
index 20071ae..a5a2cd2 100644
--- a/backend.py
+++ b/backend.py
@@ -1,6 +1,7 @@
import platform
import requests
-from os import popen,remove,mkdir
+from os import remove,mkdir
+import subprocess
import shutil
from time import sleep
import re
@@ -79,26 +80,34 @@
return response.json()
+def loadAltOptions(mono: str) -> list :
+ installed_files = getAllFiles(mono)
+ installed_files.sort(reverse=True)
+ if installed_files != [] :
+ return installed_files
+ else:
+ return ['No options available']
+
# Get the versions of the Godot Engine and sort them from latest to oldest
def verOptions(mono: str, curVersion: list|None) -> list:
tag_list = []
- if regainedConnection() :
+ altOptions = loadAltOptions(mono)
+
+ if not checkConnection() :
+ return altOptions
+ elif curVersion == None and checkConnection() :
response = requestGitHubInfo()
+ elif curVersion == altOptions and checkConnection() :
+ response = requestGitHubInfo()
+ elif curVersion != altOptions :
+ return altOptions
else :
- response = curVersion
-
- if type(response) == dict :
- installed_files = getAllFiles(mono)
- installed_files.sort(reverse=True)
- if installed_files != [] :
- return installed_files
- else:
- tag_list.append('No options available')
- return tag_list
- elif curVersion != None and checkConnection() :
return curVersion
+
+ if type(response) == dict or response == [] :
+ return altOptions
for i in response :
tag_list.append(i['tag_name'])
@@ -107,15 +116,28 @@
tag_list.sort(reverse=True)
tag_list.pop()
else :
- installed_files = getAllFiles(mono)
- installed_files.sort(reverse=True)
- if installed_files != [] :
- return installed_files
- else:
- tag_list.append('No options available')
+ return altOptions
return tag_list
+def downloadCmd(asset_url: str) -> int :
+ curlStr = f"curl -Lo {APP_PATH}/Godot.zip {asset_url}"
+ if subprocess.run(curlStr.split(' ')).returncode != 0 :
+ return 1
+
+ if OS == 'Linux' :
+ unzipStr = f"unzip -d {APP_PATH} {APP_PATH}/Godot.zip"
+ elif OS == 'Windows' :
+ unzipStr = f"tar -xf {APP_PATH}/Godot.zip -C {APP_PATH}"
+
+ if subprocess.run(unzipStr.split(' ')).returncode != 0 :
+ return 1
+
+ remove(f"{APP_PATH}/Godot.zip")
+
+ return 0
+
+
def downloadGodot(cur_version: str,mono: str) -> int :
if not pathlib.Path(APP_PATH).exists() :
@@ -146,13 +168,9 @@
monoGoal = []
- if re.findall(f"server|headless{monoCatch}",asset['name']) == [] and regex in [['linux','x86_64']+monoGoal,['x11','64']+monoGoal] :#(asset['name'].find('linux') > 0 or asset['name'].find('x11') > 0) and (asset['name'].find(ARCH) > 0 or asset['name'].find('64') > 0) and asset['name'].find('server') == -1:
- popen(f"curl -Lo {APP_PATH}/Godot.zip {asset['browser_download_url']}")
- sleep(10)
- popen(f"unzip -d {APP_PATH} {APP_PATH}/Godot.zip")
- sleep(10)
- remove(f"{APP_PATH}/Godot.zip")
- return 0
+ if re.findall(f"server|headless{monoCatch}",asset['name']) == [] and regex in [['linux','x86_64']+monoGoal,['x11','64']+monoGoal] :
+ return downloadCmd(asset['browser_download_url]'])
+
elif OS == 'Windows' :
if mono != 'no_mono' :
@@ -161,19 +179,10 @@
monoGoal = []
if ['win','arm64'] + monoGoal == re.findall('win',asset['name']) + re.findall('arm64',asset['name']) + re.findall('mono',asset['name']) :
- popen(f"curl -Lo {APP_PATH}/Godot.zip {asset['browser_download_url']}")
- sleep(10)
- popen(f"tar -xf {APP_PATH}/Godot.zip -C {APP_PATH}")
- sleep(10)
- remove(f"{APP_PATH}/Godot.zip")
- return 0
+ return downloadCmd(asset['browser_download_url]'])
+
elif ['win64'] + monoGoal == re.findall('win64',asset['name']) + re.findall('mono',asset['name']) :
- popen(f"curl -Lo {APP_PATH}/Godot.zip {asset['browser_download_url']}")
- sleep(10)
- popen(f"tar -xf {APP_PATH}/Godot.zip -C {APP_PATH}")
- sleep(10)
- remove(f"{APP_PATH}/Godot.zip")
- return 0
+ return downloadCmd(asset['browser_download_url]'])
else :
return 1
else :
diff --git a/img/icon.png b/img/icon.png
new file mode 100644
index 0000000..4e50264
--- /dev/null
+++ b/img/icon.png
Binary files differ
diff --git a/img/icon.svg b/img/icon.svg
new file mode 100644
index 0000000..43f6ecc
--- /dev/null
+++ b/img/icon.svg
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/main.py b/main.py
index f458a8a..f5cb9ae 100644
--- a/main.py
+++ b/main.py
@@ -5,16 +5,16 @@
import pathlib
def tryDownload() -> None :
- if backend.checkSettings() :
- if backend.downloadGodot(strvar.get(),mono.get()) == 0 :
- print('Download was successful')
- else :
- print('Something went wrong')
+ if backend.checkSettings() :
+ if backend.downloadGodot(strvar.get(),mono.get()) == 0 :
+ print('Download was successful')
+ else :
+ print('Something went wrong')
- else :
- openSettings()
+ else :
+ openSettings()
- isInstalled()
+ isInstalled()
def tryLaunch() -> None :
if backend.checkSettings() :
@@ -40,24 +40,24 @@
app_path.set(fd.askdirectory(initialdir=pathlib.Path.home(),mustexist=True))
def isInstalled(*event) -> None :
- global strvar
- DOWNLOAD_BUTTON = tk.Button(CANVAS,activebackground="#aaa",bg="#888",text="Download",command=tryDownload)
- REMOVE_BUTTON = tk.Button(CANVAS,activebackground="#aaa",bg="#888",text="Remove",command=tryRemove)
+ global strvar
+ DOWNLOAD_BUTTON = tk.Button(CANVAS,activebackground="#aaa",bg="#888",text="Download",command=tryDownload)
+ REMOVE_BUTTON = tk.Button(CANVAS,activebackground="#aaa",bg="#888",text="Remove",command=tryRemove)
- if backend.getFile(strvar.get(),mono.get()) == 1 :
- try :
- REMOVE_BUTTON.destroy()
- except :
- pass
- finally :
- DOWNLOAD_BUTTON.place(width=72,height=36,relx=0.34,y=380)
- else :
- try :
- DOWNLOAD_BUTTON.destroy()
- except :
- pass
- finally :
- REMOVE_BUTTON.place(width=72,height=36,relx=0.34,y=380)
+ if backend.getFile(strvar.get(),mono.get()) == 1 and backend.TOKEN != '' :
+ try :
+ REMOVE_BUTTON.destroy()
+ except :
+ pass
+ finally :
+ DOWNLOAD_BUTTON.place(width=72,height=36,relx=0.34,y=380)
+ else :
+ try :
+ DOWNLOAD_BUTTON.destroy()
+ except :
+ pass
+ finally :
+ REMOVE_BUTTON.place(width=72,height=36,relx=0.34,y=380)
def quit() -> None :
@@ -112,6 +112,8 @@
FRONTEND.geometry("650x480")
FRONTEND.resizable(False,False)
FRONTEND.title("GVM")
+icon = tk.PhotoImage("img/icon.png")
+FRONTEND.iconphoto(True,icon)
app_path = tk.StringVar(FRONTEND,backend.APP_PATH)
ttk.Style().configure("M.TCombobox",background="#888")
@@ -138,6 +140,7 @@
Menubar.add_cascade(label='File',menu=file_menu)
CANVAS.place(relheight=1,relwidth=1)
+CANVAS.create_image(120,20)
CANVAS.create_text(325,36,font="JetBrainsMono 24",text="Godot Version Manager")
LAUNCH_BUTTON.place(width=72,height=36,relx=0.55,y=380)
updateVersionList()