mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
return of the evil bytestring windows exceptions
This commit is contained in:
parent
5a59748f49
commit
4a9c08014e
3 changed files with 20 additions and 10 deletions
|
@ -779,7 +779,7 @@ to a cloze type first, via Edit>Change Note Type."""))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
showWarning(_(
|
showWarning(_(
|
||||||
"Couldn't record audio. Have you installed lame and sox?") +
|
"Couldn't record audio. Have you installed lame and sox?") +
|
||||||
"\n\n" + unicode(e))
|
"\n\n" + repr(str(e)))
|
||||||
return
|
return
|
||||||
self.addMedia(file)
|
self.addMedia(file)
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,22 @@
|
||||||
|
# coding=utf-8
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# 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 os, re, traceback, zipfile, json
|
import os
|
||||||
|
import re
|
||||||
|
import traceback
|
||||||
|
import zipfile
|
||||||
|
import json
|
||||||
|
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
import anki.importing as importing
|
import anki.importing as importing
|
||||||
from aqt.utils import getOnlyText, getFile, showText, showWarning, openHelp,\
|
from aqt.utils import getOnlyText, getFile, showText, showWarning, openHelp,\
|
||||||
askUser, tooltip
|
askUser, tooltip
|
||||||
from anki.hooks import addHook, remHook
|
from anki.hooks import addHook, remHook
|
||||||
import aqt.forms, aqt.modelchooser, aqt.deckchooser
|
import aqt.forms
|
||||||
|
import aqt.modelchooser
|
||||||
|
import aqt.deckchooser
|
||||||
|
|
||||||
|
|
||||||
class ChangeMap(QDialog):
|
class ChangeMap(QDialog):
|
||||||
def __init__(self, mw, model, current):
|
def __init__(self, mw, model, current):
|
||||||
|
@ -155,7 +164,7 @@ you can enter it here. Use \\t to represent tab."""),
|
||||||
return
|
return
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
msg = _("Import failed.\n")
|
msg = _("Import failed.\n")
|
||||||
err = unicode(e)
|
err = repr(str(e))
|
||||||
if "1-character string" in err:
|
if "1-character string" in err:
|
||||||
msg += err
|
msg += err
|
||||||
else:
|
else:
|
||||||
|
@ -283,7 +292,7 @@ def importFile(mw, file):
|
||||||
showUnicodeWarning()
|
showUnicodeWarning()
|
||||||
return
|
return
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
msg = unicode(e)
|
msg = repr(str(e))
|
||||||
if msg == "unknownFormat":
|
if msg == "unknownFormat":
|
||||||
if file.endswith(".anki2"):
|
if file.endswith(".anki2"):
|
||||||
showWarning(_("""\
|
showWarning(_("""\
|
||||||
|
@ -322,11 +331,12 @@ failed. Please try again, and if the problem persists, please try again \
|
||||||
with a different browser.""")
|
with a different browser.""")
|
||||||
showWarning(msg)
|
showWarning(msg)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
if "invalidFile" in unicode(e):
|
err = repr(str(e))
|
||||||
|
if "invalidFile" in err:
|
||||||
msg = _("""\
|
msg = _("""\
|
||||||
Invalid file. Please restore from backup.""")
|
Invalid file. Please restore from backup.""")
|
||||||
showWarning(msg)
|
showWarning(msg)
|
||||||
elif "readonly" in unicode(e):
|
elif "readonly" in err:
|
||||||
showWarning(_("""\
|
showWarning(_("""\
|
||||||
Unable to import from a read-only file."""))
|
Unable to import from a read-only file."""))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -259,16 +259,16 @@ class UpgradeThread(QThread):
|
||||||
try:
|
try:
|
||||||
self.maybeCopyFromCustomFolder(path)
|
self.maybeCopyFromCustomFolder(path)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
imp.log.append(unicode(e))
|
imp.log.append(repr(str(e)))
|
||||||
# then run the import
|
# then run the import
|
||||||
try:
|
try:
|
||||||
imp.run()
|
imp.run()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
if unicode(e) == "invalidFile":
|
if repr(str(e)) == "invalidFile":
|
||||||
# already logged
|
# already logged
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
imp.log.append(unicode(e))
|
imp.log.append(repr(str(e)))
|
||||||
self.col.save()
|
self.col.save()
|
||||||
return imp.log
|
return imp.log
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue