Skip to content

Commit 1216868

Browse files
committed
add check version
1 parent 16f7937 commit 1216868

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

sourceSDK++.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#from PIL import Image
1414
import git
1515
import ctypes as ct
16+
import requests
17+
import webbrowser
18+
from tkinter import messagebox
1619

1720
class SourceSDK():
1821
selected_folder : string
@@ -627,6 +630,42 @@ def move_files(source_folder, destination_folder):
627630
shutil.move(source_file, destination_file)
628631

629632

633+
def get_latest_release_version(repo_owner, repo_name):
634+
url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/releases/latest"
635+
response = requests.get(url)
636+
if response.status_code == 200:
637+
data = response.json()
638+
return data['tag_name']
639+
else:
640+
return None
641+
642+
def check_software_version(local_version, github_version):
643+
if local_version == github_version:
644+
print("You have the latest version installed.")
645+
else:
646+
print(f"There is a newer version ({github_version}) available on GitHub.")
647+
648+
# Replace these with your GitHub repository owner and name
649+
repo_owner = "ChocoScaff"
650+
repo_name = "SourceSDK-"
651+
652+
# Replace this with the version of your local software
653+
local_version = "0.0.1"
654+
655+
github_version = get_latest_release_version(repo_owner, repo_name)
656+
657+
if github_version:
658+
check_software_version(local_version, github_version)
659+
else:
660+
print("Failed to fetch the latest version from GitHub.")
661+
download = messagebox.askyesno("New Version Available", f"There is a newer version ({github_version}) available on GitHub. Do you want to download it?")
662+
if download:
663+
webbrowser.open(f"https://github.com/{repo_owner}/{repo_name}/releases/latest")
664+
else:
665+
messagebox.showinfo("Version Check", "You chose not to download the new version.")
666+
667+
# Replace these with your GitHub repository owner and name
668+
630669
sdk = SourceSDK()
631670

632671
# Create the main window

0 commit comments

Comments
 (0)