mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Extend Copy Debug Info
This commit is contained in:
parent
de9331a03e
commit
6e1996f701
2 changed files with 50 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# 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 platform
|
import platform
|
||||||
|
import time
|
||||||
|
|
||||||
import aqt.forms
|
import aqt.forms
|
||||||
from anki.lang import _
|
from anki.lang import _
|
||||||
|
@ -32,10 +33,51 @@ def show(mw):
|
||||||
|
|
||||||
# Copy debug info
|
# 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():
|
def onCopy():
|
||||||
addmgr = mw.addonManager
|
addmgr = mw.addonManager
|
||||||
addons = "\n".join(addmgr.annotatedName(d) for d in addmgr.allAddons())
|
active = []
|
||||||
info = "\n".join((supportText(), "Add-ons:\n\n{}".format(addons)))
|
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)
|
QApplication.clipboard().setText(info)
|
||||||
tooltip(_("Copied to clipboard"), parent=dialog)
|
tooltip(_("Copied to clipboard"), parent=dialog)
|
||||||
|
|
||||||
|
|
|
@ -685,6 +685,7 @@ def qtMenuShortcutWorkaround(qmenu):
|
||||||
|
|
||||||
def supportText():
|
def supportText():
|
||||||
import platform
|
import platform
|
||||||
|
import time
|
||||||
from aqt import mw
|
from aqt import mw
|
||||||
|
|
||||||
if isWin:
|
if isWin:
|
||||||
|
@ -700,10 +701,14 @@ def supportText():
|
||||||
except:
|
except:
|
||||||
return "?"
|
return "?"
|
||||||
|
|
||||||
|
lc = mw.pm.last_addon_update_check()
|
||||||
|
lcfmt = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(lc))
|
||||||
|
|
||||||
return """\
|
return """\
|
||||||
Anki {} Python {} Qt {} PyQt {}
|
Anki {} Python {} Qt {} PyQt {}
|
||||||
Platform: {}
|
Platform: {}
|
||||||
Flags: frz={} ao={} sv={}
|
Flags: frz={} ao={} sv={}
|
||||||
|
Add-ons, last update check: {}
|
||||||
""".format(
|
""".format(
|
||||||
versionWithBuild(),
|
versionWithBuild(),
|
||||||
platform.python_version(),
|
platform.python_version(),
|
||||||
|
@ -713,6 +718,7 @@ Flags: frz={} ao={} sv={}
|
||||||
getattr(sys, "frozen", False),
|
getattr(sys, "frozen", False),
|
||||||
mw.addonManager.dirty,
|
mw.addonManager.dirty,
|
||||||
schedVer(),
|
schedVer(),
|
||||||
|
lcfmt,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue