From 0ace93e717d72b9803d4fad7b748979fe5eee8d1 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 25 Sep 2012 22:08:54 +0900 Subject: [PATCH] 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. --- aqt/__init__.py | 3 +-- aqt/main.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/aqt/__init__.py b/aqt/__init__.py index db816ca5e..d42cad0b3 100644 --- a/aqt/__init__.py +++ b/aqt/__init__.py @@ -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 diff --git a/aqt/main.py b/aqt/main.py index b94e072b2..12d9c2c64 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -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)