mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -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
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import sys, traceback
|
import sys, traceback
|
||||||
import html
|
import html
|
||||||
|
import re
|
||||||
|
|
||||||
from anki.lang import _
|
from anki.lang import _
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from aqt.utils import showText, showWarning
|
from aqt.utils import showText, showWarning
|
||||||
|
from aqt import mw
|
||||||
|
|
||||||
if not os.environ.get("DEBUG"):
|
if not os.environ.get("DEBUG"):
|
||||||
def excepthook(etype,val,tb):
|
def excepthook(etype,val,tb):
|
||||||
|
@ -124,14 +126,27 @@ add-ons section</a> of our support site.
|
||||||
""")
|
""")
|
||||||
if self.mw.addonManager.dirty:
|
if self.mw.addonManager.dirty:
|
||||||
txt = pluginText
|
txt = pluginText
|
||||||
|
error = self._supportText() + self._addonText(error) + "\n" + error
|
||||||
else:
|
else:
|
||||||
txt = stdText
|
txt = stdText
|
||||||
# show dialog
|
|
||||||
error = self._supportText() + "\n" + error
|
error = self._supportText() + "\n" + error
|
||||||
|
|
||||||
|
# show dialog
|
||||||
txt = txt + "<div style='white-space: pre-wrap'>" + error + "</div>"
|
txt = txt + "<div style='white-space: pre-wrap'>" + error + "</div>"
|
||||||
showText(txt, type="html", copyBtn=True)
|
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):
|
def _supportText(self):
|
||||||
import platform
|
import platform
|
||||||
from aqt.utils import versionWithBuild
|
from aqt.utils import versionWithBuild
|
||||||
|
|
Loading…
Reference in a new issue