mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
Display all startup errors at once, and automatically disable add-ons
https://forums.ankiweb.net/t/anki-23-10-beta-5/35677/48
This commit is contained in:
parent
2d176d8c35
commit
d7a0bc0d42
2 changed files with 26 additions and 12 deletions
|
@ -4,6 +4,10 @@ addons-failed-to-load =
|
|||
|
||||
When loading '{ $name }':
|
||||
{ $traceback }
|
||||
addons-failed-to-load2 =
|
||||
The following add-ons failed to load, so they have been disabled:
|
||||
|
||||
{ $addons }
|
||||
# Shown in the add-on configuration screen (Tools>Add-ons>Config), in the title bar
|
||||
addons-config-window-title = Configure '{ $name }'
|
||||
addons-config-validation-error = There was a problem with the provided configuration: { $problem }, at path { $path }, against schema { $schema }.
|
||||
|
|
|
@ -229,6 +229,7 @@ class AddonManager:
|
|||
return os.path.join(root, module)
|
||||
|
||||
def loadAddons(self) -> None:
|
||||
broken: list[str] = []
|
||||
for addon in self.all_addon_meta():
|
||||
if not addon.enabled:
|
||||
continue
|
||||
|
@ -240,18 +241,27 @@ class AddonManager:
|
|||
except AbortAddonImport:
|
||||
pass
|
||||
except:
|
||||
error = html.escape(
|
||||
tr.addons_failed_to_load(
|
||||
name=addon.human_name(),
|
||||
traceback=traceback.format_exc(),
|
||||
)
|
||||
)
|
||||
txt = f"<h1>{tr.qt_misc_error()}</h1><div style='white-space: pre-wrap'>{error}</div>"
|
||||
showText(
|
||||
txt,
|
||||
type="html",
|
||||
copyBtn=True,
|
||||
)
|
||||
self.toggleEnabled(addon.dir_name, enable=False)
|
||||
name = html.escape(addon.human_name())
|
||||
page = addon.page()
|
||||
if page:
|
||||
broken.append(f"<a href={page}>{name}</a>")
|
||||
else:
|
||||
broken.append(name)
|
||||
print(traceback.format_exc())
|
||||
|
||||
if broken:
|
||||
addons = "\n\n- " + "\n- ".join(broken)
|
||||
addons = f"<div style='white-space: pre-wrap'>{addons}</div>"
|
||||
error = tr.addons_failed_to_load2(
|
||||
addons=addons,
|
||||
)
|
||||
txt = f"<h1>{tr.qt_misc_error()}</h1>{error}"
|
||||
showText(
|
||||
txt,
|
||||
type="html",
|
||||
copyBtn=True,
|
||||
)
|
||||
|
||||
def onAddonsDialog(self) -> None:
|
||||
aqt.dialogs.open("AddonsDialog", self)
|
||||
|
|
Loading…
Reference in a new issue