From f59f14aee1d1a82b60e4274e4680b54280c225c5 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 31 Jan 2021 01:26:21 +0000 Subject: backend : reuse binhost module in csvfiles module, one less portage call --- src/backend/csvfiles.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/backend/csvfiles.py b/src/backend/csvfiles.py index 0c91e81..0d2e895 100644 --- a/src/backend/csvfiles.py +++ b/src/backend/csvfiles.py @@ -1,21 +1,17 @@ #!/usr/bin/python3 -import subprocess -import io +import sisyphus.binhost def getURL(): remotePackagesCsvURL = [] remoteDescriptionsCsvURL = [] - portageExec = subprocess.Popen(['emerge', '--info', '--verbose'], stdout=subprocess.PIPE) + binhostURL = sisyphus.binhost.getURL() - 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') + 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' - portageExec.wait() return remotePackagesCsvURL,remoteDescriptionsCsvURL -- cgit v1.2.3