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/branchsetup.py | 4 +-- src/backend/check.py | 12 +++---- src/backend/setjobs.py | 2 -- src/backend/update.py | 85 ++++++++++++++++++++++++++++++---------------- 4 files changed, 63 insertions(+), 40 deletions(-) (limited to 'src/backend') diff --git a/src/backend/branchsetup.py b/src/backend/branchsetup.py index 0a54dd8..8c2a63b 100644 --- a/src/backend/branchsetup.py +++ b/src/backend/branchsetup.py @@ -71,12 +71,12 @@ def injectRedcorePortageConfig(branch,remote): def warnAboutBinaryRepository(branch,remote): if "master" in branch: print("\nThe switch to branch" + " " + "'" + branch + "'" + " " + "from remote" + " " + "'" + remote + "'" + " " + "is now complete") - print("You must pair this branch with the stable binary package repository") + print("You must pair this branch with the stable binhost (binary repository)") print("Hint : Use the odd numbers (1,3,5,7) from 'sisyphus mirror list'") print("Examples : 'sisyphus mirror set 1' or 'sisyphus mirror set 5'\n") elif "next" in branch: print("\nThe switch to branch" + " " + "'" + branch + "'" + " " + "from remote" + " " + "'" + remote + "'" + " " + "is now complete") - print("You must pair this branch with the testing binary package repository") + print("You must pair this branch with the testing binhost (binary repository)") print("Hint : Use the even numbers (2,4,6,8) from 'sisyphus mirror list'") print("Examples : 'sisyphus mirror set 4' or 'sisyphus mirror set 8'\n") diff --git a/src/backend/check.py b/src/backend/check.py index 2c4cedb..d764a85 100644 --- a/src/backend/check.py +++ b/src/backend/check.py @@ -9,23 +9,23 @@ def root(): return True if os.getuid() == 0 else False def branch(): - branchRepoMissmatch = int() + branchBinhostMatch = int() binhostURL = sisyphus.binhost.getURL() localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) os.chdir(sisyphus.filesystem.portageRepoDir) if "packages-next" in binhostURL: if localBranch.decode().strip() == "next": - branchRepoMissmatch = int(0) + branchBinhostMatch = int(1) else: - branchRepoMissmatch = int(1) + branchBinhostMatch = int(0) else: if localBranch.decode().strip() == "master": - branchRepoMissmatch = int(0) + branchBinhostMatch = int(1) else: - branchRepoMissmatch = int(1) + branchBinhostMatch = int(0) - return branchRepoMissmatch,localBranch + return branchBinhostMatch,localBranch def portage(): if os.path.isdir(os.path.join(sisyphus.filesystem.portageRepoDir, '.git')): diff --git a/src/backend/setjobs.py b/src/backend/setjobs.py index 1047913..5a22b10 100644 --- a/src/backend/setjobs.py +++ b/src/backend/setjobs.py @@ -1,8 +1,6 @@ #!/usr/bin/python3 -import animation import subprocess -@animation.wait('adjusting MAKEOPTS') def start(): subprocess.call(['/usr/share/sisyphus/helpers/set_jobs']) 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