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 }':
|
When loading '{ $name }':
|
||||||
{ $traceback }
|
{ $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
|
# Shown in the add-on configuration screen (Tools>Add-ons>Config), in the title bar
|
||||||
addons-config-window-title = Configure '{ $name }'
|
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 }.
|
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)
|
return os.path.join(root, module)
|
||||||
|
|
||||||
def loadAddons(self) -> None:
|
def loadAddons(self) -> None:
|
||||||
|
broken: list[str] = []
|
||||||
for addon in self.all_addon_meta():
|
for addon in self.all_addon_meta():
|
||||||
if not addon.enabled:
|
if not addon.enabled:
|
||||||
continue
|
continue
|
||||||
|
@ -240,18 +241,27 @@ class AddonManager:
|
||||||
except AbortAddonImport:
|
except AbortAddonImport:
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
error = html.escape(
|
self.toggleEnabled(addon.dir_name, enable=False)
|
||||||
tr.addons_failed_to_load(
|
name = html.escape(addon.human_name())
|
||||||
name=addon.human_name(),
|
page = addon.page()
|
||||||
traceback=traceback.format_exc(),
|
if page:
|
||||||
)
|
broken.append(f"<a href={page}>{name}</a>")
|
||||||
)
|
else:
|
||||||
txt = f"<h1>{tr.qt_misc_error()}</h1><div style='white-space: pre-wrap'>{error}</div>"
|
broken.append(name)
|
||||||
showText(
|
print(traceback.format_exc())
|
||||||
txt,
|
|
||||||
type="html",
|
if broken:
|
||||||
copyBtn=True,
|
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:
|
def onAddonsDialog(self) -> None:
|
||||||
aqt.dialogs.open("AddonsDialog", self)
|
aqt.dialogs.open("AddonsDialog", self)
|
||||||
|
|
Loading…
Reference in a new issue