Skip to content

Commit

Permalink
feat: Better update check
Browse files Browse the repository at this point in the history
  • Loading branch information
Axorax committed Dec 9, 2024
1 parent 7b288ce commit 175e7ab
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 22 deletions.
9 changes: 4 additions & 5 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import webbrowser
import tkinter as tk
from tk import tk_code
from utils import extract_figma_id, check_for_updates
from utils import extract_figma_id, has_update
from tkinter import filedialog, messagebox

def load_asset(path):
Expand Down Expand Up @@ -273,10 +273,9 @@ def select_outpath():

donate_button.place(x=371, y=446, width=343, height=34)

try:
exec(check_for_updates())
except:
print("No updates!")
update = has_update()
if update == True:
messagebox.showinfo('New update!', "Update your version of TkForge to get the latest features! https://github.com/axorax/tkforge/releases")

root.resizable(False, False)
root.mainloop()
1 change: 0 additions & 1 deletion info.py

This file was deleted.

3 changes: 0 additions & 3 deletions info_cli.py

This file was deleted.

4 changes: 0 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ colorama==0.4.6
idna==3.7
packaging==24.1
pefile==2024.8.26
<<<<<<< HEAD
pillow==10.4.0
=======
>>>>>>> 250f915 (fix: Include pyinstaller)
pyinstaller==6.10.0
pyinstaller-hooks-contrib==2024.8
pywin32-ctypes==0.2.3
Expand Down
8 changes: 4 additions & 4 deletions tkforge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import argparse
from tk import tk_code
from colorama import Fore, init
from utils import extract_figma_id, check_for_updates, VERSION
from utils import extract_figma_id, has_update, VERSION

init(autoreset=True)

Expand Down Expand Up @@ -37,11 +37,11 @@ def main():

if args.update:
try:
update = check_for_updates(False)
if update == "":
update = has_update()
if update == False:
print(Fore.GREEN + "No updates!")
else:
exec(update)
print("New update!\nUpdate your version of TkForge to get the latest features!\nhttps://github.com/axorax/tkforge/releases")
except:
print(Fore.RED + "Update check failed!")
return
Expand Down
8 changes: 3 additions & 5 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
VERSION = "2.1.1"
BASE_URL = "https://raw.githubusercontent.com/Axorax/tkforge/refs/heads/main/"

def check_for_updates(gui_info = True):
def has_update():
try:
global VERSION
response = requests.get(f"{BASE_URL}VERSION.txt")
Expand All @@ -14,11 +14,9 @@ def check_for_updates(gui_info = True):
version_tuple = tuple(map(int, VERSION.split('.')))
online_version_tuple = tuple(map(int, online_version.split('.')))
if online_version_tuple > version_tuple:
response = requests.get(f"{BASE_URL}{"info" if gui_info else "info_cli"}.py")
response.raise_for_status()
return response.text
return True
else:
return ""
return False
except requests.RequestException as e:
return ""

Expand Down

0 comments on commit 175e7ab

Please sign in to comment.