From aaf45e0a3c06c7affeae2b412bb8db99e9ce3d86 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 30 Oct 2022 15:14:09 +0000 Subject: move syncDatabase -> syncdb --- src/backend/__init__.py | 4 ++-- src/backend/autoremove.py | 6 ++--- src/backend/installpkg.py | 6 ++--- src/backend/installsrc.py | 8 +++---- src/backend/recoverdb.py | 6 ++--- src/backend/setProfile.py | 18 -------------- src/backend/setbranch.py | 4 ++-- src/backend/setprofile.py | 18 ++++++++++++++ src/backend/syncDatabase.py | 57 --------------------------------------------- src/backend/syncSPM.py | 4 ++-- src/backend/syncdb.py | 57 +++++++++++++++++++++++++++++++++++++++++++++ src/backend/uninstallAll.py | 8 +++---- src/backend/updateAll.py | 4 ++-- src/backend/upgradePkg.py | 6 ++--- src/backend/upgradeSrc.py | 8 +++---- 15 files changed, 107 insertions(+), 107 deletions(-) delete mode 100644 src/backend/setProfile.py create mode 100644 src/backend/setprofile.py delete mode 100644 src/backend/syncDatabase.py create mode 100644 src/backend/syncdb.py (limited to 'src/backend') diff --git a/src/backend/__init__.py b/src/backend/__init__.py index ebcee2f..6a36d58 100644 --- a/src/backend/__init__.py +++ b/src/backend/__init__.py @@ -13,8 +13,8 @@ from .searchsrc import * from .setbranch import * from .setjobs import * from .setMirror import * -from .setProfile import * -from .syncDatabase import * +from .setprofile import * +from .syncdb import * from .syncEnvironment import * from .syncSPM import * from .sysInfo import * diff --git a/src/backend/autoremove.py b/src/backend/autoremove.py index 139c850..3dc717d 100644 --- a/src/backend/autoremove.py +++ b/src/backend/autoremove.py @@ -6,13 +6,13 @@ import subprocess import sys import sisyphus.checkenv import sisyphus.killemerge -import sisyphus.syncDatabase +import sisyphus.syncdb def start(): if sisyphus.checkenv.root(): portageExec = subprocess.Popen(['emerge', '--quiet', '--depclean', '--ask']) portageExec.wait() - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.localTable() else: sys.exit("\nYou need root permissions to do this, exiting!\n") @@ -25,4 +25,4 @@ def startx(): print(portageOutput.rstrip()) portageExec.wait() - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.localTable() diff --git a/src/backend/installpkg.py b/src/backend/installpkg.py index 1e2f51e..1a27051 100644 --- a/src/backend/installpkg.py +++ b/src/backend/installpkg.py @@ -12,7 +12,7 @@ import sisyphus.getenv import sisyphus.getfs import sisyphus.killemerge import sisyphus.solvedeps -import sisyphus.syncDatabase +import sisyphus.syncdb import sisyphus.updateAll def cliExec(pkgname): @@ -45,7 +45,7 @@ def cliExec(pkgname): portageExec = subprocess.Popen(['emerge', '--quiet', '--verbose', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), stdout=subprocess.PIPE, stderr=subprocess.PIPE) portageExec.wait() - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.localTable() else: sys.exit("\n" + "Ok; Quitting." + "\n") else: @@ -86,4 +86,4 @@ def guiExec(pkgname): print(portageOutput.rstrip()) portageExec.wait() - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.localTable() diff --git a/src/backend/installsrc.py b/src/backend/installsrc.py index d860c20..9b88974 100644 --- a/src/backend/installsrc.py +++ b/src/backend/installsrc.py @@ -10,7 +10,7 @@ import sisyphus.checkenv import sisyphus.getenv import sisyphus.getfs import sisyphus.solvedeps -import sisyphus.syncDatabase +import sisyphus.syncdb import sisyphus.updateAll def cliExec(pkgname): @@ -43,7 +43,7 @@ def cliExec(pkgname): portageExec = subprocess.Popen(['emerge', '--quiet', '--verbose', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), stdout=subprocess.PIPE, stderr=subprocess.PIPE) portageExec.wait() - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.localTable() else: sys.exit("\n" + "Ok; Quitting." + "\n") else: @@ -71,7 +71,7 @@ def cliExec(pkgname): portageExec = subprocess.Popen(['emerge', '--quiet', '--verbose', '--usepkg', '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), stdout=subprocess.PIPE, stderr=subprocess.PIPE) portageExec.wait() - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.localTable() else: sys.exit("\n" + "Ok; Quitting." + "\n") else: @@ -80,7 +80,7 @@ def cliExec(pkgname): portageExec = subprocess.Popen(['emerge', '--quiet', '--verbose', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), stdout=subprocess.PIPE, stderr=subprocess.PIPE) portageExec.wait() - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.localTable() else: sys.exit("\n" + "Ok; Quitting." + "\n") else: diff --git a/src/backend/recoverdb.py b/src/backend/recoverdb.py index c429340..3c5cb78 100644 --- a/src/backend/recoverdb.py +++ b/src/backend/recoverdb.py @@ -3,7 +3,7 @@ import animation import os import sisyphus.getfs -import sisyphus.syncDatabase +import sisyphus.syncdb @animation.wait('recovering databases') def cliExec(): @@ -16,5 +16,5 @@ def cliExec(): if os.path.exists(sisyphus.getfs.localDatabase): os.remove(sisyphus.getfs.localDatabase) - sisyphus.syncDatabase.remoteTable() - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.remoteTable() + sisyphus.syncdb.localTable() diff --git a/src/backend/setProfile.py b/src/backend/setProfile.py deleted file mode 100644 index 3a7f5e3..0000000 --- a/src/backend/setProfile.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/python3 - -import animation -import platform -import subprocess - -@animation.wait('setting up profile') -def cliExec(): - if platform.uname()[4] == 'x86_64': - eselectExec = subprocess.Popen(['eselect', 'profile', 'set', 'default/linux/amd64/17.1/hardened']) - eselectExec.wait() - - if platform.uname()[4] == 'aarch64': - eselectExec = subprocess.Popen(['eselect', 'profile', 'set', 'default/linux/arm64/17.0']) - eselectExec.wait() - - envExec = subprocess.Popen(['env-update'], stdout=subprocess.DEVNULL) - envExec.wait() diff --git a/src/backend/setbranch.py b/src/backend/setbranch.py index 55e7be7..a028d76 100644 --- a/src/backend/setbranch.py +++ b/src/backend/setbranch.py @@ -8,7 +8,7 @@ import sisyphus.checkenv import sisyphus.getfs import sisyphus.purgeenv import sisyphus.setjobs -import sisyphus.setProfile +import sisyphus.setprofile def getBranchRemote(branch,remote): gentooRemote = [] @@ -87,7 +87,7 @@ def cliExec(branch,remote): injectRedcoreRepo(branch,remote) injectPortageConfigRepo(branch,remote) sisyphus.setjobs.cliExec() - sisyphus.setProfile.cliExec() + sisyphus.setprofile.cliExec() giveWarning(branch,remote) else: sys.exit("\nYou need root permissions to do this, exiting!\n") diff --git a/src/backend/setprofile.py b/src/backend/setprofile.py new file mode 100644 index 0000000..3a7f5e3 --- /dev/null +++ b/src/backend/setprofile.py @@ -0,0 +1,18 @@ +#!/usr/bin/python3 + +import animation +import platform +import subprocess + +@animation.wait('setting up profile') +def cliExec(): + if platform.uname()[4] == 'x86_64': + eselectExec = subprocess.Popen(['eselect', 'profile', 'set', 'default/linux/amd64/17.1/hardened']) + eselectExec.wait() + + if platform.uname()[4] == 'aarch64': + eselectExec = subprocess.Popen(['eselect', 'profile', 'set', 'default/linux/arm64/17.0']) + eselectExec.wait() + + envExec = subprocess.Popen(['env-update'], stdout=subprocess.DEVNULL) + envExec.wait() diff --git a/src/backend/syncDatabase.py b/src/backend/syncDatabase.py deleted file mode 100644 index b5d86ae..0000000 --- a/src/backend/syncDatabase.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/python3 - -import csv -import shutil -import urllib3 -import sqlite3 -import subprocess -import sisyphus.getenv -import sisyphus.getfs - -def remoteCSV(): - packagesCsvURL,descriptionsCsvURL = sisyphus.getenv.csvURL() - http = urllib3.PoolManager() - - with http.request('GET', packagesCsvURL, preload_content=False) as tmp_buffer, open(sisyphus.getfs.remotePackagesCsv, 'wb') as output_file: - shutil.copyfileobj(tmp_buffer, output_file) - - with http.request('GET', descriptionsCsvURL, preload_content=False) as tmp_buffer, open(sisyphus.getfs.remoteDescriptionsCsv, 'wb') as output_file: - shutil.copyfileobj(tmp_buffer, output_file) - -def localCSV(): - subprocess.call(['/usr/share/sisyphus/helpers/make_local_csv']) - -def remoteTable(): - remoteCSV() - - sisyphusdb = sqlite3.connect(sisyphus.getfs.localDatabase) - sisyphusdb.cursor().execute('''drop table if exists remote_packages''') - sisyphusdb.cursor().execute('''drop table if exists remote_descriptions''') - sisyphusdb.cursor().execute('''create table remote_packages (category TEXT,name TEXT,version TEXT,slot TEXT)''') - sisyphusdb.cursor().execute('''create table remote_descriptions (category TEXT,name TEXT,description TEXT)''') - - with open(sisyphus.getfs.remotePackagesCsv) as input_file: - for row in csv.reader(input_file): - sisyphusdb.cursor().execute("insert into remote_packages (category, name, version, slot) values (?, ?, ?, ?);", row) - - with open(sisyphus.getfs.remoteDescriptionsCsv) as input_file: - for row in csv.reader(input_file): - sisyphusdb.cursor().execute("insert into remote_descriptions (category, name, description) values (?, ?, ?);", row) - - sisyphusdb.commit() - sisyphusdb.close() - -def localTable(): - localCSV() - - sisyphusdb = sqlite3.connect(sisyphus.getfs.localDatabase) - sisyphusdb.cursor().execute('''drop table if exists local_packages''') - sisyphusdb.cursor().execute('''create table local_packages (category TEXT,name TEXT,version TEXT,slot TEXT)''') - - with open(sisyphus.getfs.localPackagesCsv) as input_file: - for row in csv.reader(input_file): - sisyphusdb.cursor().execute("insert into local_packages (category, name, version, slot) values (?, ?, ?, ?);", row) - - sisyphusdb.commit() - sisyphusdb.close() - diff --git a/src/backend/syncSPM.py b/src/backend/syncSPM.py index d7e5cdb..b97471e 100644 --- a/src/backend/syncSPM.py +++ b/src/backend/syncSPM.py @@ -1,8 +1,8 @@ #!/usr/bin/python3 import animation -import sisyphus.syncDatabase +import sisyphus.syncdb @animation.wait('syncing spm changes') def cliExec(): - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.localTable() diff --git a/src/backend/syncdb.py b/src/backend/syncdb.py new file mode 100644 index 0000000..b5d86ae --- /dev/null +++ b/src/backend/syncdb.py @@ -0,0 +1,57 @@ +#!/usr/bin/python3 + +import csv +import shutil +import urllib3 +import sqlite3 +import subprocess +import sisyphus.getenv +import sisyphus.getfs + +def remoteCSV(): + packagesCsvURL,descriptionsCsvURL = sisyphus.getenv.csvURL() + http = urllib3.PoolManager() + + with http.request('GET', packagesCsvURL, preload_content=False) as tmp_buffer, open(sisyphus.getfs.remotePackagesCsv, 'wb') as output_file: + shutil.copyfileobj(tmp_buffer, output_file) + + with http.request('GET', descriptionsCsvURL, preload_content=False) as tmp_buffer, open(sisyphus.getfs.remoteDescriptionsCsv, 'wb') as output_file: + shutil.copyfileobj(tmp_buffer, output_file) + +def localCSV(): + subprocess.call(['/usr/share/sisyphus/helpers/make_local_csv']) + +def remoteTable(): + remoteCSV() + + sisyphusdb = sqlite3.connect(sisyphus.getfs.localDatabase) + sisyphusdb.cursor().execute('''drop table if exists remote_packages''') + sisyphusdb.cursor().execute('''drop table if exists remote_descriptions''') + sisyphusdb.cursor().execute('''create table remote_packages (category TEXT,name TEXT,version TEXT,slot TEXT)''') + sisyphusdb.cursor().execute('''create table remote_descriptions (category TEXT,name TEXT,description TEXT)''') + + with open(sisyphus.getfs.remotePackagesCsv) as input_file: + for row in csv.reader(input_file): + sisyphusdb.cursor().execute("insert into remote_packages (category, name, version, slot) values (?, ?, ?, ?);", row) + + with open(sisyphus.getfs.remoteDescriptionsCsv) as input_file: + for row in csv.reader(input_file): + sisyphusdb.cursor().execute("insert into remote_descriptions (category, name, description) values (?, ?, ?);", row) + + sisyphusdb.commit() + sisyphusdb.close() + +def localTable(): + localCSV() + + sisyphusdb = sqlite3.connect(sisyphus.getfs.localDatabase) + sisyphusdb.cursor().execute('''drop table if exists local_packages''') + sisyphusdb.cursor().execute('''create table local_packages (category TEXT,name TEXT,version TEXT,slot TEXT)''') + + with open(sisyphus.getfs.localPackagesCsv) as input_file: + for row in csv.reader(input_file): + sisyphusdb.cursor().execute("insert into local_packages (category, name, version, slot) values (?, ?, ?, ?);", row) + + sisyphusdb.commit() + sisyphusdb.close() + diff --git a/src/backend/uninstallAll.py b/src/backend/uninstallAll.py index c7eea8c..617977f 100644 --- a/src/backend/uninstallAll.py +++ b/src/backend/uninstallAll.py @@ -6,13 +6,13 @@ import subprocess import sys import sisyphus.checkenv import sisyphus.killemerge -import sisyphus.syncDatabase +import sisyphus.syncdb def cliExec(pkgname): if sisyphus.checkenv.root(): portageExec = subprocess.Popen(['emerge', '--quiet', '--depclean', '--ask'] + list(pkgname)) portageExec.wait() - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.localTable() else: sys.exit("\nYou need root permissions to do this, exiting!\n") @@ -20,7 +20,7 @@ def cliExecForce(pkgname): if sisyphus.checkenv.root(): portageExec = subprocess.Popen(['emerge', '--quiet', '--unmerge', '--ask'] + list(pkgname)) portageExec.wait() - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.localTable() else: sys.exit("\nYou need root permissions to do this, exiting!\n") @@ -33,4 +33,4 @@ def guiExec(pkgname): print(portageOutput.rstrip()) portageExec.wait() - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.localTable() diff --git a/src/backend/updateAll.py b/src/backend/updateAll.py index d7d1203..6abcb70 100644 --- a/src/backend/updateAll.py +++ b/src/backend/updateAll.py @@ -6,7 +6,7 @@ import time import sisyphus.checkenv import sisyphus.getenv import sisyphus.purgeenv -import sisyphus.syncDatabase +import sisyphus.syncdb import sisyphus.syncEnvironment def syncAll(): @@ -14,7 +14,7 @@ def syncAll(): sisyphus.syncEnvironment.gentooRepo() sisyphus.syncEnvironment.redcoreRepo() sisyphus.syncEnvironment.portageConfigRepo() - sisyphus.syncDatabase.remoteTable() + sisyphus.syncdb.remoteTable() @animation.wait('fetching updates') def cliExec(): diff --git a/src/backend/upgradePkg.py b/src/backend/upgradePkg.py index 566ff85..eea69a9 100644 --- a/src/backend/upgradePkg.py +++ b/src/backend/upgradePkg.py @@ -12,7 +12,7 @@ import sisyphus.getenv import sisyphus.getfs import sisyphus.killemerge import sisyphus.solvedeps -import sisyphus.syncDatabase +import sisyphus.syncdb import sisyphus.updateAll def cliExec(): @@ -45,7 +45,7 @@ def cliExec(): portageExec = subprocess.Popen(['emerge', '--quiet', '--verbose', '--update', '--deep', '--newuse', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) portageExec.wait() - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.localTable() else: sys.exit("\n" + "Ok; Quitting." + "\n") else: @@ -90,6 +90,6 @@ def guiExec(): print(portageOutput.rstrip()) portageExec.wait() - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.localTable() else: print("\n" + "No package upgrades found; Quitting." + "\n") diff --git a/src/backend/upgradeSrc.py b/src/backend/upgradeSrc.py index 2d88dac..481fd83 100644 --- a/src/backend/upgradeSrc.py +++ b/src/backend/upgradeSrc.py @@ -10,7 +10,7 @@ import sisyphus.checkenv import sisyphus.getenv import sisyphus.getfs import sisyphus.solvedeps -import sisyphus.syncDatabase +import sisyphus.syncdb import sisyphus.updateAll def cliExec(): @@ -43,7 +43,7 @@ def cliExec(): portageExec = subprocess.Popen(['emerge', '--quiet', '--verbose', '--update', '--deep', '--newuse', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) portageExec.wait() - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.localTable() else: sys.exit("\n" + "Ok; Quitting." + "\n") else: @@ -71,7 +71,7 @@ def cliExec(): portageExec = subprocess.Popen(['emerge', '--quiet', '--verbose', '--update', '--deep', '--newuse', '--usepkg', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) portageExec.wait() - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.localTable() else: sys.exit("\n" + "Ok; Quitting." + "\n") else: @@ -80,7 +80,7 @@ def cliExec(): portageExec = subprocess.Popen(['emerge', '--quiet', '--verbose', '--update', '--deep', '--newuse', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) portageExec.wait() - sisyphus.syncDatabase.localTable() + sisyphus.syncdb.localTable() else: sys.exit("\n" + "Ok; Quitting." + "\n") else: -- cgit v1.2.3