From 5bfdc740f5162cefd30570c6b93aeaaedbc93087 Mon Sep 17 00:00:00 2001 From: Glutanimate Date: Sun, 17 Feb 2019 00:35:44 +0100 Subject: [PATCH] Show a list of potentially affected add-ons when raising error --- aqt/errors.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/aqt/errors.py b/aqt/errors.py index 6da93b8fd..699593552 100644 --- a/aqt/errors.py +++ b/aqt/errors.py @@ -3,10 +3,12 @@ # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import sys, traceback import html +import re from anki.lang import _ from aqt.qt import * from aqt.utils import showText, showWarning +from aqt import mw if not os.environ.get("DEBUG"): def excepthook(etype,val,tb): @@ -121,17 +123,30 @@ report the issue on the add-ons section of our support site.

Debug info:

-""") +""") if self.mw.addonManager.dirty: txt = pluginText + error = self._supportText() + self._addonText(error) + "\n" + error else: txt = stdText + error = self._supportText() + "\n" + error + # show dialog - error = self._supportText() + "\n" + error - txt = txt + "
" + error + "
" showText(txt, type="html", copyBtn=True) + def _addonText(self, error): + matches = re.findall(r"addons21/(.*?)/", error) + if not matches: + return "" + # reverse to list most likely suspect first, dict to deduplicate: + addons = [mw.addonManager.addonName(i) for i in + dict.fromkeys(reversed(matches))] + txt = _("""Potentially affected add-ons: {}\n""") + # highlight importance of first add-on: + addons[0] = "{}".format(addons[0]) + return txt.format(", ".join(addons)) + def _supportText(self): import platform from aqt.utils import versionWithBuild