mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -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:
|
||||
showWarning(_(
|
||||
"Couldn't record audio. Have you installed lame and sox?") +
|
||||
"\n\n" + unicode(e))
|
||||
"\n\n" + repr(str(e)))
|
||||
return
|
||||
self.addMedia(file)
|
||||
|
||||
|
|
|
@ -1,13 +1,22 @@
|
|||
# coding=utf-8
|
||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||
# 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 *
|
||||
import anki.importing as importing
|
||||
from aqt.utils import getOnlyText, getFile, showText, showWarning, openHelp,\
|
||||
askUser, tooltip
|
||||
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):
|
||||
def __init__(self, mw, model, current):
|
||||
|
@ -155,7 +164,7 @@ you can enter it here. Use \\t to represent tab."""),
|
|||
return
|
||||
except Exception, e:
|
||||
msg = _("Import failed.\n")
|
||||
err = unicode(e)
|
||||
err = repr(str(e))
|
||||
if "1-character string" in err:
|
||||
msg += err
|
||||
else:
|
||||
|
@ -283,7 +292,7 @@ def importFile(mw, file):
|
|||
showUnicodeWarning()
|
||||
return
|
||||
except Exception, e:
|
||||
msg = unicode(e)
|
||||
msg = repr(str(e))
|
||||
if msg == "unknownFormat":
|
||||
if file.endswith(".anki2"):
|
||||
showWarning(_("""\
|
||||
|
@ -322,11 +331,12 @@ failed. Please try again, and if the problem persists, please try again \
|
|||
with a different browser.""")
|
||||
showWarning(msg)
|
||||
except Exception, e:
|
||||
if "invalidFile" in unicode(e):
|
||||
err = repr(str(e))
|
||||
if "invalidFile" in err:
|
||||
msg = _("""\
|
||||
Invalid file. Please restore from backup.""")
|
||||
showWarning(msg)
|
||||
elif "readonly" in unicode(e):
|
||||
elif "readonly" in err:
|
||||
showWarning(_("""\
|
||||
Unable to import from a read-only file."""))
|
||||
else:
|
||||
|
|
|
@ -259,16 +259,16 @@ class UpgradeThread(QThread):
|
|||
try:
|
||||
self.maybeCopyFromCustomFolder(path)
|
||||
except Exception, e:
|
||||
imp.log.append(unicode(e))
|
||||
imp.log.append(repr(str(e)))
|
||||
# then run the import
|
||||
try:
|
||||
imp.run()
|
||||
except Exception, e:
|
||||
if unicode(e) == "invalidFile":
|
||||
if repr(str(e)) == "invalidFile":
|
||||
# already logged
|
||||
pass
|
||||
else:
|
||||
imp.log.append(unicode(e))
|
||||
imp.log.append(repr(str(e)))
|
||||
self.col.save()
|
||||
return imp.log
|
||||
|
||||
|
|
Loading…
Reference in a new issue