mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Show a list of potentially affected add-ons when raising error
This commit is contained in:
parent
5deb905b27
commit
5bfdc740f5
1 changed files with 18 additions and 3 deletions
|
@ -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 <a href="https://help.ankiweb.net/discussions/add-ons/">
|
|||
add-ons section</a> of our support site.
|
||||
|
||||
<p>Debug info:</p>
|
||||
""")
|
||||
""")
|
||||
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 + "<div style='white-space: pre-wrap'>" + error + "</div>"
|
||||
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] = "<b>{}</b>".format(addons[0])
|
||||
return txt.format(", ".join(addons))
|
||||
|
||||
def _supportText(self):
|
||||
import platform
|
||||
from aqt.utils import versionWithBuild
|
||||
|
|
Loading…
Reference in a new issue