From ed3747e4ff721914d1df6b62788a91a1e8b3f741 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Tue, 2 Feb 2021 01:07:55 +0000 Subject: * better explain some used terms * update the help menu and CLI documentation * remove animations from setjobs module (it takes less than a second, so it's pointless) * make some error messages less cryptic && offer help to understand them * don't kill the graphical interface right away if there is a missmatch, display the error, offer help && and then die in 10 seconds --- src/backend/update.py | 85 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 30 deletions(-) (limited to 'src/backend/update.py') diff --git a/src/backend/update.py b/src/backend/update.py index 655b705..63624f5 100644 --- a/src/backend/update.py +++ b/src/backend/update.py @@ -2,6 +2,7 @@ import animation import sys +import time import sisyphus.cache import sisyphus.binhost import sisyphus.check @@ -9,38 +10,62 @@ import sisyphus.database import sisyphus.metadata import sisyphus.sync +def dosync(): + sisyphus.sync.portage() + sisyphus.sync.overlay() + sisyphus.sync.portageCfg() + sisyphus.database.syncRemote() + sisyphus.metadata.regenSilent() + +def checksync(): + sisyphus.cache.clean() + + needsPortage = sisyphus.check.portage() + needsOverlay = sisyphus.check.overlay() + + if needsPortage == 1: + if needsOverlay == 1: + dosync() + elif not needsOverlay == 1: + dosync() + elif not needsPortage == 1: + if needsOverlay == 1: + dosync() + elif not needsOverlay == 1: + sisyphus.sync.portageCfg() + @animation.wait('fetching updates') def start(): - sisyphus.cache.clean() + binhostURL = sisyphus.binhost.getURL() + branchBinhostMatch,localBranch = sisyphus.check.branch() + + if branchBinhostMatch == 1: + checksync() + else: + if "packages-next" in binhostURL: + print("\nCurrent branch: '" + localBranch.decode().strip() + "' (stable)" + "\nCurrent binhost: '" + binhostURL + "' (testing)") + else: + print("\nCurrent branch: '" + localBranch.decode().strip() + "' (testing)" + "\nCurrent binhost: '" + binhostURL + "' (stable)") + sys.exit("\nInvalid branch - binhost pairing; Use 'sisyphus branch --help' for help; Quitting.") +def startqt(): binhostURL = sisyphus.binhost.getURL() - branchRepoMissmatch,localBranch = sisyphus.check.branch() - - if branchRepoMissmatch == 0: - needsPortage = sisyphus.check.portage() - needsOverlay = sisyphus.check.overlay() - - if needsPortage == 1: - if needsOverlay == 1: - sisyphus.sync.portage() - sisyphus.sync.overlay() - sisyphus.sync.portageCfg() - sisyphus.database.syncRemote() - sisyphus.metadata.regenSilent() - elif not needsOverlay == 1: - sisyphus.sync.portage() - sisyphus.sync.overlay() - sisyphus.sync.portageCfg() - sisyphus.database.syncRemote() - sisyphus.metadata.regenSilent() - elif not needsPortage == 1: - if needsOverlay == 1: - sisyphus.sync.portage() - sisyphus.sync.overlay() - sisyphus.sync.portageCfg() - sisyphus.database.syncRemote() - sisyphus.metadata.regenSilent() - elif not needsOverlay == 1: - sisyphus.sync.portageCfg() + branchBinhostMatch,localBranch = sisyphus.check.branch() + + if branchBinhostMatch == 1: + checksync() else: - sys.exit("\n" + "Branch :" + " '" + localBranch.decode().strip() + "' " + "\n" + "Repository :" + " '" + binhostURL + "' " + "\n" + "Branch - Repository missmatch; Quitting.") + if "packages-next" in binhostURL: + print("\nCurrent branch: '" + localBranch.decode().strip() + "' (stable)" + "\nCurrent binhost: '" + binhostURL + "' (testing)") + else: + print("\nCurrent branch: '" + localBranch.decode().strip() + "' (testing)" + "\nCurrent binhost: '" + binhostURL + "' (stable)") + print("\nInvalid branch - binhost pairing; Use 'sisyphus branch --help' for help; Quitting in 10 seconds.\n") + t = int(10) + while t: + mins, secs = divmod(t, 60) + timer = '{:02d}:{:02d}'.format(mins, secs) + print(timer, end="\r") + time.sleep(1) + t -= 1 + + sys.exit() -- cgit v1.2.3