summaryrefslogtreecommitdiff
path: root/src/frontend/gui
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2018-01-03 02:21:09 +0000
committerV3n3RiX <venerix@redcorelinux.org>2018-01-03 02:21:09 +0000
commit514c4d813ee988cce920318e2d4d3c5130d0936c (patch)
treec77cd5c02bf94923c997b8dd73cb8268ced7460c /src/frontend/gui
parentc43519c58a8f0cf496098c4d3b8deb05df919d01 (diff)
autopep8
Diffstat (limited to 'src/frontend/gui')
-rwxr-xr-xsrc/frontend/gui/sisyphus-gui.py89
1 files changed, 55 insertions, 34 deletions
diff --git a/src/frontend/gui/sisyphus-gui.py b/src/frontend/gui/sisyphus-gui.py
index 13a90f0..f285f1c 100755
--- a/src/frontend/gui/sisyphus-gui.py
+++ b/src/frontend/gui/sisyphus-gui.py
@@ -1,42 +1,47 @@
#!/usr/bin/python3
-import sys, subprocess, sqlite3, io, atexit
+import sys
+import subprocess
+import sqlite3
+import io
+import atexit
from collections import OrderedDict
from PyQt5 import QtCore, QtGui, QtWidgets, uic
from libsisyphus import *
+
class Sisyphus(QtWidgets.QMainWindow):
def __init__(self):
super(Sisyphus, self).__init__()
uic.loadUi('ui/sisyphus-gui.ui', self)
self.centerOnScreen()
self.show()
-
- self.SEARCHFIELDS = OrderedDict ([
+
+ self.SEARCHFIELDS = OrderedDict([
('Search by Name', 'pn'),
('Search by Category', 'cat'),
('Search by Description', 'descr')
- ])
+ ])
self.selectfield.addItems(self.SEARCHFIELDS.keys())
self.selectfield.setCurrentText('Search by Name')
Sisyphus.SEARCHFIELD = self.SEARCHFIELDS['Search by Name']
self.selectfield.currentIndexChanged.connect(self.setSearchField)
-
- self.SEARCHFILTERS = OrderedDict ([
+
+ self.SEARCHFILTERS = OrderedDict([
('All Packages', 'all'),
('Installed Packages', 'instaled'),
('Installable Packages', 'installable'),
('Safely Removable Packages', 'removable'),
('Upgradable/Rebuilt Packages', 'upgradable')
- ])
+ ])
Sisyphus.SEARCHFILTER = self.SEARCHFILTERS['All Packages']
self.selectfilter.addItems(self.SEARCHFILTERS.keys())
self.selectfilter.setCurrentText('All Packages')
self.selectfilter.currentIndexChanged.connect(self.setSearchFilter)
-
+
Sisyphus.SEARCHTERM = "'%%'"
self.database.clicked.connect(self.rowClicked)
-
+
self.input.textEdited.connect(self.filterDatabase)
self.updateWorker = UpdateWorker()
@@ -64,7 +69,8 @@ class Sisyphus(QtWidgets.QMainWindow):
self.uninstallWorker.started.connect(self.showProgressBar)
self.uninstallWorker.strReady.connect(self.updateStatusBar)
self.uninstallWorker.finished.connect(self.uninstallThread.quit)
- self.uninstallThread.started.connect(self.uninstallWorker.startUninstall)
+ self.uninstallThread.started.connect(
+ self.uninstallWorker.startUninstall)
self.uninstallThread.finished.connect(self.jobDone)
self.upgrade.clicked.connect(self.systemUpgrade)
@@ -91,32 +97,36 @@ class Sisyphus(QtWidgets.QMainWindow):
self.progress.hide()
self.abort.clicked.connect(self.sisyphusExit)
-
+
def centerOnScreen(self):
resolution = QtWidgets.QDesktopWidget().screenGeometry()
self.move((resolution.width() / 2) - (self.frameSize().width() / 2),
- (resolution.height() / 2) - (self.frameSize().height() / 2))
-
+ (resolution.height() / 2) - (self.frameSize().height() / 2))
+
def rowClicked(self):
- Sisyphus.PKGSELECTED = len(self.database.selectionModel().selectedRows())
+ Sisyphus.PKGSELECTED = len(
+ self.database.selectionModel().selectedRows())
self.showPackageCount()
def showPackageCount(self):
- self.statusBar().showMessage("Found: %d, Selected: %d packages" %(Sisyphus.PKGCOUNT, Sisyphus.PKGSELECTED))
+ self.statusBar().showMessage("Found: %d, Selected: %d packages" %
+ (Sisyphus.PKGCOUNT, Sisyphus.PKGSELECTED))
def setSearchField(self):
- Sisyphus.SEARCHFIELD = self.SEARCHFIELDS[self.selectfield.currentText()]
+ Sisyphus.SEARCHFIELD = self.SEARCHFIELDS[self.selectfield.currentText(
+ )]
self.loadDatabase()
-
+
def setSearchFilter(self):
- Sisyphus.SEARCHFILTER = self.SEARCHFILTERS[self.selectfilter.currentText()]
+ Sisyphus.SEARCHFILTER = self.SEARCHFILTERS[self.selectfilter.currentText(
+ )]
Sisyphus.SELECT = self.selectfilter.currentText()
self.loadDatabase()
def loadDatabase(self):
FILTEROUT = "AND cat NOT LIKE 'virtual'"
- self.SELECTS = OrderedDict ([
- ('all','''SELECT
+ self.SELECTS = OrderedDict([
+ ('all', '''SELECT
i.category AS cat,
i.name as pn,
IFNULL(a.version, 'None') AS av,
@@ -140,7 +150,7 @@ class Sisyphus(QtWidgets.QMainWindow):
AND a.slot = i.slot
WHERE %s LIKE %s %s
''' % (Sisyphus.SEARCHFIELD, Sisyphus.SEARCHTERM, FILTEROUT, Sisyphus.SEARCHFIELD, Sisyphus.SEARCHTERM, FILTEROUT)),
- ('instaled','''SELECT
+ ('instaled', '''SELECT
i.category AS cat,
i.name AS pn,
a.version AS av,
@@ -153,7 +163,7 @@ class Sisyphus(QtWidgets.QMainWindow):
AND i.slot = a.slot
WHERE %s LIKE %s %s
''' % (Sisyphus.SEARCHFIELD, Sisyphus.SEARCHTERM, FILTEROUT)),
- ('installable','''SELECT
+ ('installable', '''SELECT
a.category AS cat,
a.name AS pn,
a.version AS av,
@@ -167,7 +177,7 @@ class Sisyphus(QtWidgets.QMainWindow):
WHERE %s LIKE %s %s
AND iv IS NULL
''' % (Sisyphus.SEARCHFIELD, Sisyphus.SEARCHTERM, FILTEROUT)),
- ('removable','''SELECT
+ ('removable', '''SELECT
i.category AS cat,
i.name AS pn,
a.version AS av,
@@ -184,7 +194,7 @@ class Sisyphus(QtWidgets.QMainWindow):
AND i.slot = rm.slot
WHERE %s LIKE %s %s
''' % (Sisyphus.SEARCHFIELD, Sisyphus.SEARCHTERM, FILTEROUT)),
- ('upgradable','''SELECT
+ ('upgradable', '''SELECT
i.category AS cat,
i.name AS pn,
CASE WHEN a.version = i.version THEN 'Rebuilt' ELSE a.version END AS av,
@@ -198,19 +208,20 @@ class Sisyphus(QtWidgets.QMainWindow):
WHERE %s LIKE %s %s
AND a.timestamp > i.timestamp
''' % (Sisyphus.SEARCHFIELD, Sisyphus.SEARCHTERM, FILTEROUT)),
- ])
+ ])
with sqlite3.connect(sisyphus_database_path) as db:
- cursor=db.cursor()
+ cursor = db.cursor()
cursor.execute('%s' % (self.SELECTS[Sisyphus.SEARCHFILTER]))
rows = cursor.fetchall()
Sisyphus.PKGCOUNT = len(rows)
Sisyphus.PKGSELECTED = 0
model = QtGui.QStandardItemModel(len(rows), 5)
- model.setHorizontalHeaderLabels(['Category', 'Name', 'Available Version', 'Installed Version', 'Description'])
+ model.setHorizontalHeaderLabels(
+ ['Category', 'Name', 'Available Version', 'Installed Version', 'Description'])
for row in rows:
indx = rows.index(row)
for column in range(0, 5):
- item = QtGui.QStandardItem("%s"%(row[column]))
+ item = QtGui.QStandardItem("%s" % (row[column]))
model.setItem(indx, column, item)
self.database.setModel(model)
self.showPackageCount()
@@ -261,11 +272,11 @@ class Sisyphus(QtWidgets.QMainWindow):
def showProgressBar(self):
self.hideButtons()
- self.progress.setRange(0,0)
+ self.progress.setRange(0, 0)
self.progress.show()
def hideProgressBar(self):
- self.progress.setRange(0,1)
+ self.progress.setRange(0, 1)
self.progress.setValue(1)
self.progress.hide()
self.showButtons()
@@ -290,6 +301,7 @@ class Sisyphus(QtWidgets.QMainWindow):
def sisyphusExit(self):
self.close()
+
class UpdateWorker(QtCore.QObject):
started = QtCore.pyqtSignal()
finished = QtCore.pyqtSignal()
@@ -300,6 +312,7 @@ class UpdateWorker(QtCore.QObject):
sisyphus_pkg_system_update()
self.finished.emit()
+
class InstallWorker(QtCore.QObject):
started = QtCore.pyqtSignal()
finished = QtCore.pyqtSignal()
@@ -311,7 +324,8 @@ class InstallWorker(QtCore.QObject):
PKGLIST = Sisyphus.PKGLIST
redcore_sync()
generate_sisyphus_local_packages_table_csv_pre()
- portage_call = subprocess.Popen(['emerge', '-q'] + PKGLIST, stdout=subprocess.PIPE)
+ portage_call = subprocess.Popen(
+ ['emerge', '-q'] + PKGLIST, stdout=subprocess.PIPE)
atexit.register(kill_bg_portage, portage_call)
for portage_output in io.TextIOWrapper(portage_call.stdout, encoding="utf-8"):
self.strReady.emit(portage_output.rstrip())
@@ -319,6 +333,7 @@ class InstallWorker(QtCore.QObject):
sync_sisyphus_local_packages_table_csv()
self.finished.emit()
+
class UninstallWorker(QtCore.QObject):
started = QtCore.pyqtSignal()
finished = QtCore.pyqtSignal()
@@ -330,7 +345,8 @@ class UninstallWorker(QtCore.QObject):
PKGLIST = Sisyphus.PKGLIST
redcore_sync()
generate_sisyphus_local_packages_table_csv_pre()
- portage_call = subprocess.Popen(['emerge', '--depclean', '-q'] + PKGLIST, stdout=subprocess.PIPE)
+ portage_call = subprocess.Popen(
+ ['emerge', '--depclean', '-q'] + PKGLIST, stdout=subprocess.PIPE)
atexit.register(kill_bg_portage, portage_call)
for portage_output in io.TextIOWrapper(portage_call.stdout, encoding="utf-8"):
self.strReady.emit(portage_output.rstrip())
@@ -338,6 +354,7 @@ class UninstallWorker(QtCore.QObject):
sync_sisyphus_local_packages_table_csv()
self.finished.emit()
+
class UpgradeWorker(QtCore.QObject):
started = QtCore.pyqtSignal()
finished = QtCore.pyqtSignal()
@@ -348,7 +365,8 @@ class UpgradeWorker(QtCore.QObject):
self.started.emit()
redcore_sync()
generate_sisyphus_local_packages_table_csv_pre()
- portage_call = subprocess.Popen(['emerge', '-uDNq', '--backtrack=100', '--with-bdeps=y', '@world'], stdout=subprocess.PIPE)
+ portage_call = subprocess.Popen(
+ ['emerge', '-uDNq', '--backtrack=100', '--with-bdeps=y', '@world'], stdout=subprocess.PIPE)
atexit.register(kill_bg_portage, portage_call)
for portage_output in io.TextIOWrapper(portage_call.stdout, encoding="utf-8"):
self.strReady.emit(portage_output.rstrip())
@@ -356,6 +374,7 @@ class UpgradeWorker(QtCore.QObject):
sync_sisyphus_local_packages_table_csv()
self.finished.emit()
+
class OrphansWorker(QtCore.QObject):
started = QtCore.pyqtSignal()
finished = QtCore.pyqtSignal()
@@ -366,7 +385,8 @@ class OrphansWorker(QtCore.QObject):
self.started.emit()
redcore_sync()
generate_sisyphus_local_packages_table_csv_pre()
- portage_call = subprocess.Popen(['emerge', '--depclean', '-q'], stdout=subprocess.PIPE)
+ portage_call = subprocess.Popen(
+ ['emerge', '--depclean', '-q'], stdout=subprocess.PIPE)
atexit.register(kill_bg_portage, portage_call)
for portage_output in io.TextIOWrapper(portage_call.stdout, encoding="utf-8"):
self.strReady.emit(portage_output.rstrip())
@@ -374,6 +394,7 @@ class OrphansWorker(QtCore.QObject):
sync_sisyphus_local_packages_table_csv()
self.finished.emit()
+
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
window = Sisyphus()