From 6e1996f701690377df5e302c646c18b41f9fa19c Mon Sep 17 00:00:00 2001 From: ijgnd Date: Mon, 3 Feb 2020 02:17:10 +0100 Subject: [PATCH] Extend Copy Debug Info --- qt/aqt/about.py | 46 ++++++++++++++++++++++++++++++++++++++++++++-- qt/aqt/utils.py | 6 ++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/qt/aqt/about.py b/qt/aqt/about.py index e4416148d..b3aa7dee9 100644 --- a/qt/aqt/about.py +++ b/qt/aqt/about.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import platform +import time import aqt.forms from anki.lang import _ @@ -32,10 +33,51 @@ def show(mw): # Copy debug info ###################################################################### + def addon_fmt(addmgr, a): + if a.installed_at: + t = time.strftime("%Y-%m-%dT%H:%M", time.localtime(a.installed_at)) + else: + t = "0" + if a.provided_name: + n = a.provided_name + else: + n = "''" + user = addmgr.getConfig(a.dir_name) + default = addmgr.addonConfigDefaults(a.dir_name) + if user == default: + confstat = "''" + else: + confstat = "mod" + return f"{n} ['{a.dir_name}', {t}, '{a.human_version}', {confstat}]" + def onCopy(): addmgr = mw.addonManager - addons = "\n".join(addmgr.annotatedName(d) for d in addmgr.allAddons()) - info = "\n".join((supportText(), "Add-ons:\n\n{}".format(addons))) + active = [] + activeids = [] + inactive = [] + for a in addmgr.all_addon_meta(): + if a.enabled: + active.append(addon_fmt(addmgr, a)) + if a.ankiweb_id(): + activeids.append(a.dir_name) + else: + inactive.append(addon_fmt(addmgr, a)) + newline = "\n" + info = f""" +{supportText()} + +===Add-ons (active)=== +(add-on provided name [Add-on folder, installed at, version, is config changed]) +{newline.join(sorted(active))} + +===Add-ons (active) Ankiweb-IDs=== +{" ".join(activeids)} + +===Add-ons (inactive)=== +(add-on provided name [Add-on folder, installed at, version, is config changed]) +{newline.join(sorted(inactive))} +""" + info = " " + " ".join(info.splitlines(True)) QApplication.clipboard().setText(info) tooltip(_("Copied to clipboard"), parent=dialog) diff --git a/qt/aqt/utils.py b/qt/aqt/utils.py index 9143636cd..318f48b07 100644 --- a/qt/aqt/utils.py +++ b/qt/aqt/utils.py @@ -685,6 +685,7 @@ def qtMenuShortcutWorkaround(qmenu): def supportText(): import platform + import time from aqt import mw if isWin: @@ -700,10 +701,14 @@ def supportText(): except: return "?" + lc = mw.pm.last_addon_update_check() + lcfmt = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(lc)) + return """\ Anki {} Python {} Qt {} PyQt {} Platform: {} Flags: frz={} ao={} sv={} +Add-ons, last update check: {} """.format( versionWithBuild(), platform.python_version(), @@ -713,6 +718,7 @@ Flags: frz={} ao={} sv={} getattr(sys, "frozen", False), mw.addonManager.dirty, schedVer(), + lcfmt, )