summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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"):