summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2018-09-15 20:02:44 +0100
committerV3n3RiX <venerix@redcorelinux.org>2018-09-15 20:02:44 +0100
commitac10326fcf926f11fd21f69efd896b5ead503b26 (patch)
tree5fc02b65f74bd4a6e5fe16d4fe563f45d821a462
parent0ce66b4deb653d31ac71a1a5020a12d7fed12f48 (diff)
reduce the number of database connections to speed things a bit, arrange the code a bitv1.1809
-rw-r--r--src/backend/libsisyphus.py307
-rwxr-xr-xsrc/frontend/cli/sisyphus-cli.py4
-rw-r--r--src/frontend/gui/sisyphus-gui.py78
3 files changed, 127 insertions, 262 deletions
diff --git a/src/backend/libsisyphus.py b/src/backend/libsisyphus.py
index 55e185a..c218972 100644
--- a/src/backend/libsisyphus.py
+++ b/src/backend/libsisyphus.py
@@ -20,16 +20,10 @@ localPkgsDB = '/var/lib/sisyphus/csv/localPackagesPre.csv'
sisyphusDB = '/var/lib/sisyphus/db/sisyphus.db'
mirrorCfg = '/etc/sisyphus/mirrors.conf'
-# only run as root (CLI + GUI frontend)
-
-
def checkRoot():
if not os.getuid() == 0:
sys.exit("\nYou need root permissions to do this, exiting!\n")
-# only run in binary mode (binmode) or hybrid mode (mixedmode) (CLI + GUI frontend)
-
-
def checkSystemMode():
portageBinCfg = '/opt/redcore-build/conf/intel/portage/make.conf.amd64-binmode'
portageCfgSym = '/etc/portage/make.conf'
@@ -44,48 +38,70 @@ def checkSystemMode():
print("\nThe system is not set to binmode, refusing to run!\n")
sys.exit(1)
-# get current mirror information, so we know where we download from (CLI + GUI frontend)
+def getMirrorList():
+ mirrorList = []
+ with open(mirrorCfg) as mirrorFile:
+ for line in mirrorFile.readlines():
+ if 'PORTAGE_BINHOST=' in line:
+ url = line.split("=")[1].replace('"', '').rstrip()
+ mirror = {'isActive': True, 'Url': url}
+ if line.startswith('#'):
+ mirror['isActive'] = False
+ mirrorList.append(mirror)
+ mirrorFile.close()
+ return mirrorList
def getBinhostURL():
binhostURL = []
+ portageExec = subprocess.Popen(['emerge', '--info', '--verbose'], stdout=subprocess.PIPE)
- portageExec = subprocess.Popen(
- ['emerge', '--info', '--verbose'], stdout=subprocess.PIPE)
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
if "PORTAGE_BINHOST" in portageOutput.rstrip():
binhostURL = str(portageOutput.rstrip().split("=")[1].strip('\"'))
-
return binhostURL
-
def getRemotePkgsURL():
remotePkgsURL = []
+ portageExec = subprocess.Popen(['emerge', '--info', '--verbose'], stdout=subprocess.PIPE)
- portageExec = subprocess.Popen(
- ['emerge', '--info', '--verbose'], stdout=subprocess.PIPE)
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
if "PORTAGE_BINHOST" in portageOutput.rstrip():
- remotePkgsURL = str(portageOutput.rstrip().split("=")[1].strip(
- '\"').replace('packages', 'csv') + 'remotePackagesPre.csv')
-
+ remotePkgsURL = str(portageOutput.rstrip().split("=")[1].strip('\"').replace('packages', 'csv') + 'remotePackagesPre.csv')
return remotePkgsURL
-
def getRemoteDscsURL():
remoteDscsURL = []
+ portageExec = subprocess.Popen(['emerge', '--info', '--verbose'], stdout=subprocess.PIPE)
- portageExec = subprocess.Popen(
- ['emerge', '--info', '--verbose'], stdout=subprocess.PIPE)
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
if "PORTAGE_BINHOST" in portageOutput.rstrip():
- remoteDscsURL = str(portageOutput.rstrip().split("=")[1].strip(
- '\"').replace('packages', 'csv') + 'remoteDescriptionsPre.csv')
-
+ remoteDscsURL = str(portageOutput.rstrip().split("=")[1].strip('\"').replace('packages', 'csv') + 'remoteDescriptionsPre.csv')
return remoteDscsURL
-# download remote CSV's to be imported into the database (CLI + GUI frontend)
+@animation.wait('resolving dependencies')
+def getPkgDeps(pkgList):
+ pkgDeps = []
+ portageExec = subprocess.Popen(['emerge', '-qgp'] + pkgList, stdout=subprocess.PIPE)
+ for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
+ if "/" in portageOutput.rstrip():
+ pkgDep = str(portageOutput.rstrip().split("]")[1].strip("\ "))
+ if not "blocking" in pkgDep:
+ pkgDeps.append(pkgDep)
+ return pkgDeps
+
+@animation.wait('resolving dependencies')
+def getWorldDeps():
+ worldDeps = []
+ portageExec = subprocess.Popen(['emerge', '-uDNqgp', '--backtrack=100', '--with-bdeps=y', '@world'], stdout=subprocess.PIPE)
+
+ for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
+ if "/" in portageOutput.rstrip():
+ worldDep = str(portageOutput.rstrip().split("]")[1].split("[")[0].strip("\ "))
+ if not "blocking" in worldDep:
+ worldDeps.append(worldDep)
+ return worldDeps
def fetchRemoteDatabase():
remotePkgsURL = getRemotePkgsURL()
@@ -98,74 +114,50 @@ def fetchRemoteDatabase():
with http.request('GET', remoteDscsURL, preload_content=False) as tmp_buffer, open(remoteDscsDB, 'wb') as output_file:
shutil.copyfileobj(tmp_buffer, output_file)
-# generate local CSV's to be imported into the database (CLI + GUI frontend)
-
-
def makeLocalDatabase():
- # this is really hard to do in python, so we cheat with a bash helper script
subprocess.check_call(['/usr/share/sisyphus/helpers/make_local_csv'])
-# download and import remote CSV's into the database (CLI + GUI frontend)
-
-
def syncRemoteDatabase():
fetchRemoteDatabase()
sisyphusdb = sqlite3.connect(sisyphusDB)
sisyphusdb.cursor().execute('''drop table if exists remote_packages''')
- sisyphusdb.cursor().execute(
- '''create table remote_packages (category TEXT,name TEXT,version TEXT,slot TEXT)''')
+ 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(remotePkgsDB) as rmtCsv:
for row in csv.reader(rmtCsv):
- sisyphusdb.cursor().execute(
- "insert into remote_packages (category, name, version, slot) values (?, ?, ?, ?);", row)
- sisyphusdb.commit()
- sisyphusdb.close()
+ sisyphusdb.cursor().execute("insert into remote_packages (category, name, version, slot) values (?, ?, ?, ?);", row)
- sisyphusdb = sqlite3.connect(sisyphusDB)
- sisyphusdb.cursor().execute('''drop table if exists remote_descriptions''')
- sisyphusdb.cursor().execute(
- '''create table remote_descriptions (category TEXT,name TEXT,description TEXT)''')
with open(remoteDscsDB) as rmtCsv:
for row in csv.reader(rmtCsv):
- sisyphusdb.cursor().execute(
- "insert into remote_descriptions (category, name, description) values (?, ?, ?);", row)
+ sisyphusdb.cursor().execute("insert into remote_descriptions (category, name, description) values (?, ?, ?);", row)
+
sisyphusdb.commit()
sisyphusdb.close()
-# generate and import local CSV's into the database (CLI + GUI frontend)
-
-
def syncLocalDatabase():
makeLocalDatabase()
sisyphusdb = sqlite3.connect(sisyphusDB)
sisyphusdb.cursor().execute('''drop table if exists local_packages''')
- sisyphusdb.cursor().execute(
- '''create table local_packages (category TEXT,name TEXT,version TEXT,slot TEXT)''')
+ sisyphusdb.cursor().execute('''create table local_packages (category TEXT,name TEXT,version TEXT,slot TEXT)''')
+
with open(localPkgsDB) as lclCsv:
for row in csv.reader(lclCsv):
- sisyphusdb.cursor().execute(
- "insert into local_packages (category, name, version, slot) values (?, ?, ?, ?);", row)
+ sisyphusdb.cursor().execute("insert into local_packages (category, name, version, slot) values (?, ?, ?, ?);", row)
+
sisyphusdb.commit()
sisyphusdb.close()
-# sync portage tree (CLI + GUI frontend)
-
-
def syncPortageTree():
subprocess.call(['emerge', '--sync', '--quiet'])
-# sync portage configuration files (CLI + GUI frontend)
-
-
def syncPortageCfg():
os.chdir(portageCfg)
subprocess.call(['git', 'pull', '--quiet'])
-# check remote timestamps...if newer than local timestamps, sync everything (CLI + GUI frontend)
-
-
@animation.wait('syncing remote database')
def syncAll():
checkRoot()
@@ -175,13 +167,11 @@ def syncAll():
http = urllib3.PoolManager()
reqRemotePkgsTS = http.request('HEAD', remotePkgsURL)
- remotePkgsTS = int(parser.parse(
- reqRemotePkgsTS.headers['last-modified']).strftime("%s"))
+ remotePkgsTS = int(parser.parse(reqRemotePkgsTS.headers['last-modified']).strftime("%s"))
localPkgsTS = int(os.path.getctime(remotePkgsDB))
reqRemoteDscsTS = http.request('HEAD', remoteDscsURL)
- remoteDscsTS = int(parser.parse(
- reqRemoteDscsTS.headers['last-modified']).strftime("%s"))
+ remoteDscsTS = int(parser.parse(reqRemoteDscsTS.headers['last-modified']).strftime("%s"))
localDscsTS = int(os.path.getctime(remoteDscsDB))
if remotePkgsTS < localPkgsTS:
@@ -193,28 +183,15 @@ def syncAll():
syncPortageCfg()
syncRemoteDatabase()
-# regenerate local CSV's and import them into the database (CLI frontend)
-# if something is installed with portage directly using emerge, sisyphus won't be aware of it
-# this will parse local portage database and import the changes into sisyphus database
-
-
@animation.wait('syncing local database')
def startSyncSPM():
syncLocalDatabase()
-# sync portage tree and portage configuration files (CLI frontend)
-
-
@animation.wait('syncing portage')
def startSync():
syncPortageTree()
syncPortageCfg()
-# regenerate sisyphus database (CLI frontend)
-# if for some reason sisyphus database gets corrupted or deleted, we can still regenerate it from portage database
-# this will fetch remote information from mirrors, parse local portage database and regenerate sisyphus database
-
-
@animation.wait('resurrecting database')
def rescueDB():
if os.path.exists(remotePkgsDB):
@@ -229,45 +206,17 @@ def rescueDB():
syncRemoteDatabase()
syncLocalDatabase()
-# call portage to solve package(s) dependencies (CLI frontend)
-
-
-@animation.wait('resolving dependencies')
-def solvePkgDeps(pkgList):
- pkgDeps = []
- portageExec = subprocess.Popen(
- ['emerge', '-qgp'] + pkgList, stdout=subprocess.PIPE)
- for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
- if "/" in portageOutput.rstrip():
- pkgDep = str(portageOutput.rstrip().split("]")[1].strip("\ "))
- if not "blocking" in pkgDep:
- pkgDeps.append(pkgDep)
- return pkgDeps
-
-# call portage to solve world dependencies (CLI frontend)
-
-
-@animation.wait('resolving dependencies')
-def solveWorldDeps():
- worldDeps = []
- portageExec = subprocess.Popen(
- ['emerge', '-uDNqgp', '--backtrack=100', '--with-bdeps=y', '@world'], stdout=subprocess.PIPE)
- for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
- if "/" in portageOutput.rstrip():
- worldDep = str(portageOutput.rstrip().split("]")[
- 1].split("[")[0].strip("\ "))
- if not "blocking" in worldDep:
- worldDeps.append(worldDep)
- return worldDeps
-
-# fetch binaries and call portage to install the package(s) from local cache (CLI frontend)
+def startSearch(pkgList):
+ subprocess.check_call(['emerge', '-sg'] + pkgList)
+def startUpdate():
+ syncAll()
def startInstall(pkgList):
syncAll()
binhostURL = getBinhostURL()
- pkgDeps = solvePkgDeps(pkgList)
+ pkgDeps = getPkgDeps(pkgList)
pkgBins = []
if not len(pkgDeps) == 0:
@@ -285,21 +234,16 @@ def startInstall(pkgList):
for index, binpkg in enumerate(pkgBins):
subprocess.call(['qtbz2', '-x'] + str(binpkg + '.tbz2').split())
- CATEGORY = subprocess.check_output(
- ['qxpak', '-x', '-O'] + str(binpkg + '.xpak').split() + ['CATEGORY'])
- # we extracted the categories, safe to delete
+ CATEGORY = subprocess.check_output(['qxpak', '-x', '-O'] + str(binpkg + '.xpak').split() + ['CATEGORY'])
os.remove(str(binpkg + '.xpak'))
if os.path.isdir(portageCache + CATEGORY.decode().strip()):
- shutil.move(str(binpkg + '.tbz2'), os.path.join(portageCache +
- CATEGORY.decode().strip(), os.path.basename(str(binpkg + '.tbz2'))))
+ shutil.move(str(binpkg + '.tbz2'), os.path.join(portageCache + CATEGORY.decode().strip(), os.path.basename(str(binpkg + '.tbz2'))))
else:
os.makedirs(portageCache + CATEGORY.decode().strip())
- shutil.move(str(binpkg + '.tbz2'), os.path.join(portageCache +
- CATEGORY.decode().strip(), os.path.basename(str(binpkg + '.tbz2'))))
+ shutil.move(str(binpkg + '.tbz2'), os.path.join(portageCache + CATEGORY.decode().strip(), os.path.basename(str(binpkg + '.tbz2'))))
if os.path.exists(str(binpkg + '.tbz2')):
- # we moved the binaries in cache, safe to delete
os.remove(str(binpkg + '.tbz2'))
portageExec = subprocess.Popen(['emerge', '-q'] + pkgList)
@@ -308,38 +252,11 @@ def startInstall(pkgList):
else:
sys.exit(1)
-# call portage to uninstall the package(s) (CLI frontend)
-
-
-def startUninstall(pkgList):
- portageExec = subprocess.Popen(['emerge', '-cqa'] + pkgList)
- portageExec.wait()
- syncLocalDatabase()
-
-# call portage to force-uninstall the package(s) (CLI frontend)
-
-
-def startUninstallForce(pkgList):
- portageExec = subprocess.Popen(['emerge', '-Cqa'] + pkgList)
- portageExec.wait()
- syncLocalDatabase()
-
-# call portage to remove orphan package(s) (CLI frontend)
-
-
-def removeOrphans():
- portageExec = subprocess.Popen(['emerge', '-cqa'])
- portageExec.wait()
- syncLocalDatabase()
-
-# fetch binaries and call portage to perform a system upgrade using local cache (CLI frontend)
-
-
def startUpgrade():
syncAll()
binhostURL = getBinhostURL()
- worldDeps = solveWorldDeps()
+ worldDeps = getWorldDeps()
worldBins = []
if not len(worldDeps) == 0:
@@ -357,84 +274,61 @@ def startUpgrade():
for index, worldpkg in enumerate(worldBins):
subprocess.call(['qtbz2', '-x'] + str(worldpkg + '.tbz2').split())
- CATEGORY = subprocess.check_output(
- ['qxpak', '-x', '-O'] + str(worldpkg + '.xpak').split() + ['CATEGORY'])
- # we extracted the categories, safe to delete
+ CATEGORY = subprocess.check_output(['qxpak', '-x', '-O'] + str(worldpkg + '.xpak').split() + ['CATEGORY'])
os.remove(str(worldpkg + '.xpak'))
if os.path.isdir(portageCache + CATEGORY.decode().strip()):
- shutil.move(str(worldpkg + '.tbz2'), os.path.join(portageCache +
- CATEGORY.decode().strip(), os.path.basename(str(worldpkg + '.tbz2'))))
+ shutil.move(str(worldpkg + '.tbz2'), os.path.join(portageCache + CATEGORY.decode().strip(), os.path.basename(str(worldpkg + '.tbz2'))))
else:
os.makedirs(portageCache + CATEGORY.decode().strip())
- shutil.move(str(worldpkg + '.tbz2'), os.path.join(portageCache +
- CATEGORY.decode().strip(), os.path.basename(str(worldpkg + '.tbz2'))))
+ shutil.move(str(worldpkg + '.tbz2'), os.path.join(portageCache + CATEGORY.decode().strip(), os.path.basename(str(worldpkg + '.tbz2'))))
if os.path.exists(str(worldpkg + '.tbz2')):
- # we moved the binaries in cache, safe to delete
os.remove(str(worldpkg + '.tbz2'))
- portageExec = subprocess.Popen(
- ['emerge', '-uDNq', '--backtrack=100', '--with-bdeps=y', '@world'])
+ portageExec = subprocess.Popen(['emerge', '-uDNq', '--backtrack=100', '--with-bdeps=y', '@world'])
portageExec.wait()
syncLocalDatabase()
else:
sys.exit("\n" + "Nothing to upgrade; quitting." + "\n")
-# call portage to search for package(s) (CLI frontend)
-
-
-def startSearch(pkgList):
- # FIXME : query sisyphus.db instead of searching through portage
- subprocess.check_call(['emerge', '-sg'] + pkgList)
-
-# check remote timestamps...if newer than local timestamps, sync everything (CLI + GUI frontend)
-
-
-def startUpdate():
- syncAll()
+def startUninstall(pkgList):
+ portageExec = subprocess.Popen(['emerge', '-cqa'] + pkgList)
+ portageExec.wait()
+ syncLocalDatabase()
-# display information about installed core packages and portage configuration (CLI frontend)
+def startUninstallForce(pkgList):
+ portageExec = subprocess.Popen(['emerge', '-Cqa'] + pkgList)
+ portageExec.wait()
+ syncLocalDatabase()
+def removeOrphans():
+ portageExec = subprocess.Popen(['emerge', '-cqa'])
+ portageExec.wait()
+ syncLocalDatabase()
def sysInfo():
subprocess.check_call(['emerge', '--info'])
-# kill background portage process if sisyphus dies (CLI + GUI frontend)
-
-
def portageKill(portageCmd):
portageCmd.terminate()
-# get a list of mirrors (GUI frontend)
-
-
-def getMirrors():
- mirrorList = []
- with open(mirrorCfg) as mirrorFile:
- for line in mirrorFile.readlines():
- if 'PORTAGE_BINHOST=' in line:
- url = line.split("=")[1].replace('"', '').rstrip()
- mirror = {'isActive': True, 'Url': url}
- if line.startswith('#'):
- mirror['isActive'] = False
- mirrorList.append(mirror)
- mirrorFile.close()
- return mirrorList
-# set the active mirror (GUI frontend)
+def printMirrorList():
+ mirrorList = getMirrorList()
+ for i, line in enumerate(mirrorList):
+ if line['isActive']:
+ print(i + 1, '*', line['Url'])
+ else:
+ print(i + 1, ' ', line['Url'])
-def setActiveMirror(mirrorList):
+def writeMirrorCfg(mirrorList):
with open(mirrorCfg, 'w+') as mirrorFile:
- mirrorFile.write(
- "#######################################################\n")
- mirrorFile.write(
- "# Support for multiple mirrors is somewhat incomplete #\n")
- mirrorFile.write(
- "# Uncomment only one mirror from the list bellow #\n")
- mirrorFile.write(
- "#######################################################\n")
+ mirrorFile.write("#######################################################\n")
+ mirrorFile.write("# Support for multiple mirrors is somewhat incomplete #\n")
+ mirrorFile.write("# Uncomment only one mirror from the list bellow #\n")
+ mirrorFile.write("#######################################################\n")
mirrorFile.write("\n")
for line in mirrorList:
mirror = 'PORTAGE_BINHOST=' + '"' + line['Url'] + '"'
@@ -443,23 +337,9 @@ def setActiveMirror(mirrorList):
mirrorFile.write(mirror + "\n")
mirrorFile.write("\n")
-# get a list of mirrors (CLI frontend)
-
-
-def listRepo():
- mirrorList = getMirrors()
- for i, line in enumerate(mirrorList):
- if line['isActive']:
- print(i + 1, '*', line['Url'])
- else:
- print(i + 1, ' ', line['Url'])
-
-# set the active mirror (CLI frontend)
-
-
-def setRepo(mirror):
+def setActiveMirror(mirror):
mirror = int(mirror[0])
- mirrorList = getMirrors()
+ mirrorList = getMirrorList()
if mirror not in range(1, len(mirrorList) + 1):
print('mirror index is wrong, please check with "sisyphus mirror list"')
else:
@@ -469,10 +349,7 @@ def setRepo(mirror):
mirrorList[i]['isActive'] = True
else:
mirrorList[i]['isActive'] = False
- setActiveMirror(mirrorList)
-
-# display help menu (CLI frontend)
-
+ writeMirrorCfg(mirrorList)
def showHelp():
print("\nUsage : sisyphus command [package(s)] || [file(s)]\n")
diff --git a/src/frontend/cli/sisyphus-cli.py b/src/frontend/cli/sisyphus-cli.py
index 9d347ab..d5febd9 100755
--- a/src/frontend/cli/sisyphus-cli.py
+++ b/src/frontend/cli/sisyphus-cli.py
@@ -31,10 +31,10 @@ if "__main__" == __name__:
sysInfo()
elif "mirror" in sys.argv[1:]:
if "list" in sys.argv[2:]:
- listRepo()
+ printMirrorList()
elif "set" in sys.argv[2:]:
if sys.argv[3:]:
- setRepo(sys.argv[3:])
+ setActiveMirror(sys.argv[3:])
else:
showHelp()
else:
diff --git a/src/frontend/gui/sisyphus-gui.py b/src/frontend/gui/sisyphus-gui.py
index 793a30e..8050568 100644
--- a/src/frontend/gui/sisyphus-gui.py
+++ b/src/frontend/gui/sisyphus-gui.py
@@ -11,7 +11,6 @@ from PyQt5 import QtCore, QtGui, QtWidgets, uic
from libsisyphus import *
-# main window class
class Sisyphus(QtWidgets.QMainWindow):
def __init__(self):
super(Sisyphus, self).__init__()
@@ -26,8 +25,7 @@ class Sisyphus(QtWidgets.QMainWindow):
])
self.applicationFilter.addItems(self.filterApplications.keys())
self.applicationFilter.setCurrentText('Search by Name')
- self.applicationFilter.currentIndexChanged.connect(
- self.setApplicationFilter)
+ self.applicationFilter.currentIndexChanged.connect(self.setApplicationFilter)
Sisyphus.applicationView = self.filterApplications['Search by Name']
self.filterDatabases = OrderedDict([
@@ -73,8 +71,7 @@ class Sisyphus(QtWidgets.QMainWindow):
self.uninstallThread = QtCore.QThread()
self.uninstallWorker.moveToThread(self.uninstallThread)
self.uninstallWorker.started.connect(self.showProgressBar)
- self.uninstallThread.started.connect(
- self.uninstallWorker.startUninstall)
+ self.uninstallThread.started.connect(self.uninstallWorker.startUninstall)
self.uninstallWorker.strReady.connect(self.updateStatusBar)
self.uninstallThread.finished.connect(self.jobDone)
self.uninstallWorker.finished.connect(self.uninstallThread.quit)
@@ -110,22 +107,18 @@ class Sisyphus(QtWidgets.QMainWindow):
(resolution.height() / 2) - (self.frameSize().height() / 2))
def rowClicked(self):
- Sisyphus.pkgSelect = len(
- self.databaseTable.selectionModel().selectedRows())
+ Sisyphus.pkgSelect = len(self.databaseTable.selectionModel().selectedRows())
self.showPackageCount()
def showPackageCount(self):
- self.statusBar().showMessage("Found: %d, Selected: %d packages" %
- (Sisyphus.pkgCount, Sisyphus.pkgSelect))
+ self.statusBar().showMessage("Found: %d, Selected: %d packages" % (Sisyphus.pkgCount, Sisyphus.pkgSelect))
def setApplicationFilter(self):
- Sisyphus.applicationView = self.filterApplications[self.applicationFilter.currentText(
- )]
+ Sisyphus.applicationView = self.filterApplications[self.applicationFilter.currentText()]
self.loadDatabase()
def setDatabaseFilter(self):
- Sisyphus.databaseView = self.filterDatabases[self.databaseFilter.currentText(
- )]
+ Sisyphus.databaseView = self.filterDatabases[self.databaseFilter.currentText()]
Sisyphus.SELECT = self.databaseFilter.currentText()
self.loadDatabase()
@@ -210,8 +203,7 @@ class Sisyphus(QtWidgets.QMainWindow):
Sisyphus.pkgCount = len(rows)
Sisyphus.pkgSelect = 0
model = QtGui.QStandardItemModel(len(rows), 5)
- model.setHorizontalHeaderLabels(
- ['Category', 'Name', 'Installed Version', 'Available Version', 'Description'])
+ model.setHorizontalHeaderLabels(['Category', 'Name', 'Installed Version', 'Available Version', 'Description'])
for row in rows:
indx = rows.index(row)
for column in range(0, 5):
@@ -304,13 +296,12 @@ class Sisyphus(QtWidgets.QMainWindow):
self.close()
-# mirror configuration window class
class MirrorConfiguration(QtWidgets.QMainWindow):
def __init__(self):
super(MirrorConfiguration, self).__init__()
uic.loadUi('ui/mirrorcfg.ui', self)
self.centerOnScreen()
- self.MIRRORLIST = getMirrors()
+ self.MIRRORLIST = getMirrorList()
self.updateMirrorList()
self.applyButton.pressed.connect(self.mirrorCfgApply)
self.applyButton.released.connect(self.mirrorCfgExit)
@@ -339,13 +330,12 @@ class MirrorConfiguration(QtWidgets.QMainWindow):
self.MIRRORLIST[self.ACTIVEMIRRORINDEX]['isActive'] = True
def mirrorCfgApply(self):
- setActiveMirror(self.MIRRORLIST)
+ writeMirrorCfg(self.MIRRORLIST)
def mirrorCfgExit(self):
self.close()
-# license information window class
class LicenseInformation(QtWidgets.QMainWindow):
def __init__(self):
super(LicenseInformation, self).__init__()
@@ -376,7 +366,7 @@ class MainWorker(QtCore.QObject):
pkgList = Sisyphus.pkgList
binhostURL = getBinhostURL()
- pkgDeps = solvePkgDeps(pkgList)
+ pkgDeps = getPkgDeps(pkgList)
pkgBins = []
for index, url in enumerate([binhostURL + package + '.tbz2' for package in pkgDeps]):
@@ -390,28 +380,25 @@ class MainWorker(QtCore.QObject):
for index, binpkg in enumerate(pkgBins):
subprocess.call(['qtbz2', '-x'] + str(binpkg + '.tbz2').split())
- CATEGORY = subprocess.check_output(
- ['qxpak', '-x', '-O'] + str(binpkg + '.xpak').split() + ['CATEGORY'])
- # we extracted the categories, safe to delete
+ CATEGORY = subprocess.check_output(['qxpak', '-x', '-O'] + str(binpkg + '.xpak').split() + ['CATEGORY'])
os.remove(str(binpkg + '.xpak'))
if os.path.isdir(portageCache + CATEGORY.decode().strip()):
- shutil.move(str(binpkg + '.tbz2'), os.path.join(portageCache +
- CATEGORY.decode().strip(), os.path.basename(str(binpkg + '.tbz2'))))
+ shutil.move(str(binpkg + '.tbz2'), os.path.join(portageCache + CATEGORY.decode().strip(), os.path.basename(str(binpkg + '.tbz2'))))
else:
os.makedirs(portageCache + CATEGORY.decode().strip())
- shutil.move(str(binpkg + '.tbz2'), os.path.join(portageCache +
- CATEGORY.decode().strip(), os.path.basename(str(binpkg + '.tbz2'))))
+ shutil.move(str(binpkg + '.tbz2'), os.path.join(portageCache + CATEGORY.decode().strip(), os.path.basename(str(binpkg + '.tbz2'))))
if os.path.exists(str(binpkg + '.tbz2')):
- # we moved the binaries in cache, safe to delete
os.remove(str(binpkg + '.tbz2'))
- portageExec = subprocess.Popen(
- ['emerge', '-q'] + pkgList, stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '-q'] + pkgList, stdout=subprocess.PIPE)
+
atexit.register(portageKill, portageExec)
+
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
self.strReady.emit(portageOutput.rstrip())
+
portageExec.wait()
syncLocalDatabase()
self.finished.emit()
@@ -420,11 +407,13 @@ class MainWorker(QtCore.QObject):
def startUninstall(self):
self.started.emit()
pkgList = Sisyphus.pkgList
- portageExec = subprocess.Popen(
- ['emerge', '-cq'] + pkgList, stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '-cq'] + pkgList, stdout=subprocess.PIPE)
+
atexit.register(portageKill, portageExec)
+
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
self.strReady.emit(portageOutput.rstrip())
+
portageExec.wait()
syncLocalDatabase()
self.finished.emit()
@@ -434,7 +423,7 @@ class MainWorker(QtCore.QObject):
self.started.emit()
binhostURL = getBinhostURL()
- worldDeps = solveWorldDeps()
+ worldDeps = getWorldDeps()
worldBins = []
for index, url in enumerate([binhostURL + package + '.tbz2' for package in worldDeps]):
@@ -448,28 +437,25 @@ class MainWorker(QtCore.QObject):
for index, worldpkg in enumerate(worldBins):
subprocess.call(['qtbz2', '-x'] + str(worldpkg + '.tbz2').split())
- CATEGORY = subprocess.check_output(
- ['qxpak', '-x', '-O'] + str(worldpkg + '.xpak').split() + ['CATEGORY'])
- # we extracted the categories, safe to delete
+ CATEGORY = subprocess.check_output(['qxpak', '-x', '-O'] + str(worldpkg + '.xpak').split() + ['CATEGORY'])
os.remove(str(worldpkg + '.xpak'))
if os.path.isdir(portageCache + CATEGORY.decode().strip()):
- shutil.move(str(worldpkg + '.tbz2'), os.path.join(portageCache +
- CATEGORY.decode().strip(), os.path.basename(str(worldpkg + '.tbz2'))))
+ shutil.move(str(worldpkg + '.tbz2'), os.path.join(portageCache + CATEGORY.decode().strip(), os.path.basename(str(worldpkg + '.tbz2'))))
else:
os.makedirs(portageCache + CATEGORY.decode().strip())
- shutil.move(str(worldpkg + '.tbz2'), os.path.join(portageCache +
- CATEGORY.decode().strip(), os.path.basename(str(worldpkg + '.tbz2'))))
+ shutil.move(str(worldpkg + '.tbz2'), os.path.join(portageCache + CATEGORY.decode().strip(), os.path.basename(str(worldpkg + '.tbz2'))))
if os.path.exists(str(worldpkg + '.tbz2')):
- # we moved the binaries in cache, safe to delete
os.remove(str(worldpkg + '.tbz2'))
- portageExec = subprocess.Popen(
- ['emerge', '-uDNq', '--backtrack=100', '--with-bdeps=y', '@world'], stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '-uDNq', '--backtrack=100', '--with-bdeps=y', '@world'], stdout=subprocess.PIPE)
+
atexit.register(portageKill, portageExec)
+
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
self.strReady.emit(portageOutput.rstrip())
+
portageExec.wait()
syncLocalDatabase()
self.finished.emit()
@@ -477,11 +463,13 @@ class MainWorker(QtCore.QObject):
@QtCore.pyqtSlot()
def cleanOrphans(self):
self.started.emit()
- portageExec = subprocess.Popen(
- ['emerge', '-cq'], stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '-cq'], stdout=subprocess.PIPE)
+
atexit.register(portageKill, portageExec)
+
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
self.strReady.emit(portageOutput.rstrip())
+
portageExec.wait()
syncLocalDatabase()
self.finished.emit()