[master 2/2] Display verbose packaging errors to the user
bcl
installerbot-noreply at redhat.com
Thu Jul 16 19:27:06 UTC 2015
From: "Brian C. Lane" <bcl at redhat.com>
Sometimes packaging has more information about an error. These are
logged, but not all users know how to read the logs. This adds a
clickable info bar to the source spoke and storage for errors in the
payload.verbose_errors list.
Now when there is a problem fetching .treeinfo or fetching metadata the
exact error will be visible when the info bar is clicked.
---
pyanaconda/packaging/__init__.py | 5 +++++
pyanaconda/packaging/dnfpayload.py | 1 +
pyanaconda/ui/gui/spokes/source.glade | 1 +
pyanaconda/ui/gui/spokes/source.py | 26 ++++++++++++++++++++++++--
4 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index ada75ff..3e73d38 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -140,12 +140,16 @@ def __init__(self, data):
self.instclass = None
self.txID = None
+ # A list of verbose error strings from the subclass
+ self.verbose_errors = []
+
self._session = requests_session()
def setup(self, storage, instClass):
""" Do any payload-specific setup. """
self.storage = storage
self.instclass = instClass
+ self.verbose_errors = []
def unsetup(self):
""" Invalidate a previously setup paylaod. """
@@ -364,6 +368,7 @@ def _getTreeInfo(self, url, proxy_url, sslverify):
response = self._session.get("%s/treeinfo" % url, headers=headers, proxies=proxies, verify=sslverify)
except requests.exceptions.RequestException as e:
log.info("Error downloading treeinfo: %s", e)
+ self.verbose_errors.append(str(e))
response = None
if response:
diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py
index 818eac4..fcf715d 100644
--- a/pyanaconda/packaging/dnfpayload.py
+++ b/pyanaconda/packaging/dnfpayload.py
@@ -480,6 +480,7 @@ def _sync_metadata(self, dnf_repo):
id_ = dnf_repo.id
log.info('_sync_metadata: addon repo error: %s', e)
self.disableRepo(id_)
+ self.verbose_errors.append(str(e))
@property
def baseRepo(self):
diff --git a/pyanaconda/ui/gui/spokes/source.glade b/pyanaconda/ui/gui/spokes/source.glade
index 0b1045c..dd076a6 100644
--- a/pyanaconda/ui/gui/spokes/source.glade
+++ b/pyanaconda/ui/gui/spokes/source.glade
@@ -473,6 +473,7 @@
<property name="can_focus">False</property>
<property name="window_name" translatable="yes">INSTALLATION SOURCE</property>
<signal name="button-clicked" handler="on_back_clicked" swapped="no"/>
+ <signal name="info-bar-clicked" handler="on_info_bar_clicked" swapped="no"/>
<child internal-child="main_box">
<object class="GtkBox" id="AnacondaSpokeWindow-main_box1">
<property name="can_focus">False</property>
diff --git a/pyanaconda/ui/gui/spokes/source.py b/pyanaconda/ui/gui/spokes/source.py
index 45ef1c9..ce0975c 100644
--- a/pyanaconda/ui/gui/spokes/source.py
+++ b/pyanaconda/ui/gui/spokes/source.py
@@ -704,9 +704,16 @@ def _payload_error(self):
self._error = True
hubQ.send_message(self.__class__.__name__, payloadMgr.error)
if not (hasattr(self.data.method, "proxy") and self.data.method.proxy):
- self._error_msg = _("Failed to set up installation source; check the repo url")
+ if self.payload.verbose_errors:
+ self._error_msg = _('Failed to set up installation source; check the repo url. <a href="">Click for details.</a>')
+ else:
+ self._error_msg = _("Failed to set up installation source; check the repo url.")
else:
- self._error_msg = _("Failed to set up installation source; check the repo url and proxy settings")
+ if self.payload.verbose_errors:
+ self._error_msg = _('Failed to set up installation source; check the repo url and proxy settings. <a href="">Click for details.</a>')
+ else:
+ self._error_msg = _("Failed to set up installation source; check the repo url and proxy settings.")
+
hubQ.send_ready(self.__class__.__name__, False)
def _initialize(self):
@@ -1070,6 +1077,21 @@ def on_back_clicked(self, button):
self.clear_info()
NormalSpoke.on_back_clicked(self, button)
+ def on_info_bar_clicked(self, *args):
+ log.debug("info bar clicked: %s (%s)", self._error, args)
+ if not self.payload.verbose_errors:
+ return
+
+ dlg = Gtk.MessageDialog(flags=Gtk.DialogFlags.MODAL,
+ message_type=Gtk.MessageType.ERROR,
+ buttons=Gtk.ButtonsType.CLOSE,
+ message_format="\n".join(self.payload.verbose_errors))
+ dlg.set_decorated(False)
+
+ with self.main_window.enlightbox(dlg):
+ dlg.run()
+ dlg.destroy()
+
def on_chooser_clicked(self, button):
dialog = IsoChooser(self.data)
--
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/7394774feb067024f0f8f8ab027bca6809cfb0d1
More information about the anaconda-patches
mailing list