From e5d40ebec925b9e0f308fa55930f7fd03f02a693 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 31 Jan 2021 01:20:32 +0000 Subject: Revert "backend : reuse binhost module in csvfiles module, one less portage call" This reverts commit e4f2e722b2740d16ddc2ffa9b184287a7850b203. --- src/backend/check.py | 23 --------------------- src/backend/csvfiles.py | 20 ++++++++++-------- src/backend/update.py | 54 ++++++++++++++++++++++--------------------------- 3 files changed, 36 insertions(+), 61 deletions(-) (limited to 'src') diff --git a/src/backend/check.py b/src/backend/check.py index d5d3aca..b2d8206 100644 --- a/src/backend/check.py +++ b/src/backend/check.py @@ -2,34 +2,11 @@ import os import subprocess -import sisyphus.binhost import sisyphus.filesystem def root(): return True if os.getuid() == 0 else False - -def branch(): - binhostURL = sisyphus.binhost.getURL() - localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) - mismatch = int() - - if "packages-next" in binhostURL: - os.chdir(sisyphus.filesystem.portageRepoDir) - if localBranch.decode().strip() == "next": - print(binhostURL.replace('packages-next', 'csv-next') + 'remotePackagesPre.csv') - mismatch = int(0) - else: - mismatch = int(1) - else: - if localBranch.decode().strip() == "master": - mismatch = int(0) - else: - mismatch = int(1) - - return localBranch,mismatch -branch() - def portage(): if os.path.isdir(os.path.join(sisyphus.filesystem.portageRepoDir, '.git')): os.chdir(sisyphus.filesystem.portageRepoDir) diff --git a/src/backend/csvfiles.py b/src/backend/csvfiles.py index 0d2e895..0c91e81 100644 --- a/src/backend/csvfiles.py +++ b/src/backend/csvfiles.py @@ -1,17 +1,21 @@ #!/usr/bin/python3 -import sisyphus.binhost +import subprocess +import io def getURL(): remotePackagesCsvURL = [] remoteDescriptionsCsvURL = [] - binhostURL = sisyphus.binhost.getURL() + portageExec = subprocess.Popen(['emerge', '--info', '--verbose'], stdout=subprocess.PIPE) - if "packages-next" in binhostURL: - remotePackagesCsvURL = binhostURL.replace('packages-next', 'csv-next') + 'remotePackagesPre.csv' - remoteDescriptionsCsvURL = binhostURL.replace('packages-next', 'csv-next') + 'remoteDescriptionsPre.csv' - else: - remotePackagesCsvURL = binhostURL.replace('packages', 'csv') + 'remotePackagesPre.csv' - remoteDescriptionsCsvURL = binhostURL.replace('packages', 'csv') + 'remoteDescriptionsPre.csv' + for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"): + if "PORTAGE_BINHOST" in portageOutput.rstrip(): + if "packages-next" in portageOutput.rstrip(): + remotePackagesCsvURL = str(portageOutput.rstrip().split("=")[1].strip('\"').replace('packages-next', 'csv-next') + 'remotePackagesPre.csv') + remoteDescriptionsCsvURL = str(portageOutput.rstrip().split("=")[1].strip('\"').replace('packages-next', 'csv-next') + 'remoteDescriptionsPre.csv') + else: + remotePackagesCsvURL = str(portageOutput.rstrip().split("=")[1].strip('\"').replace('packages', 'csv') + 'remotePackagesPre.csv') + remoteDescriptionsCsvURL = str(portageOutput.rstrip().split("=")[1].strip('\"').replace('packages', 'csv') + 'remoteDescriptionsPre.csv') + portageExec.wait() return remotePackagesCsvURL,remoteDescriptionsCsvURL diff --git a/src/backend/update.py b/src/backend/update.py index b99da1c..902c398 100644 --- a/src/backend/update.py +++ b/src/backend/update.py @@ -1,7 +1,6 @@ #!/usr/bin/python3 import animation -import sys import sisyphus.cache import sisyphus.check import sisyphus.database @@ -12,33 +11,28 @@ import sisyphus.sync def start(): sisyphus.cache.clean() - mismatch = sisyphus.check.branch() + needsPortage = sisyphus.check.portage() + needsOverlay = sisyphus.check.overlay() - if mismatch == 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() - else: - sys.exit("\n" + "") + 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() -- cgit v1.2.3