From 02b654dc089c570ce81ce5da0c2c48d5d21d3cb8 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 30 Oct 2022 14:26:52 +0000 Subject: move getEnvironment -> getenv --- src/backend/__init__.py | 2 +- src/backend/checkEnvironment.py | 42 ----------------------------------------- src/backend/checkenv.py | 42 +++++++++++++++++++++++++++++++++++++++++ src/backend/getEnvironment.py | 29 ---------------------------- src/backend/getenv.py | 29 ++++++++++++++++++++++++++++ src/backend/installPkg.py | 6 +++--- src/backend/installSrc.py | 4 ++-- src/backend/syncDatabase.py | 4 ++-- src/backend/updateAll.py | 6 +++--- src/backend/upgradePkg.py | 6 +++--- src/backend/upgradeSrc.py | 4 ++-- 11 files changed, 87 insertions(+), 87 deletions(-) delete mode 100644 src/backend/checkEnvironment.py create mode 100644 src/backend/checkenv.py delete mode 100644 src/backend/getEnvironment.py create mode 100644 src/backend/getenv.py (limited to 'src') diff --git a/src/backend/__init__.py b/src/backend/__init__.py index 20b12a0..02c5bf2 100644 --- a/src/backend/__init__.py +++ b/src/backend/__init__.py @@ -1,6 +1,6 @@ from .autoremove import * from .checkenv import * -from .getEnvironment import * +from .getenv import * from .getFilesystem import * from .installPkg import * from .installSrc import * diff --git a/src/backend/checkEnvironment.py b/src/backend/checkEnvironment.py deleted file mode 100644 index 9613fe6..0000000 --- a/src/backend/checkEnvironment.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/python3 - -import os -import subprocess -import sisyphus.getEnvironment -import sisyphus.getFilesystem - -def root(): - return True if os.getuid() == 0 else False - -def branch(): - activeBranch = None - - if os.path.isdir(os.path.join(sisyphus.getFilesystem.gentooRepoDir, '.git')): - os.chdir(sisyphus.getFilesystem.gentooRepoDir) - localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) - - if localBranch.decode().strip() == 'master': - activeBranch = str('master') - - if localBranch.decode().strip() == 'next': - activeBranch = str('next') - - return activeBranch - -def sanity(): - activeBranch = branch() - binhostURL = sisyphus.getEnvironment.binhostURL() - isSane = int() - - if "packages-next" in binhostURL: - if activeBranch == "next": - isSane = int(1) - else: - isSane = int(0) - else: - if activeBranch == "master": - isSane = int(1) - else: - isSane = int(0) - - return isSane diff --git a/src/backend/checkenv.py b/src/backend/checkenv.py new file mode 100644 index 0000000..feaab4b --- /dev/null +++ b/src/backend/checkenv.py @@ -0,0 +1,42 @@ +#!/usr/bin/python3 + +import os +import subprocess +import sisyphus.getenv +import sisyphus.getFilesystem + +def root(): + return True if os.getuid() == 0 else False + +def branch(): + activeBranch = None + + if os.path.isdir(os.path.join(sisyphus.getFilesystem.gentooRepoDir, '.git')): + os.chdir(sisyphus.getFilesystem.gentooRepoDir) + localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) + + if localBranch.decode().strip() == 'master': + activeBranch = str('master') + + if localBranch.decode().strip() == 'next': + activeBranch = str('next') + + return activeBranch + +def sanity(): + activeBranch = branch() + binhostURL = sisyphus.getenv.binhostURL() + isSane = int() + + if "packages-next" in binhostURL: + if activeBranch == "next": + isSane = int(1) + else: + isSane = int(0) + else: + if activeBranch == "master": + isSane = int(1) + else: + isSane = int(0) + + return isSane diff --git a/src/backend/getEnvironment.py b/src/backend/getEnvironment.py deleted file mode 100644 index 5edd038..0000000 --- a/src/backend/getEnvironment.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/python3 - -import io -import subprocess - -def binhostURL(): - binhostURL = [] - portageExec = subprocess.Popen(['emerge', '--info', '--verbose'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - - for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"): - if "PORTAGE_BINHOST" in portageOutput: - binhostURL = portageOutput.rstrip().split("=")[1].strip('\"') - - portageExec.wait() - return binhostURL - -def csvURL(): - csvURL = binhostURL() - packagesCsvURL = [] - descriptionsCsvURL = [] - - if "packages-next" in csvURL: - packagesCsvURL = csvURL.replace('packages-next', 'csv-next') + 'remotePackagesPre.csv' - descriptionsCsvURL = csvURL.replace('packages-next', 'csv-next') + 'remoteDescriptionsPre.csv' - else: - packagesCsvURL = csvURL.replace('packages', 'csv') + 'remotePackagesPre.csv' - descriptionsCsvURL = csvURL.replace('packages', 'csv') + 'remoteDescriptionsPre.csv' - - return packagesCsvURL,descriptionsCsvURL diff --git a/src/backend/getenv.py b/src/backend/getenv.py new file mode 100644 index 0000000..5edd038 --- /dev/null +++ b/src/backend/getenv.py @@ -0,0 +1,29 @@ +#!/usr/bin/python3 + +import io +import subprocess + +def binhostURL(): + binhostURL = [] + portageExec = subprocess.Popen(['emerge', '--info', '--verbose'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"): + if "PORTAGE_BINHOST" in portageOutput: + binhostURL = portageOutput.rstrip().split("=")[1].strip('\"') + + portageExec.wait() + return binhostURL + +def csvURL(): + csvURL = binhostURL() + packagesCsvURL = [] + descriptionsCsvURL = [] + + if "packages-next" in csvURL: + packagesCsvURL = csvURL.replace('packages-next', 'csv-next') + 'remotePackagesPre.csv' + descriptionsCsvURL = csvURL.replace('packages-next', 'csv-next') + 'remoteDescriptionsPre.csv' + else: + packagesCsvURL = csvURL.replace('packages', 'csv') + 'remotePackagesPre.csv' + descriptionsCsvURL = csvURL.replace('packages', 'csv') + 'remoteDescriptionsPre.csv' + + return packagesCsvURL,descriptionsCsvURL diff --git a/src/backend/installPkg.py b/src/backend/installPkg.py index 55e9bb7..7c1f100 100644 --- a/src/backend/installPkg.py +++ b/src/backend/installPkg.py @@ -8,7 +8,7 @@ import subprocess import sys import wget import sisyphus.checkenv -import sisyphus.getEnvironment +import sisyphus.getenv import sisyphus.getFilesystem import sisyphus.killPortage import sisyphus.resolveDeps @@ -19,7 +19,7 @@ def cliExec(pkgname): if sisyphus.checkenv.root(): sisyphus.updateAll.cliExec() - binhostURL = sisyphus.getEnvironment.binhostURL() + binhostURL = sisyphus.getenv.binhostURL() areBinaries,areSources,needsConfig = sisyphus.resolveDeps.package(pkgname) if needsConfig == 0: @@ -59,7 +59,7 @@ def cliExec(pkgname): sys.exit("\nYou need root permissions to do this, exiting!\n") def guiExec(pkgname): - binhostURL = sisyphus.getEnvironment.binhostURL() + binhostURL = sisyphus.getenv.binhostURL() areBinaries,areSources,needsConfig = sisyphus.resolveDeps.package.__wrapped__(pkgname) #undecorate os.chdir(sisyphus.getFilesystem.portageCacheDir) diff --git a/src/backend/installSrc.py b/src/backend/installSrc.py index 8929041..d37399e 100644 --- a/src/backend/installSrc.py +++ b/src/backend/installSrc.py @@ -7,7 +7,7 @@ import subprocess import sys import wget import sisyphus.checkenv -import sisyphus.getEnvironment +import sisyphus.getenv import sisyphus.getFilesystem import sisyphus.resolveDeps import sisyphus.syncDatabase @@ -17,7 +17,7 @@ def cliExec(pkgname): if sisyphus.checkenv.root(): sisyphus.updateAll.cliExec() - binhostURL = sisyphus.getEnvironment.binhostURL() + binhostURL = sisyphus.getenv.binhostURL() areBinaries,areSources,needsConfig = sisyphus.resolveDeps.package(pkgname) if needsConfig == 0: diff --git a/src/backend/syncDatabase.py b/src/backend/syncDatabase.py index 1823847..760e3b6 100644 --- a/src/backend/syncDatabase.py +++ b/src/backend/syncDatabase.py @@ -5,11 +5,11 @@ import shutil import urllib3 import sqlite3 import subprocess -import sisyphus.getEnvironment +import sisyphus.getenv import sisyphus.getFilesystem def remoteCSV(): - packagesCsvURL,descriptionsCsvURL = sisyphus.getEnvironment.csvURL() + packagesCsvURL,descriptionsCsvURL = sisyphus.getenv.csvURL() http = urllib3.PoolManager() with http.request('GET', packagesCsvURL, preload_content=False) as tmp_buffer, open(sisyphus.getFilesystem.remotePackagesCsv, 'wb') as output_file: diff --git a/src/backend/updateAll.py b/src/backend/updateAll.py index ed6a6cc..bf95266 100644 --- a/src/backend/updateAll.py +++ b/src/backend/updateAll.py @@ -4,7 +4,7 @@ import animation import sys import time import sisyphus.checkenv -import sisyphus.getEnvironment +import sisyphus.getenv import sisyphus.purgeEnvironment import sisyphus.syncDatabase import sisyphus.syncEnvironment @@ -19,7 +19,7 @@ def syncAll(): @animation.wait('fetching updates') def cliExec(): activeBranch = sisyphus.checkenv.branch() - binhostURL = sisyphus.getEnvironment.binhostURL() + binhostURL = sisyphus.getenv.binhostURL() isSane = sisyphus.checkenv.sanity() if isSane == 1: @@ -33,7 +33,7 @@ def cliExec(): def guiExec(): activeBranch = sisyphus.checkenv.branch() - binhostURL = sisyphus.getEnvironment.binhostURL() + binhostURL = sisyphus.getenv.binhostURL() isSane = sisyphus.checkenv.sanity() if isSane == 1: diff --git a/src/backend/upgradePkg.py b/src/backend/upgradePkg.py index ec46cda..5110499 100644 --- a/src/backend/upgradePkg.py +++ b/src/backend/upgradePkg.py @@ -8,7 +8,7 @@ import subprocess import sys import wget import sisyphus.checkenv -import sisyphus.getEnvironment +import sisyphus.getenv import sisyphus.getFilesystem import sisyphus.killPortage import sisyphus.resolveDeps @@ -19,7 +19,7 @@ def cliExec(): if sisyphus.checkenv.root(): sisyphus.updateAll.cliExec() - binhostURL = sisyphus.getEnvironment.binhostURL() + binhostURL = sisyphus.getenv.binhostURL() areBinaries,areSources,needsConfig = sisyphus.resolveDeps.world() if needsConfig == 0: @@ -59,7 +59,7 @@ def cliExec(): sys.exit("\nYou need root permissions to do this, exiting!\n") def guiExec(): - binhostURL = sisyphus.getEnvironment.binhostURL() + binhostURL = sisyphus.getenv.binhostURL() areBinaries,areSources,needsConfig = sisyphus.resolveDeps.world.__wrapped__() #undecorate if not len(areSources) == 0: diff --git a/src/backend/upgradeSrc.py b/src/backend/upgradeSrc.py index 3335724..7251e64 100644 --- a/src/backend/upgradeSrc.py +++ b/src/backend/upgradeSrc.py @@ -7,7 +7,7 @@ import subprocess import sys import wget import sisyphus.checkenv -import sisyphus.getEnvironment +import sisyphus.getenv import sisyphus.getFilesystem import sisyphus.resolveDeps import sisyphus.syncDatabase @@ -17,7 +17,7 @@ def cliExec(): if sisyphus.checkenv.root(): sisyphus.updateAll.cliExec() - binhostURL = sisyphus.getEnvironment.binhostURL() + binhostURL = sisyphus.getenv.binhostURL() areBinaries,areSources,needsConfig = sisyphus.resolveDeps.world() if needsConfig == 0: -- cgit v1.2.3