diff --git a/ResetTracker/data/config.json b/ResetTracker/data/config.json index edd755a..bb44222 100644 --- a/ResetTracker/data/config.json +++ b/ResetTracker/data/config.json @@ -1 +1 @@ -{"lbName": "", "version": "2.0.3"} \ No newline at end of file +{"lbName": "", "version": "2.0.6"} \ No newline at end of file diff --git a/ResetTracker/scripts/graphs.py b/ResetTracker/graphs.py similarity index 99% rename from ResetTracker/scripts/graphs.py rename to ResetTracker/graphs.py index 010e3c5..6645716 100644 --- a/ResetTracker/scripts/graphs.py +++ b/ResetTracker/graphs.py @@ -6,7 +6,7 @@ from stats import * -with open('../data/palette.json', 'r') as f: +with open('data/palette.json', 'r') as f: guiColors = json.load(f) # class methods for creating graphs diff --git a/ResetTracker/scripts/gui.py b/ResetTracker/gui.py similarity index 99% rename from ResetTracker/scripts/gui.py rename to ResetTracker/gui.py index 391b46e..de23268 100644 --- a/ResetTracker/scripts/gui.py +++ b/ResetTracker/gui.py @@ -27,7 +27,6 @@ """ if True: - os.chdir("..") databaseLink = "https://docs.google.com/spreadsheets/d/1ky0mgYjsDE14xccw6JjmsKPrEIDHpt4TFnD2vr4Qmcc" headerLabels = ['Date and Time', 'Iron Source', 'Enter Type', 'Gold Source', 'Spawn Biome', 'RTA', 'Wood', 'Iron Pickaxe', 'Nether', 'Bastion', 'Fortress', 'Nether Exit', 'Stronghold', 'End', 'Retimed IGT', 'IGT', 'Gold Dropped', 'Blaze Rods', 'Blazes', 'Diamond Pick', 'Pearls Thrown', 'Deaths', 'Obsidian Placed', 'Diamond Sword', 'Blocks Mined', 'Iron', 'Wall Resets Since Prev', 'Played Since Prev', 'RTA Since Prev', 'Break RTA Since Prev', 'Wall Time Since Prev', 'Session Marker', 'RTA Distribution'] lastRun = None @@ -47,9 +46,9 @@ base_path = sys._MEIPASS else: base_path = os.path.abspath(".") - databasePath = os.path.join(base_path, 'assets/databaseCredentials.json') + databasePath = os.path.join(base_path, 'databaseCredentials.json') if not os.path.exists(databasePath): - print("DM pncakespoon#4895 on Discord to obtain the credentials file, then put it in the assets folder.") + print("DM pncakespoon#4895 on Discord to obtain the credentials file, then put it in the tracker folder.") sys.exit() gc_sheets_database = pygsheets.authorize(service_file=databasePath) sh2 = gc_sheets_database.open_by_url(databaseLink) @@ -887,7 +886,7 @@ def trackResets(cls): class IntroPage(Page): def populate(self): # Load the image using PIL - img = Image.open(os.path.join(base_path, "assets/cover.png")) + img = Image.open(os.path.join(base_path, "cover.png")) # Resize the image resized_img = img.resize((900, 600)) # Replace (200, 200) with your desired size diff --git a/ResetTracker/scripts/guiUtils.py b/ResetTracker/guiUtils.py similarity index 97% rename from ResetTracker/scripts/guiUtils.py rename to ResetTracker/guiUtils.py index eb5ba16..605ac54 100644 --- a/ResetTracker/scripts/guiUtils.py +++ b/ResetTracker/guiUtils.py @@ -1,9 +1,16 @@ import tkinter as tk from tkinter import * -from PIL import ImageTk, Image +from PIL import Image from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg import io +try: + from PIL import ImageTk +except: + if sys.platform.startswith("linux"): + print("The PIL.ImageTk library is not supported, try to install the python3-pil.imagetk package.") + else: + sys.exit() from graphs import * diff --git a/ResetTracker/scripts/speedrun_models.py b/ResetTracker/speedrun_models.py similarity index 100% rename from ResetTracker/scripts/speedrun_models.py rename to ResetTracker/speedrun_models.py diff --git a/ResetTracker/scripts/stats.py b/ResetTracker/stats.py similarity index 100% rename from ResetTracker/scripts/stats.py rename to ResetTracker/stats.py diff --git a/ResetTracker/scripts/update.py b/ResetTracker/update.py similarity index 91% rename from ResetTracker/scripts/update.py rename to ResetTracker/update.py index d39d9a0..90dfc9b 100644 --- a/ResetTracker/scripts/update.py +++ b/ResetTracker/update.py @@ -17,10 +17,11 @@ def unzip(path): def downloadSource(): response1 = requests.get("https://api.github.com/repos/pncakespoon1/ResetTracker/releases/latest") releaseTag = response1.json()["name"] - URL = "https://github.com/pncakespoon1/ResetTracker/archive/refs/tags/" + releaseTag + "/.zip" + URL = "https://github.com/pncakespoon1/ResetTracker/archive/refs/tags/" + releaseTag + ".zip" os.makedirs("temp/update/", exist_ok=True) response2 = wget.download(URL, "temp/update/ResetTracker2.zip") + def updateSource(): downloadSource() unzip('temp/update/ResetTracker2.zip') @@ -47,14 +48,20 @@ def updateSource(): newConfigFile.close() json.dump(newConfig, open('temp/update/ResetTracker2/data/config.json', 'w')) - shutil.move('assets/databaseCredentials.json', 'temp/update/ResetTracker2/assets/databaseCredentials.json') - shutil.rmtree('assets') shutil.rmtree('data') - shutil.rmtree('scripts') - shutil.move('temp/update/ResetTracker2/assets', '.') + files = os.listdir(".") + for file in files: + if file != "databaseCredentials.json": + os.remove(file) + shutil.move('temp/update/ResetTracker2/data', '.') - shutil.move('temp/update/ResetTracker2/scripts', '.') + + files = os.listdir("temp/update/ResetTracker2") + for file in files: + if "." in file: + shutil.move('temp/update/ResetTracker2/' + file, '.') + os.remove('temp/update/ResetTracker2.zip') shutil.rmtree('temp/update/ResetTracker2') @@ -65,6 +72,7 @@ def downloadExe(): URL = "https://github.com/pncakespoon1/ResetTracker/releases/download/" + releaseTag + "/ResetTracker2.zip" response2 = wget.download(URL, "temp/update/ResetTracker2.zip") + def updateExe(): downloadExe() unzip('temp/update/ResetTracker2.zip') @@ -92,7 +100,7 @@ def updateExe(): json.dump(newConfig, open('temp/update/ResetTracker2/data/config.json', 'w')) shutil.rmtree('data') - os.remove('ResetTracker2.exe') + os.remove('gui.exe') relativeDir = os.path.abspath('temp') relativeDir = relativeDir[:len(relativeDir) - 5] @@ -103,13 +111,13 @@ def updateExe(): def update(): - os.chdir("..") if getattr(sys, 'frozen', False): # if running in a PyInstaller bundle updateExe() else: updateSource() root.destroy() + if __name__ == "__main__": time.sleep(3) root = tk.Tk() diff --git a/ResetTracker/scripts/utils.py b/ResetTracker/utils.py similarity index 100% rename from ResetTracker/scripts/utils.py rename to ResetTracker/utils.py