def _data(self): d = {"ver": versionWithBuild(), "os": platDesc(), "id": self.config['id'], "lm": self.config['lastMsg'], "crt": self.config['created']} return d
def supportText(): import platform from aqt import mw if isWin: platname = "Windows " + platform.win32_ver()[0] elif isMac: platname = "Mac " + platform.mac_ver()[0] else: platname = "Linux" def schedVer(): try: return mw.col.schedVer() except: return "?" return """\ Anki {} Python {} Qt {} PyQt {} Platform: {} Flags: frz={} ao={} sv={} """.format(versionWithBuild(), platform.python_version(), QT_VERSION_STR, PYQT_VERSION_STR, platname, getattr(sys, "frozen", False), mw.addonManager.dirty, schedVer())
def _data(self) -> Dict[str, Any]: return { "ver": versionWithBuild(), "os": platDesc(), "id": self.config["id"], "lm": self.config["lastMsg"], "crt": self.config["created"], }
def _data(self): d = { "ver": versionWithBuild(), "os": platDesc(), "id": self.config["id"], "lm": self.config["lastMsg"], "crt": self.config["created"], } return d
def meta(self): self.postVars = dict( k=self.hkey, s=self.skey, ) ret = self.req( "meta", io.BytesIO(json.dumps(dict( v=SYNC_VER, cv="ankidesktop,%s,%s"%(versionWithBuild(), platDesc()))).encode("utf8")), badAuthRaises=False) if not ret: # invalid auth return return json.loads(ret.decode("utf8"))
def meta(self): """ Ask the server for an object which should contain """ self.postVars = dict( k=self.hkey, s=self.skey, ) d = dict(v=SYNC_VER, cv="ankidesktop,%s,%s"%(versionWithBuild(), platDesc())) ret = self.req( "meta", io.BytesIO(json.dumps(d).encode("utf8")), badAuthRaises=False) if not ret: # invalid auth return return json.loads(ret.decode("utf8"))
def supportText() -> str: import platform import time from aqt import mw if isWin: platname = f"Windows {platform.win32_ver()[0]}" elif isMac: platname = f"Mac {platform.mac_ver()[0]}" else: platname = "Linux" def schedVer() -> str: try: if mw.col.v3_scheduler(): return "3" else: return str(mw.col.sched_ver()) 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(), QT_VERSION_STR, PYQT_VERSION_STR, platname, getattr(sys, "frozen", False), mw.addonManager.dirty, schedVer(), lcfmt, )
def anki(self) -> dict: import platform import sys import locale from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR from anki.utils import versionWithBuild from anki.utils import isWin, isMac if isWin: platname = "Windows " + platform.win32_ver()[0] elif isMac: platname = "Mac " + platform.mac_ver()[0] else: platname = "Linux" def schedVer() -> str: try: return self._mainWindow.col.schedVer() except: return "?" return { "version": versionWithBuild(), "python": platform.python_version(), "qt": QT_VERSION_STR, "pyqt": PYQT_VERSION_STR, "platform": platname, "frozen": getattr(sys, "frozen", False), # source build or binary build? "addonsLoaded": self._mainWindow.addonManager.dirty, "scheduler": schedVer(), "env": self._getEnvironment(self._anki_env), "locale": locale.getlocale(), "cacert": certifi.where(), "sslVersion": ssl.OPENSSL_VERSION, }
def show(mw): dialog = ClosableQDialog(mw) dialog.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore mw.setupDialogGC(dialog) abt = aqt.forms.about.Ui_About() abt.setupUi(dialog) # Copy debug info ###################################################################### def addon_fmt(addmgr: AddonManager, addon: AddonMeta) -> str: if addon.installed_at: installed = time.strftime("%Y-%m-%dT%H:%M", time.localtime(addon.installed_at)) else: installed = "0" if addon.provided_name: name = addon.provided_name else: name = "''" user = addmgr.getConfig(addon.dir_name) default = addmgr.addonConfigDefaults(addon.dir_name) if user == default: modified = "''" else: modified = "mod" return f"{name} ['{addon.dir_name}', {installed}, '{addon.human_version}', {modified}]" def onCopy(): addmgr = mw.addonManager active = [] activeids = [] inactive = [] for addon in addmgr.all_addon_meta(): if addon.enabled: active.append(addon_fmt(addmgr, addon)) if addon.ankiweb_id(): activeids.append(addon.dir_name) else: inactive.append(addon_fmt(addmgr, addon)) 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))} ===IDs of active AnkiWeb add-ons=== {" ".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(tr(TR.ABOUT_COPIED_TO_CLIPBOARD), parent=dialog) btn = QPushButton(tr(TR.ABOUT_COPY_DEBUG_INFO)) qconnect(btn.clicked, onCopy) abt.buttonBox.addButton(btn, QDialogButtonBox.ActionRole) abt.buttonBox.button(QDialogButtonBox.Ok).setFocus() # WebView contents ###################################################################### abouttext = "<center><img src='/_anki/imgs/anki-logo-thin.png'></center>" abouttext += "<p>" + tr(TR.ABOUT_ANKI_IS_A_FRIENDLY_INTELLIGENT_SPACED) abouttext += "<p>" + tr(TR.ABOUT_ANKI_IS_LICENSED_UNDER_THE_AGPL3) abouttext += "<p>" + tr(TR.ABOUT_VERSION, val=versionWithBuild()) + "<br>" abouttext += ("Python %s Qt %s PyQt %s<br>") % ( platform.python_version(), QT_VERSION_STR, PYQT_VERSION_STR, ) abouttext += (without_unicode_isolation( tr(TR.ABOUT_VISIT_WEBSITE, val=aqt.appWebsite)) + "</span>") # automatically sorted; add new lines at the end allusers = sorted(( "Aaron Harsh", "Alex Fraser", "Andreas Klauer", "Andrew Wright", "Aristotelis P.", "Bernhard Ibertsberger", "C. van Rooyen", "Charlene Barina", "Christian Krause", "Christian Rusche", "Dave Druelinger", "David Smith", "Dmitry Mikheev", "Dotan Cohen", "Emilio Wuerges", "Emmanuel Jarri", "Frank Harper", "Gregor Skumavc", "Guillem Palau Salvà", "H. Mijail", "Henrik Enggaard Hansen", "Houssam Salem", "Ian Lewis", "Immanuel Asmus", "Iroiro", "Jarvik7", "Jin Eun-Deok", "Jo Nakashima", "Johanna Lindh", "Joseph Lorimer", "Julien Baley", "Jussi Määttä", "Kieran Clancy", "LaC", "Laurent Steffan", "Luca Ban", "Luciano Esposito", "Marco Giancotti", "Marcus Rubeus", "Mari Egami", "Mark Wilbur", "Matthew Duggan", "Matthew Holtz", "Meelis Vasser", "Michael Jürges", "Michael Keppler", "Michael Montague", "Michael Penkov", "Michal Čadil", "Morteza Salehi", "Nathanael Law", "Nguyễn Hào Khôi", "Nick Cook", "Niklas Laxström", "Norbert Nagold", "Ole Guldberg", "Pcsl88", "Petr Michalec", "Piotr Kubowicz", "Richard Colley", "Roland Sieker", "Samson Melamed", "Silja Ijas", "Snezana Lukic", "Soren Bjornstad", "Stefaan De Pooter", "Susanna Björverud", "Sylvain Durand", "Tacutu", "Timm Preetz", "Timo Paulssen", "Ursus", "Victor Suba", "Volker Jansen", "Volodymyr Goncharenko", "Xtru", "Ádám Szegi", "赵金鹏", "黃文龍", "David Bailey", "Arman High", "Arthur Milchior", "Rai (Michael Pokorny)", "AMBOSS MD Inc.", "Erez Volk", "Tobias Predel", "Thomas Kahn", "zjosua", "Ijgnd", "Evandro Coan", "Alan Du", "ANH", "Junseo Park", "Gustavo Costa", "余时行", "叶峻峣", )) abouttext += "<p>" + tr(TR.ABOUT_WRITTEN_BY_DAMIEN_ELMES_WITH_PATCHES, cont=", ".join(allusers)) abouttext += "<p>" + tr(TR.ABOUT_IF_YOU_HAVE_CONTRIBUTED_AND_ARE) abouttext += "<p>" + tr(TR.ABOUT_A_BIG_THANKS_TO_ALL_THE) abt.label.setMinimumWidth(800) abt.label.setMinimumHeight(600) dialog.show() abt.label.stdHtml(abouttext, js=[]) return dialog
def show(mw): dialog = ClosableQDialog(mw) mw.setupDialogGC(dialog) abt = aqt.forms.about.Ui_About() abt.setupUi(dialog) # Copy debug info ###################################################################### 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))) QApplication.clipboard().setText(info) tooltip(_("Copied to clipboard"), parent=dialog) btn = QPushButton(_("Copy Debug Info")) btn.clicked.connect(onCopy) abt.buttonBox.addButton(btn, QDialogButtonBox.ActionRole) abt.buttonBox.button(QDialogButtonBox.Ok).setFocus() # WebView contents ###################################################################### abouttext = "<center><img src='/_anki/imgs/anki-logo-thin.png'></center>" abouttext += "<p>" + _( "Anki is a friendly, intelligent spaced learning \ system. It's free and open source." ) abouttext += "<p>" + _( "Anki is licensed under the AGPL3 license. Please see " "the license file in the source distribution for more information." ) abouttext += "<p>" + _("Version %s") % versionWithBuild() + "<br>" abouttext += ("Python %s Qt %s PyQt %s<br>") % ( platform.python_version(), QT_VERSION_STR, PYQT_VERSION_STR, ) abouttext += (_("<a href='%s'>Visit website</a>") % aqt.appWebsite) + "</span>" # automatically sorted; add new lines at the end allusers = sorted( ( "Aaron Harsh", "Alex Fraser", "Andreas Klauer", "Andrew Wright", "Aristotelis P.", "Bernhard Ibertsberger", "C. van Rooyen", "Charlene Barina", "Christian Krause", "Christian Rusche", "Dave Druelinger", "David Smith", "Dmitry Mikheev", "Dotan Cohen", "Emilio Wuerges", "Emmanuel Jarri", "Frank Harper", "Gregor Skumavc", "Guillem Palau Salvà", "H. Mijail", "Henrik Enggaard Hansen", "Houssam Salem", "Ian Lewis", "Immanuel Asmus", "Iroiro", "Jarvik7", "Jin Eun-Deok", "Jo Nakashima", "Johanna Lindh", "Joseph Lorimer", "Julien Baley", "Jussi Määttä", "Kieran Clancy", "LaC", "Laurent Steffan", "Luca Ban", "Luciano Esposito", "Marco Giancotti", "Marcus Rubeus", "Mari Egami", "Mark Wilbur", "Matthew Duggan", "Matthew Holtz", "Meelis Vasser", "Michael Jürges", "Michael Keppler", "Michael Montague", "Michael Penkov", "Michal Čadil", "Morteza Salehi", "Nathanael Law", "Nguyễn Hào Khôi", "Nick Cook", "Niklas Laxström", "Norbert Nagold", "Ole Guldberg", "Pcsl88", "Petr Michalec", "Piotr Kubowicz", "Richard Colley", "Roland Sieker", "Samson Melamed", "Silja Ijas", "Snezana Lukic", "Soren Bjornstad", "Stefaan De Pooter", "Susanna Björverud", "Sylvain Durand", "Tacutu", "Timm Preetz", "Timo Paulssen", "Ursus", "Victor Suba", "Volker Jansen", "Volodymyr Goncharenko", "Xtru", "Ádám Szegi", "赵金鹏", "黃文龍", "David Bailey", "Arman High", "Arthur Milchior", "Rai (Michael Pokorny)", ) ) abouttext += ( "<p>" + _( "Written by Damien Elmes, with patches, translation,\ testing and design from:<p>%(cont)s" ) % {"cont": ", ".join(allusers)} ) abouttext += "<p>" + _( "If you have contributed and are not on this list, \ please get in touch." ) abouttext += "<p>" + _( "A big thanks to all the people who have provided \ suggestions, bug reports and donations." ) abt.label.setMinimumWidth(800) abt.label.setMinimumHeight(600) dialog.show() abt.label.stdHtml(abouttext, js=" ") return dialog
def show(mw): dialog = ClosableQDialog(mw) mw.setupDialogGC(dialog) abt = aqt.forms.about.Ui_About() abt.setupUi(dialog) # Copy debug info ###################################################################### def addon_fmt(addmgr: AddonManager, addon: AddonMeta) -> str: if addon.installed_at: installed = time.strftime("%Y-%m-%dT%H:%M", time.localtime(addon.installed_at)) else: installed = "0" if addon.provided_name: name = addon.provided_name else: name = "''" user = addmgr.getConfig(addon.dir_name) default = addmgr.addonConfigDefaults(addon.dir_name) if user == default: modified = "''" else: modified = "mod" return f"{name} ['{addon.dir_name}', {installed}, '{addon.human_version}', {modified}]" def onCopy(): addmgr = mw.addonManager active = [] activeids = [] inactive = [] for addon in addmgr.all_addon_meta(): if addon.enabled: active.append(addon_fmt(addmgr, addon)) if addon.ankiweb_id(): activeids.append(addon.dir_name) else: inactive.append(addon_fmt(addmgr, addon)) 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))} ===IDs of active AnkiWeb add-ons=== {" ".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) btn = QPushButton(_("Copy Debug Info")) qconnect(btn.clicked, onCopy) abt.buttonBox.addButton(btn, QDialogButtonBox.ActionRole) abt.buttonBox.button(QDialogButtonBox.Ok).setFocus() # WebView contents ###################################################################### abouttext = "<center><img src='/_anki/imgs/anki-logo-thin.png'></center>" abouttext += "<p>" + _("Anki is a friendly, intelligent spaced learning \ system. It's free and open source.") abouttext += "<p>" + _( "Anki is licensed under the AGPL3 license. Please see " "the license file in the source distribution for more information.") abouttext += "<p>" + _("Version %s") % versionWithBuild() + "<br>" abouttext += ("Python %s Qt %s PyQt %s<br>") % ( platform.python_version(), QT_VERSION_STR, PYQT_VERSION_STR, ) abouttext += (_("<a href='%s'>Visit website</a>") % aqt.appWebsite) + "</span>" # automatically sorted; add new lines at the end allusers = sorted(( "Aaron Harsh", "Alex Fraser", "Andreas Klauer", "Andrew Wright", "Aristotelis P.", "Bernhard Ibertsberger", "C. van Rooyen", "Charlene Barina", "Christian Krause", "Christian Rusche", "Dave Druelinger", "David Smith", "Dmitry Mikheev", "Dotan Cohen", "Emilio Wuerges", "Emmanuel Jarri", "Frank Harper", "Gregor Skumavc", "Guillem Palau Salvà", "H. Mijail", "Henrik Enggaard Hansen", "Houssam Salem", "Ian Lewis", "Immanuel Asmus", "Iroiro", "Jarvik7", "Jin Eun-Deok", "Jo Nakashima", "Johanna Lindh", "Joseph Lorimer", "Julien Baley", "Jussi Määttä", "Kieran Clancy", "LaC", "Laurent Steffan", "Luca Ban", "Luciano Esposito", "Marco Giancotti", "Marcus Rubeus", "Mari Egami", "Mark Wilbur", "Matthew Duggan", "Matthew Holtz", "Meelis Vasser", "Michael Jürges", "Michael Keppler", "Michael Montague", "Michael Penkov", "Michal Čadil", "Morteza Salehi", "Nathanael Law", "Nguyễn Hào Khôi", "Nick Cook", "Niklas Laxström", "Norbert Nagold", "Ole Guldberg", "Pcsl88", "Petr Michalec", "Piotr Kubowicz", "Richard Colley", "Roland Sieker", "Samson Melamed", "Silja Ijas", "Snezana Lukic", "Soren Bjornstad", "Stefaan De Pooter", "Susanna Björverud", "Sylvain Durand", "Tacutu", "Timm Preetz", "Timo Paulssen", "Ursus", "Victor Suba", "Volker Jansen", "Volodymyr Goncharenko", "Xtru", "Ádám Szegi", "赵金鹏", "黃文龍", "David Bailey", "Arman High", "Arthur Milchior", "Rai (Michael Pokorny)", "AMBOSS MD Inc.", "Erez Volk", "Tobias Predel", "Thomas Kahn", "zjosua", "Ijgnd", "Evandro Coan", "Alan Du", "ANH", "Junseo Park", )) abouttext += ("<p>" + _("Written by Damien Elmes, with patches, translation,\ testing and design from:<p>%(cont)s") % { "cont": ", ".join(allusers) }) abouttext += "<p>" + _("If you have contributed and are not on this list, \ please get in touch.") abouttext += "<p>" + _("A big thanks to all the people who have provided \ suggestions, bug reports and donations.") abt.label.setMinimumWidth(800) abt.label.setMinimumHeight(600) dialog.show() abt.label.stdHtml(abouttext, js=[]) return dialog
def show(mw): dialog = ClosableQDialog(mw) mw.setupDialogGC(dialog) abt = aqt.forms.about.Ui_About() abt.setupUi(dialog) # Copy debug info ###################################################################### 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))) QApplication.clipboard().setText(info) tooltip(_("Copied to clipboard"), parent=dialog) btn = QPushButton(_("Copy Debug Info")) btn.clicked.connect(onCopy) abt.buttonBox.addButton(btn, QDialogButtonBox.ActionRole) abt.buttonBox.button(QDialogButtonBox.Ok).setFocus() # WebView contents ###################################################################### abouttext = "<center><img src='/_anki/imgs/anki-logo-thin.png'></center>" abouttext += '<p>' + _("Anki is a friendly, intelligent spaced learning \ system. It's free and open source.") abouttext += "<p>"+_("Anki is licensed under the AGPL3 license. Please see " "the license file in the source distribution for more information.") abouttext += '<p>' + _("Version %s") % versionWithBuild() + '<br>' abouttext += ("Qt %s PyQt %s<br>") % (QT_VERSION_STR, PYQT_VERSION_STR) abouttext += (_("<a href='%s'>Visit website</a>") % aqt.appWebsite) + \ "</span>" # automatically sorted; add new lines at the end allusers = sorted(( "Aaron Harsh", "Alex Fraser", "Andreas Klauer", "Andrew Wright", "Aristotelis P.", "Bernhard Ibertsberger", "C. van Rooyen", "Charlene Barina", "Christian Krause", "Christian Rusche", "Dave Druelinger", "David Smith", "Dmitry Mikheev", "Dotan Cohen", "Emilio Wuerges", "Emmanuel Jarri", "Frank Harper", "Gregor Skumavc", "Guillem Palau Salvà", "H. Mijail", "Henrik Enggaard Hansen", "Houssam Salem", "Ian Lewis", "Immanuel Asmus", "Iroiro", "Jarvik7", "Jin Eun-Deok", "Jo Nakashima", "Johanna Lindh", "Joseph Lorimer", "Julien Baley", "Jussi Määttä", "Kieran Clancy", "LaC", "Laurent Steffan", "Luca Ban", "Luciano Esposito", "Marco Giancotti", "Marcus Rubeus", "Mari Egami", "Mark Wilbur", "Matthew Duggan", "Matthew Holtz", "Meelis Vasser", "Michael Jürges", "Michael Keppler", "Michael Montague", "Michael Penkov", "Michal Čadil", "Morteza Salehi", "Nathanael Law", "Nguyễn Hào Khôi", "Nick Cook", "Niklas Laxström", "Norbert Nagold", "Ole Guldberg", "Pcsl88", "Petr Michalec", "Piotr Kubowicz", "Richard Colley", "Roland Sieker", "Samson Melamed", "Silja Ijas", "Snezana Lukic", "Soren Bjornstad", "Stefaan De Pooter", "Susanna Björverud", "Sylvain Durand", "Tacutu", "Timm Preetz", "Timo Paulssen", "Ursus", "Victor Suba", "Volker Jansen", "Volodymyr Goncharenko", "Xtru", "Ádám Szegi", "赵金鹏", "黃文龍", "David Bailey", "Arman High", "Arthur Milchior", )) abouttext += '<p>' + _("Written by Damien Elmes, with patches, translation,\ testing and design from:<p>%(cont)s") % {'cont': ", ".join(allusers)} abouttext += '<p>' + _("If you have contributed and are not on this list, \ please get in touch.") abouttext += '<p>' + _("A big thanks to all the people who have provided \ suggestions, bug reports and donations.") abt.label.setMinimumWidth(800) abt.label.setMinimumHeight(600) dialog.show() abt.label.stdHtml(abouttext, js=" ") return dialog