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 ++++++++++++++++++++++++++-------------- src/frontend/cli/README.md | 10 ++--- src/frontend/cli/sisyphus-cli.py | 10 ++--- src/frontend/gui/sisyphus-gui.py | 4 +- 7 files changed, 75 insertions(+), 52 deletions(-) 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() diff --git a/src/frontend/cli/README.md b/src/frontend/cli/README.md index 5636e2e..567db9d 100644 --- a/src/frontend/cli/README.md +++ b/src/frontend/cli/README.md @@ -23,7 +23,7 @@ $ sisyphus [OPTIONS] COMMAND [ARGS]... * `autoremove`: Uninstall packages that are no longer needed. * `branch`: Pull the selected branch of the Portage tree,... * `install`: Install binary and/or ebuild(source)... -* `mirror`: List/Set the active binary repository mirror. +* `mirror`: List/Set the active binhost (binary repository) mirror. * `rescue`: Resurrect Sisyphus's package database if lost... * `search`: Search for binary and/or ebuild (source)... * `spmsync`: Sync Sisyphus's package database with... @@ -70,9 +70,9 @@ The remote can be selected by using the --remote option. !!! WARNING !!! -Once you changed the branch, you must pair it with the correct binary repository. +Once you changed the branch, you must pair it with the correct binhost (binary repository). -Branch 'master' must be paired with the stable binary repository (odd numbers in 'sisyphus mirror list'). +Branch 'master' must be paired with the stable binhost (binary repository) (odd numbers in 'sisyphus mirror list'). * Examples: @@ -82,7 +82,7 @@ Branch 'master' must be paired with the stable binary repository (odd numbers in ` sisyphus mirror set 5 ` -Branch 'next' must be paired with the testing binary repository (even numbers in 'sisyphus mirror list'). +Branch 'next' must be paired with the testing binhost (binary repository) (even numbers in 'sisyphus mirror list'). * Examples: @@ -136,7 +136,7 @@ $ sisyphus install [OPTIONS] PKGNAME... ## `sisyphus mirror` -List/Set the active binary repository mirror. +List/Set the active binhost (binary repository) mirror. **Usage**: diff --git a/src/frontend/cli/sisyphus-cli.py b/src/frontend/cli/sisyphus-cli.py index 5c87698..eb385d1 100755 --- a/src/frontend/cli/sisyphus-cli.py +++ b/src/frontend/cli/sisyphus-cli.py @@ -8,7 +8,7 @@ import sys app = typer.Typer() mirrorSetup = typer.Typer() -app.add_typer(mirrorSetup, name="mirror", help='List/Set the active binary repository mirror.') +app.add_typer(mirrorSetup, name="mirror", help='List/Set the active binhost (binary repository) mirror.') @app.callback() def app_callback(ctx: typer.Context): @@ -249,9 +249,9 @@ def branch(branch: Branch = typer.Argument(...), remote: Remote = typer.Option(R !!! WARNING !!! - Once you changed the branch, you must pair it with the correct binary repository. + Once you changed the branch, you must pair it with the correct binhost (binary repository). - Branch 'master' must be paired with the stable binary repository (odd numbers in 'sisyphus mirror list'). + Branch 'master' must be paired with the stable binhost (binary repository) (odd numbers in 'sisyphus mirror list'). * Examples: @@ -259,7 +259,7 @@ def branch(branch: Branch = typer.Argument(...), remote: Remote = typer.Option(R sisyphus mirror set 5 - Branch 'next' must be paired with the testing binary repository (even numbers in 'sisyphus mirror list'). + Branch 'next' must be paired with the testing binhost (binary repository) (even numbers in 'sisyphus mirror list'). * Examples: @@ -287,5 +287,5 @@ def mirrorset(index: int): if __name__ == "__main__": if len(sys.argv) > 1 and not '--help' in sys.argv: sisyphus.check.update() - sisyphus.setjobs.start.__wrapped__() # undecorate + sisyphus.setjobs.start() app() diff --git a/src/frontend/gui/sisyphus-gui.py b/src/frontend/gui/sisyphus-gui.py index 8930f6c..67d3f1f 100644 --- a/src/frontend/gui/sisyphus-gui.py +++ b/src/frontend/gui/sisyphus-gui.py @@ -384,8 +384,8 @@ class MainWorker(QtCore.QObject): def startUpdate(self): self.started.emit() sisyphus.check.update() - sisyphus.setjobs.start.__wrapped__() # undecorate - sisyphus.update.start.__wrapped__() # undecorate + sisyphus.setjobs.start() + sisyphus.update.startqt() self.finished.emit() @QtCore.pyqtSlot() -- cgit v1.2.3