also makes it clickable and shows verbose errors in a dialog.
From: "Brian C. Lane" bcl@redhat.com
Trying to display errors/warnings using gtk_call_once while the spoke is closed doesn't work. So instead cache them in self._error_msg and display them when refresh() is called. --- pyanaconda/ui/gui/spokes/source.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/source.py b/pyanaconda/ui/gui/spokes/source.py index d909ec9..45ef1c9 100644 --- a/pyanaconda/ui/gui/spokes/source.py +++ b/pyanaconda/ui/gui/spokes/source.py @@ -387,6 +387,7 @@ def __init__(self, *args, **kwargs): self._currentIsoFile = None self._ready = False self._error = False + self._error_msg = "" self._proxyUrl = "" self._proxyChange = False self._cdrom = None @@ -496,8 +497,8 @@ def _method_changed(self): (self.data.method.server, self.data.method.dir) = url.split(":", 2) except ValueError as e: log.error("ValueError: %s", e) - gtk_call_once(self.set_warning, _("Failed to set up installation source; check the repo url")) self._error = True + self._error_msg = _("Failed to set up installation source; check the repo url") return
self.data.method.opts = self.builder.get_object("nfsOptsEntry").get_text() or "" @@ -688,6 +689,7 @@ def _probing_storage(self): def _downloading_package_md(self): # Reset the error state from previous payloads self._error = False + self._error_msg = ""
hubQ.send_message(self.__class__.__name__, _(constants.PAYLOAD_STATUS_PACKAGE_MD))
@@ -702,9 +704,9 @@ 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): - gtk_call_once(self.set_warning, _("Failed to set up installation source; check the repo url")) + self._error_msg = _("Failed to set up installation source; check the repo url") else: - gtk_call_once(self.set_warning, _("Failed to set up installation source; check the repo url and proxy settings")) + 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): @@ -895,6 +897,9 @@ def refresh(self):
self.clear_info() self.set_warning(_("You need to configure the network to use a network installation source.")) + elif self._error: + self.clear_info() + self.set_error(self._error_msg)
def _setup_no_updates(self): """ Setup the state of the No Updates checkbox.
From: "Brian C. Lane" bcl@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)
anaconda-patches@lists.fedorahosted.org