示例#1
0
文件: errors.py 项目: DexDex1515/anki
    def onTimeout(self):
        error = html.escape(self.pool)
        self.pool = ""
        self.mw.progress.clear()
        if "abortSchemaMod" in error:
            return
        if "DeprecationWarning" in error:
            return
        if "10013" in error:
            return showWarning(
                tr(TR.QT_MISC_YOUR_FIREWALL_OR_ANTIVIRUS_PROGRAM_IS))
        if "no default input" in error.lower():
            return showWarning(
                tr(TR.QT_MISC_PLEASE_CONNECT_A_MICROPHONE_AND_ENSURE))
        if "invalidTempFolder" in error:
            return showWarning(self.tempFolderMsg())
        if "Beautiful Soup is not an HTTP client" in error:
            return
        if "database or disk is full" in error or "Errno 28" in error:
            return showWarning(
                tr(TR.QT_MISC_YOUR_COMPUTERS_STORAGE_MAY_BE_FULL))
        if "disk I/O error" in error:
            showWarning(markdown(tr(TR.ERRORS_ACCESSING_DB)))
            return

        if self.mw.addonManager.dirty:
            txt = markdown(tr(TR.ERRORS_ADDONS_ACTIVE_POPUP))
            error = supportText() + self._addonText(error) + "\n" + error
        else:
            txt = markdown(tr(TR.ERRORS_STANDARD_POPUP))
            error = supportText() + "\n" + error

        # show dialog
        txt = txt + "<div style='white-space: pre-wrap'>" + error + "</div>"
        showText(txt, type="html", copyBtn=True)
示例#2
0
    def onTimeout(self):
        error = html.escape(self.pool)
        self.pool = ""
        self.mw.progress.clear()
        if "abortSchemaMod" in error:
            return
        if "10013" in error:
            return showWarning(
                _("Your firewall or antivirus program is preventing Anki from creating a connection to itself. Please add an exception for Anki."
                  ))
        if "install mplayer" in error:
            return showWarning(
                _("Sound and video on cards will not function until mpv or mplayer is installed."
                  ))
        if "no default input" in error.lower():
            return showWarning(
                _("Please connect a microphone, and ensure "
                  "other programs are not using the audio device."))
        if "invalidTempFolder" in error:
            return showWarning(self.tempFolderMsg())
        if "Beautiful Soup is not an HTTP client" in error:
            return
        if "database or disk is full" in error or "Errno 28" in error:
            return showWarning(
                _("Your computer's storage may be full. Please delete some unneeded files, then try again."
                  ))
        if "disk I/O error" in error:
            showWarning(markdown(tr(FString.ERRORS_ACCESSING_DB)))
            return

        if self.mw.addonManager.dirty:
            txt = markdown(tr(FString.ERRORS_ADDONS_ACTIVE_POPUP))
            error = supportText() + self._addonText(error) + "\n" + error
        else:
            txt = markdown(tr(FString.ERRORS_STANDARD_POPUP))
            error = supportText() + "\n" + error

        # show dialog
        txt = txt + "<div style='white-space: pre-wrap'>" + error + "</div>"
        showText(txt, type="html", copyBtn=True)
示例#3
0
def debugInfo() -> str:
    """Return verbose info on add-ons and Anki installation"""
    info = ["{name} version {version}".format(name=ADDON.NAME, version=ADDON.VERSION)]
    from aqt.utils import supportText

    info.append(supportText())

    addmgr = mw.addonManager
    info.append(
        "Add-ons:\n\n" + "\n".join(addmgr.annotatedName(d) for d in addmgr.allAddons())
    )

    return "\n\n".join(info)
示例#4
0
    def showDebugInfo():
        from aqt import mw
        from anki import version as anki_version
        from aqt.utils import showInfo, showText

        txt = """
    <h2>Bug Status: Affected</h2>

    <p>It seems like your system is affected by a module import bug.</p>

    <p>To report your findings, please copy the debug info below and post it 
    <a href="https://anki.tenderapp.com/discussions/add-ons/35343">here</a>. 
    (no account needed).
    Feel free to uninstall "Import Bug Test" once you're done</p>

    <p>Thanks so much for your help in tracking this issue down!</p>

    <p><b>Debug info</b>:</p>
    """
        txt += "<div style='white-space: pre-wrap'>"

        if not anki_version.startswith("2.0"):
            from aqt.utils import supportText
            txt += "\n" + supportText() + "\n"
            addmgr = mw.addonManager
            txt += "Add-ons:\n\n" + "\n".join(
                addmgr.annotatedName(d) for d in addmgr.allAddons()) + "\n\n"
        else:
            from aqt import appVersion
            from aqt.qt import QT_VERSION_STR, PYQT_VERSION_STR
            txt += '<p>' + "Version %s" % appVersion + '\n'
            txt += ("Qt %s PyQt %s\n\n") % (QT_VERSION_STR, PYQT_VERSION_STR)
            txt += "Add-ons:\n\n" + repr(mw.addonManager.files()) + "\n\n"

        txt += "Import Errors:\n\n"
        txt += "\n\n".join(error[0] + ":\n" + error[1] for error in errors)

        txt += "</div>"

        kwargs = dict(title="Import Bug Test", type="html")

        if not anki_version.startswith("2.0"):
            kwargs["copyBtn"] = True

        showText(txt, **kwargs)
示例#5
0
def debugInfo():
    """Return verbose info on add-ons and Anki installation"""
    info = [
        "{name} version {version}".format(name=ADDON.NAME,
                                          version=ADDON.VERSION)
    ]
    if ANKI20:
        from aqt.qt import QT_VERSION_STR, PYQT_VERSION_STR
        from aqt import appVersion
        from anki.utils import platDesc
        info.append("Anki {version} (Qt {qt} PyQt {pyqt})".format(
            version=appVersion, qt=QT_VERSION_STR, pyqt=PYQT_VERSION_STR))
        info.append(platDesc())
        files = [f for f in os.listdir(PATH_ADDONS) if f.endswith(".py")]
        info.append("Add-ons:\n\n" + repr(files))
    else:
        from aqt.utils import supportText
        info.append(supportText())

        addmgr = mw.addonManager
        info.append("Add-ons:\n\n" + "\n".join(
            addmgr.annotatedName(d) for d in addmgr.allAddons()))

    return "\n\n".join(info)
示例#6
0
    def onTimeout(self):
        error = html.escape(self.pool)
        self.pool = ""
        self.mw.progress.clear()
        if "abortSchemaMod" in error:
            return
        if "10013" in error:
            return showWarning(_("Your firewall or antivirus program is preventing Anki from creating a connection to itself. Please add an exception for Anki."))
        if "Pyaudio not" in error:
            return showWarning(_("Please install PyAudio"))
        if "install mplayer" in error:
            return showWarning(_("Sound and video on cards will not function until mpv or mplayer is installed."))
        if "no default input" in error.lower():
            return showWarning(_("Please connect a microphone, and ensure "
                                 "other programs are not using the audio device."))
        if "invalidTempFolder" in error:
            return showWarning(self.tempFolderMsg())
        if "Beautiful Soup is not an HTTP client" in error:
            return
        if "database or disk is full" in error:
            return showWarning(_("Your computer's storage may be full. Please delete some unneeded files, then try again."))
        if "disk I/O error" in error:
            return showWarning(_("""\
An error occurred while accessing the database.

Possible causes:

- Antivirus, firewall, backup, or synchronization software may be \
  interfering with Anki. Try disabling such software and see if the \
  problem goes away.
- Your disk may be full.
- The Documents/Anki folder may be on a network drive.
- Files in the Documents/Anki folder may not be writeable.
- Your hard disk may have errors.

It's a good idea to run Tools>Check Database to ensure your collection \
is not corrupt.
"""))

        stdText = _("""\
<h1>Error</h1>
<p>An error occurred. Please use <b>Tools &gt; Check Database</b> to see if \
that fixes the problem.</p>

<p>If problems persist, you are SOL.</p>""")


        pluginText = _("""\
<h1>Error</h1>

<p>An error occurred. Please start CCBC while holding down the shift \
key, which will temporarily disable the add-ons you have installed.</p>

<p>If the issue only occurs when add-ons are enabled, please use the \
Add-ons config manager to disable some add-ons and restart CCBC, \
repeat this step until you discover the add-on that is causing the problem.</p>

<p>Obviously, no support is given, so you're SOL.</p>

<p>Debug info:</p>
""")

        # if self.mw.addonManager.dirty:
        if "addon" in error:
            txt = pluginText
            error = supportText() + self._addonText(error) + "\n" + error
        else:
            txt = stdText
            error = supportText() + "\n" + error

        # show dialog
        txt = txt + "<div style='white-space: pre-wrap'>" + error + "</div>"
        showText(txt, type="html", copyBtn=True)
示例#7
0
    def onTimeout(self):
        error = html.escape(self.pool)
        self.pool = ""
        self.mw.progress.clear()
        if "abortSchemaMod" in error:
            return
        if "10013" in error:
            return showWarning(_("Your firewall or antivirus program is preventing Anki from creating a connection to itself. Please add an exception for Anki."))
        if "Pyaudio not" in error:
            return showWarning(_("Please install PyAudio"))
        if "install mplayer" in error:
            return showWarning(_("Sound and video on cards will not function until mpv or mplayer is installed."))
        if "no default input" in error.lower():
            return showWarning(_("Please connect a microphone, and ensure "
                                 "other programs are not using the audio device."))
        if "invalidTempFolder" in error:
            return showWarning(self.tempFolderMsg())
        if "Beautiful Soup is not an HTTP client" in error:
            return
        if "database or disk is full" in error:
            return showWarning(_("Your computer's storage may be full. Please delete some unneeded files, then try again."))
        if "disk I/O error" in error:
            return showWarning(_("""\
An error occurred while accessing the database.

Possible causes:

- Antivirus, firewall, backup, or synchronization software may be \
  interfering with Anki. Try disabling such software and see if the \
  problem goes away.
- Your disk may be full.
- The Documents/Anki folder may be on a network drive.
- Files in the Documents/Anki folder may not be writeable.
- Your hard disk may have errors.

It's a good idea to run Tools>Check Database to ensure your collection \
is not corrupt.
"""))

        stdText = _("""\
<h1>Error</h1>

<p>An error occurred. Please use <b>Tools &gt; Check Database</b> to see if \
that fixes the problem.</p>

<p>If problems persist, please report the problem on our \
<a href="https://help.ankiweb.net">support site</a>. Please copy and paste \
 the information below into your report.</p>""")

        pluginText = _("""\
<h1>Error</h1>

<p>An error occurred. Please start Anki while holding down the shift \
key, which will temporarily disable the add-ons you have installed.</p>

<p>If the issue only occurs when add-ons are enabled, please use the \
Tools&gt;Add-ons menu item to disable some add-ons and restart Anki, \
repeating until you discover the add-on that is causing the problem.</p>

<p>When you've discovered the add-on that is causing the problem, please \
report the issue on the <a href="https://help.ankiweb.net/discussions/add-ons/">\
add-ons section</a> of our support site.

<p>Debug info:</p>
""")        
        if self.mw.addonManager.dirty:
            txt = pluginText
            error = supportText() + self._addonText(error) + "\n" + error
        else:
            txt = stdText
            error = supportText() + "\n" + error
        
        # show dialog
        txt = txt + "<div style='white-space: pre-wrap'>" + error + "</div>"
        showText(txt, type="html", copyBtn=True)
示例#8
0
 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)
示例#9
0
 def onAbout(self):
     from aqt.utils import supportText, showText
     addmgr = self.addonManager
     addons = "\n".join(addmgr.annotatedName(d) for d in addmgr.allAddons())
     info = "\n".join((supportText(), "Add-ons:\n\n{}".format(addons)))
     showText(info)
示例#10
0
文件: about.py 项目: Glutanimate/anki
 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)