Skip to content

Commit

Permalink
- I MANAGED TO MAKE IT WOOOOOORK
Browse files Browse the repository at this point in the history
  • Loading branch information
LyamBRS committed May 1, 2023
1 parent 312aa0f commit 42afae4
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 24 deletions.
12 changes: 6 additions & 6 deletions Application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
#====================================================================#
Expand Down
16 changes: 9 additions & 7 deletions Programs/Local/Updating/GitUpdating.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
LoadingLog.Import("Python")
import os
import shutil
from git import rmtree
#endregion
#region --------------------------------------------------------- BRS
LoadingLog.Import("Libraries")
Expand Down Expand Up @@ -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}")
Expand Down
18 changes: 10 additions & 8 deletions Programs/Local/Updating/LaunchHandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
"""
Expand All @@ -72,7 +72,7 @@ def ShutdownFunction():
#====================================================================#
# Functions
#====================================================================#
def CreateLaunchNewAppPopUp(cancelHandler) -> Execution:
def CreateLaunchNewAppPopUp() -> Execution:
"""
CreateLaunchNewAppPopUp:
========================
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand All @@ -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.")
Expand All @@ -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")
2 changes: 1 addition & 1 deletion Programs/Pages/DownloadProgress.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def GoodDownload() -> Execution:
PopUps_Screens.SetCaller(DownloadProgress, "DownloadProgress")
PopUps_Screens.SetExiter(ProfileMenu_Screens, "ProfileMenu")

CreateTransferDataPopUp()
# CreateTransferDataPopUp()
CreateLaunchNewAppPopUp()

PopUps_Screens.Call()
Expand Down
16 changes: 14 additions & 2 deletions Test2.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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()

0 comments on commit 42afae4

Please sign in to comment.