From 61bae3efdc42fc1d748e4d60d24ff45e885ea212 Mon Sep 17 00:00:00 2001 From: bionel Date: Tue, 18 Aug 2020 16:32:47 +0300 Subject: pythonize check.root :P --- src/backend/check.py | 3 +-- src/backend/installbinary.py | 2 +- src/backend/installebuild.py | 2 +- src/backend/searchbinary.py | 2 +- src/backend/uninstall.py | 2 +- src/backend/uninstallforce.py | 2 +- src/backend/upgradebinary.py | 2 +- src/backend/upgradeebuild.py | 2 +- src/frontend/cli/sisyphus-cli.py | 2 +- 9 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/backend/check.py b/src/backend/check.py index fb760cc..b2d8206 100644 --- a/src/backend/check.py +++ b/src/backend/check.py @@ -5,8 +5,7 @@ import subprocess import sisyphus.filesystem def root(): - if os.getuid() == 0: - return 0 + return True if os.getuid() == 0 else False def portage(): if os.path.isdir(os.path.join(sisyphus.filesystem.portageRepoDir, '.git')): diff --git a/src/backend/installbinary.py b/src/backend/installbinary.py index 684bc79..d762ef9 100644 --- a/src/backend/installbinary.py +++ b/src/backend/installbinary.py @@ -14,7 +14,7 @@ import sisyphus.solvedeps import sisyphus.update def start(pkgname): - if sisyphus.check.root() == 0: + if sisyphus.check.root(): sisyphus.update.start() binhostURL = sisyphus.binhost.getURL() diff --git a/src/backend/installebuild.py b/src/backend/installebuild.py index 199b836..62e7fc2 100644 --- a/src/backend/installebuild.py +++ b/src/backend/installebuild.py @@ -14,7 +14,7 @@ import sisyphus.solvedeps import sisyphus.update def start(pkgname): - if sisyphus.check.root() == 0: + if sisyphus.check.root(): sisyphus.update.start() binhostURL = sisyphus.binhost.getURL() diff --git a/src/backend/searchbinary.py b/src/backend/searchbinary.py index d4ce032..d2c9eac 100644 --- a/src/backend/searchbinary.py +++ b/src/backend/searchbinary.py @@ -127,7 +127,7 @@ def showSearch(filter, cat, pn, desc, single): print("To search for source packages, use the '--ebuild' option.") def start(filter, cat, pn, desc, single): - if sisyphus.check.root() == 0: + if sisyphus.check.root(): sisyphus.update.start() else: print('\nYou are not root, cannot fetch updates.\nSearch result may be inaccurate!\n') diff --git a/src/backend/uninstall.py b/src/backend/uninstall.py index 2537b74..8da7e79 100644 --- a/src/backend/uninstall.py +++ b/src/backend/uninstall.py @@ -6,7 +6,7 @@ import sisyphus.database import sys def start(pkgname): - if sisyphus.check.root() == 0: + if sisyphus.check.root(): portageExec = subprocess.Popen(['emerge', '--quiet', '--depclean', '--ask'] + list(pkgname)) portageExec.wait() sisyphus.database.syncLocal() diff --git a/src/backend/uninstallforce.py b/src/backend/uninstallforce.py index f85dbe1..11139f4 100644 --- a/src/backend/uninstallforce.py +++ b/src/backend/uninstallforce.py @@ -6,7 +6,7 @@ import sisyphus.database import sys def start(pkgname): - if sisyphus.check.root() == 0: + if sisyphus.check.root(): portageExec = subprocess.Popen(['emerge', '--quiet', '--unmerge', '--ask'] + list(pkgname)) portageExec.wait() sisyphus.database.syncLocal() diff --git a/src/backend/upgradebinary.py b/src/backend/upgradebinary.py index 0f800cc..b3d68b6 100644 --- a/src/backend/upgradebinary.py +++ b/src/backend/upgradebinary.py @@ -14,7 +14,7 @@ import sisyphus.solvedeps import sisyphus.update def start(): - if sisyphus.check.root() == 0: + if sisyphus.check.root(): sisyphus.update.start() binhostURL = sisyphus.binhost.getURL() diff --git a/src/backend/upgradeebuild.py b/src/backend/upgradeebuild.py index 0e3a399..952bde7 100644 --- a/src/backend/upgradeebuild.py +++ b/src/backend/upgradeebuild.py @@ -14,7 +14,7 @@ import sisyphus.solvedeps import sisyphus.update def start(): - if sisyphus.check.root() == 0: + if sisyphus.check.root(): sisyphus.update.start() binhostURL = sisyphus.binhost.getURL() diff --git a/src/frontend/cli/sisyphus-cli.py b/src/frontend/cli/sisyphus-cli.py index 61a5d82..8937c93 100755 --- a/src/frontend/cli/sisyphus-cli.py +++ b/src/frontend/cli/sisyphus-cli.py @@ -177,7 +177,7 @@ def autoremove(): @app.command("update") def update(): """Update the Portage tree, the Redcore Overlay(s), Portage configs and Sisyphus's package database.""" - if sisyphus.check.root() == 0: + if sisyphus.check.root(): sisyphus.update.start() else: sys.exit("\nYou need root permissions to do this, exiting!\n") -- cgit v1.2.3