don't decode file argument as unicode; tell user to file>import if broken

When the file to import has non-latin characters in its path, we're not
handling the provided filename correctly. I tried decoding with
sys.getfilesystemencoding() with no luck, so this needs more looking into. In
the mean time, if we can't open the path name, tell the user to File>Import
the file instead.
This commit is contained in:
Damien Elmes 2012-09-25 22:08:54 +09:00
parent ca2f9acce2
commit 0ace93e717
2 changed files with 2 additions and 3 deletions

View file

@ -128,7 +128,6 @@ class AnkiApp(QApplication):
self._srv = QLocalServer(self)
self.connect(self._srv, SIGNAL("newConnection()"), self.onRecv)
self._srv.listen(self.KEY)
# if we were given a file on startup, send import it
else:
# we accept only one command line argument. if it's missing, send
# a blank screen to just raise the existing window
@ -155,7 +154,7 @@ class AnkiApp(QApplication):
sys.stderr.write(sock.errorString())
return
buf = sock.readAll()
self.emit(SIGNAL("appMsg"), unicode(buf))
self.emit(SIGNAL("appMsg"), buf)
sock.disconnectFromServer()
# OS X file/url handler

View file

@ -1055,6 +1055,6 @@ Please ensure a profile is open and Anki is not busy, then try again."""),
return
# import
if not os.path.exists(buf):
return showInfo(_("Provided file does not exist."))
return showInfo(_("Please use File>Import to import this file."))
import aqt.importing
aqt.importing.importFile(self, buf)