summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2023-11-26 18:40:01 +0100
committerPapoteur <papoteur@mageia.org>2023-11-26 18:40:01 +0100
commitffce8fe1ae0eab4f8bcd560ce44a1c94ac5d94fb (patch)
tree413e2a1e6b64557a6f6eb24453a8733dd0d44b0e
parent59d3d144ba3345a34232f5b63d031f10de723598 (diff)
downloadmga-advisor-ffce8fe1ae0eab4f8bcd560ce44a1c94ac5d94fb.tar
mga-advisor-ffce8fe1ae0eab4f8bcd560ce44a1c94ac5d94fb.tar.gz
mga-advisor-ffce8fe1ae0eab4f8bcd560ce44a1c94ac5d94fb.tar.bz2
mga-advisor-ffce8fe1ae0eab4f8bcd560ce44a1c94ac5d94fb.tar.xz
mga-advisor-ffce8fe1ae0eab4f8bcd560ce44a1c94ac5d94fb.zip
Add status line at bottom of the UI
Manage Busy cursor when retrieving info Inform that the info is not retrieved (bad number, server not available) Ordering the output in the order we specified Fix src, sve and ref outputs when there is only one
-rw-r--r--form.ui7
-rw-r--r--mga-advisor.py54
2 files changed, 37 insertions, 24 deletions
diff --git a/form.ui b/form.ui
index 8bb09f9..29e1a7b 100644
--- a/form.ui
+++ b/form.ui
@@ -220,6 +220,13 @@
</layout>
</item>
<item>
+ <widget class="QLabel" name="status">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPushButton" name="cancel_pb">
diff --git a/mga-advisor.py b/mga-advisor.py
index 6f720eb..7810287 100644
--- a/mga-advisor.py
+++ b/mga-advisor.py
@@ -19,7 +19,8 @@ from PySide6.QtWidgets import (
QComboBox,
QTextEdit,
)
-from PySide6.QtCore import QFile, QDate, QDir
+from PySide6.QtGui import QCursor
+from PySide6.QtCore import QFile, QDate, QDir, Qt, QTimer
from PySide6.QtUiTools import QUiLoader
BASE_URL = "https://bugs.mageia.org/rest/bug/"
@@ -91,13 +92,14 @@ class Widget(QWidget):
Retrieve CVEs, URLs and Source package name from the bug report given by its number
"""
if self.ui.bug_le.text() == "":
- mb = QMessageBox("Provide a bug number first")
+ mb = QMessageBox(QMessageBox.Warning, "Retrieve info", "Provide a bug number first", QMessageBox.Ok)
mb.exec()
return
+ QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
url = os.path.join(BASE_URL, self.ui.bug_le.text()) + "?include_fields=cf_rpmpkg,cf_cve,url"
headers = {'Accept': 'application/json'}
r = requests.get(url, headers=headers)
- if r.json()["faults"] == []:
+ if r.status_code == 200 and r.json()["faults"] == []:
for pkg in re.split(';|,| ', r.json()['bugs'][0]['cf_rpmpkg']):
pkg = pkg.strip()
if pkg == "":
@@ -126,6 +128,13 @@ class Widget(QWidget):
url = url.strip()
if url != "":
self.ui.list_ref.addItem(url)
+ else:
+ self.ui.status.setText("No info retreived")
+ QTimer.singleShot(5000, self.clean_status)
+ QApplication.restoreOverrideCursor()
+
+ def clean_status(self):
+ self.ui.status.setText("")
def add_src(self):
dl = SrcDialog()
@@ -159,41 +168,38 @@ class Widget(QWidget):
self.ui.list_cve.takeItem(self.ui.list_cve.currentRow())
def adv_text(self):
- data = {}
+ data = dict()
if self.ui.bugfix_rb.isEnabled():
data['type'] = 'bugfix'
if self.ui.security_rb.isEnabled():
data['type'] = 'security'
- if len(self.ui.description_te.toPlainText()) != 0:
- data['description'] = self.ui.description_te.toPlainText()
if self.ui.subject_le.text() != "":
data['subject'] = self.sanitize_line(self.ui.subject_le.text())
cves = []
- n = 0
- for n in range(0, self.ui.list_cve.count()):
- cves.append(self.ui.list_cve.item(n).text())
- if n != 0:
+ if self.ui.list_cve.count() != 0:
+ for n in range(0, self.ui.list_cve.count()):
+ cves.append(self.ui.list_cve.item(n).text())
data['CVE'] = cves
srcs = {}
- n = 0
- for n in range(0, self.ui.list_src.count()):
- release, repo, name = self.ui.list_src.item(n).text().split(" ")
- if not release in srcs.keys():
- srcs[release] = {}
- srcs[release][repo] = []
- else:
- if not repo in srcs[release].keys():
+ if self.ui.list_src.count() != 0:
+ for n in range(0, self.ui.list_src.count()):
+ release, repo, name = self.ui.list_src.item(n).text().split(" ")
+ if not release in srcs.keys():
+ srcs[release] = {}
srcs[release][repo] = []
+ else:
+ if not repo in srcs[release].keys():
+ srcs[release][repo] = []
srcs[release][repo].append(self.sanitize_line(name))
- if n != 0:
data['src'] = srcs
+ if len(self.ui.description_te.toPlainText()) != 0:
+ data['description'] = self.ui.description_te.toPlainText()
refs = []
- n = 0
- for n in range(0, self.ui.list_ref.count()):
- refs.append(self.ui.list_ref.item(n).text())
- if n != 0:
+ if self.ui.list_ref.count():
+ for n in range(0, self.ui.list_ref.count()):
+ refs.append(self.ui.list_ref.item(n).text())
data['references'] = refs
- return yaml.dump(data, default_flow_style=False, width=75)
+ return yaml.dump(data, default_flow_style=False, sort_keys=False, width=75)
def export(self):
if QDir().mkpath(QDir().homePath() + "/mageia-advisories/advisories"):