From 42afae473d8ddb42434cce85e031c8f1228e44d0 Mon Sep 17 00:00:00 2001 From: "Lyam[BRS]" Date: Sun, 30 Apr 2023 21:20:31 -0400 Subject: [PATCH] - I MANAGED TO MAKE IT WOOOOOORK --- Application.py | 12 ++++++------ Programs/Local/Updating/GitUpdating.py | 16 +++++++++------- Programs/Local/Updating/LaunchHandling.py | 18 ++++++++++-------- Programs/Pages/DownloadProgress.py | 2 +- Test2.py | 16 ++++++++++++++-- 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/Application.py b/Application.py index 36d4fae..c8dab7d 100644 --- a/Application.py +++ b/Application.py @@ -4,21 +4,20 @@ import os import sys from Libraries.BRS_Python_Libraries.BRS.Debug.LoadingLog import LoadingLog -from Libraries.BRS_Python_Libraries.BRS.Network.APIs.GitHub import GitHub -from Programs.Local.Updating.GitUpdating import DownloadLatestVersion -from Programs.Local.Updating.LaunchHandling import Shutdown +# from Libraries.BRS_Python_Libraries.BRS.Network.APIs.GitHub import GitHub +# from Programs.Local.Updating.GitUpdating import DownloadLatestVersion LoadingLog.Start("Application.py") #===================================================================# # Imports #===================================================================# LoadingLog.Import("Kivy") from kivy.core.window import Window -from kivy.uix.screenmanager import ScreenManager, Screen, WipeTransition, CardTransition +from kivy.uix.screenmanager import ScreenManager # ------------------------------------------------------------------- LoadingLog.Import("KivyMD") from kivymd.app import MDApp -from kivymd.uix.button import MDRaisedButton -from kivymd.theming import ThemeManager +# from kivymd.uix.button import MDRaisedButton +# from kivymd.theming import ThemeManager # ------------------------------------------------------------------- LoadingLog.Import("Libraries") from Libraries.BRS_Python_Libraries.BRS.GUI.Utilities.font import Font @@ -34,6 +33,7 @@ from Programs.Pages.Startup import Startup_Screens from Programs.Pages.AppLoading import AppLoading,AppLoading_Screens from Programs.Pages.PopUps import PopUps,PopUps_Screens,PopUpsHandler,Keys,PopUpTypeEnum +from Programs.Local.Updating.LaunchHandling import Shutdown #====================================================================# # Configuration #====================================================================# diff --git a/Programs/Local/Updating/GitUpdating.py b/Programs/Local/Updating/GitUpdating.py index eb20f26..056aa31 100644 --- a/Programs/Local/Updating/GitUpdating.py +++ b/Programs/Local/Updating/GitUpdating.py @@ -20,6 +20,7 @@ LoadingLog.Import("Python") import os import shutil +from git import rmtree #endregion #region --------------------------------------------------------- BRS LoadingLog.Import("Libraries") @@ -323,13 +324,14 @@ def _DeleteOtherKontrolVersions(*args) -> Execution: versionPath = GetParentPath(os.getcwd()) + version Debug.Log(f">>> Deleting: {version} ...") - try: - shutil.rmtree(versionPath) - Debug.Log(">>> DELETED") - except: - Debug.Error(f"Failed to delete: {version}") - PopUpsHandler.Add(Type=PopUpTypeEnum.FatalError, - Message=_("Kontrol failed to delete the following version: ")+version) + # try: + Debug.Log(f"Trying to remove: {versionPath}") + rmtree(versionPath) + Debug.Log(">>> DELETED") + # except: + # Debug.Error(f"Failed to delete: {version}") + # PopUpsHandler.Add(Type=PopUpTypeEnum.FatalError, + # Message=_("Kontrol failed to delete the following version: ")+version) else: Debug.Error("Running version not found in list of installed versions.") Debug.Error(f"List of versions: {installedVersions}") diff --git a/Programs/Local/Updating/LaunchHandling.py b/Programs/Local/Updating/LaunchHandling.py index e2a5084..dd69d74 100644 --- a/Programs/Local/Updating/LaunchHandling.py +++ b/Programs/Local/Updating/LaunchHandling.py @@ -12,8 +12,7 @@ #====================================================================# import subprocess from Libraries.BRS_Python_Libraries.BRS.Debug.LoadingLog import LoadingLog -from Programs.Local.Updating.GitUpdating import GetInstalledKontrolVersions -from Programs.Pages.DownloadProgress import DownloadProgress_Screens +# from Programs.Pages.DownloadProgress import DownloadProgress_Screens LoadingLog.Start("LaunchHandling.py") #====================================================================# # Imports @@ -62,6 +61,7 @@ def ShutdownFunction(): This function's purpose is to execute when the app closes. By default it is empty. """ + pass newAppPath:str = None """ @@ -72,7 +72,7 @@ def ShutdownFunction(): #====================================================================# # Functions #====================================================================# -def CreateLaunchNewAppPopUp(cancelHandler) -> Execution: +def CreateLaunchNewAppPopUp() -> Execution: """ CreateLaunchNewAppPopUp: ======================== @@ -157,9 +157,9 @@ def QuitAndLaunchNewApp(*args) -> Execution: - This function does not clear pop ups - This function does NOT handle PopUps_Screens - This should be the last function you call. - """ - Debug.Start() - + # """ + Debug.Start("QuitAndLaunchNewApp") + from Programs.Local.Updating.GitUpdating import GetInstalledKontrolVersions Debug.Log("Checking if multiple versions installed") installedVersions = GetInstalledKontrolVersions() if(installedVersions == Execution.Unecessary): @@ -199,6 +199,8 @@ def QuitAndLaunchNewApp(*args) -> Execution: Debug.End() return Execution.Failed + Debug.Log(f"path found: {newPath}") + Shutdown.newAppPath = newPath Debug.Log("Checking if Application.py is available") files = os.listdir(newPath) if "Application.py" in files: @@ -211,7 +213,7 @@ def QuitAndLaunchNewApp(*args) -> Execution: return Execution.Failed Debug.Log("Configurating Shutdown class.") - Shutdown.newAppPath = newPath + # Shutdown.newAppPath = newPath Shutdown.ShutdownFunction = _AppShutDownFunction Debug.Log("Shutting down KivyMD application.") @@ -226,7 +228,7 @@ def _AppShutDownFunction(*args) -> Execution: Debug.Error("FAILED TO LAUNCH NEW APP DUE TO NO PATH BEING SPECIFIED") else: os.chdir(Shutdown.newAppPath) - result = subprocess.run(['python', os.path.basename(Shutdown.newAppPath)]) + result = subprocess.run(['python', "Application.py"]) Debug.End() LoadingLog.End("LaunchHandling.py") \ No newline at end of file diff --git a/Programs/Pages/DownloadProgress.py b/Programs/Pages/DownloadProgress.py index 48afe9c..5902a91 100644 --- a/Programs/Pages/DownloadProgress.py +++ b/Programs/Pages/DownloadProgress.py @@ -80,7 +80,7 @@ def GoodDownload() -> Execution: PopUps_Screens.SetCaller(DownloadProgress, "DownloadProgress") PopUps_Screens.SetExiter(ProfileMenu_Screens, "ProfileMenu") - CreateTransferDataPopUp() + # CreateTransferDataPopUp() CreateLaunchNewAppPopUp() PopUps_Screens.Call() diff --git a/Test2.py b/Test2.py index a6346a6..7921914 100644 --- a/Test2.py +++ b/Test2.py @@ -1,6 +1,8 @@ import os from Libraries.BRS_Python_Libraries.BRS.Debug.consoleLog import Debug -from Programs.Local.Updating.GitUpdating import DeleteOtherKontrolVersions +from Programs.Local.Updating.GitUpdating import DownloadLatestVersion, _DeleteOtherKontrolVersions +from Libraries.BRS_Python_Libraries.BRS.Network.APIs.GitHub import GitHub +from kivymd.uix.progressbar import MDProgressBar def get_last_directory(path): """ Returns the last directory of a given path. @@ -15,4 +17,14 @@ def get_last_directory(path): print(f"current folder: {folder}") Debug.enableConsole = True -DeleteOtherKontrolVersions() + +class FUCK(): + def GoodDownload(): + return + def FailedDownload(): + return + +GitHub.CurrentTag = "0.0.0" +GitHub.LatestTag = "0.0.2" +# DownloadLatestVersion(MDProgressBar, FUCK) +_DeleteOtherKontrolVersions()