diff --git a/kcc/KCC_gui.py b/kcc/KCC_gui.py index 3116656..3740699 100644 --- a/kcc/KCC_gui.py +++ b/kcc/KCC_gui.py @@ -159,7 +159,7 @@ class WorkerThread(QtCore.QThread): argv.append("--forcecolor") for i in range(GUI.JobList.count()): if GUI.JobList.item(i).icon().isNull(): - currentJobs.append(str(GUI.JobList.item(i).text())) + currentJobs.append(unicode(GUI.JobList.item(i).text())) GUI.JobList.clear() for job in currentJobs: time.sleep(0.5) @@ -215,8 +215,8 @@ class WorkerThread(QtCore.QThread): try: self.kindlegenErrorCode = 0 if os.path.getsize(item) < 367001600: - output = Popen('kindlegen -locale en "' + item + '"', stdout=PIPE, stderr=STDOUT, - shell=True) + output = Popen('kindlegen -locale en "' + item.encode(sys.getfilesystemencoding()) + + '"', stdout=PIPE, stderr=STDOUT, shell=True) for line in output.stdout: # ERROR: Generic error if "Error(" in line: @@ -312,18 +312,11 @@ class Ui_KCC(object): dnames = dirDialog.selectedFiles() else: dnames = "" - # Lame UTF-8 security measure for dname in dnames: - try: - str(dname) - except Exception: - QtGui.QMessageBox.critical(MainWindow, 'KCC - Error', 'Path cannot contain non-ASCII characters.', - QtGui.QMessageBox.Ok) - return - if str(dname) != "": + if unicode(dname) != "": if sys.platform == 'win32': dname = dname.replace('/', '\\') - self.lastPath = os.path.abspath(os.path.join(str(dname), os.pardir)) + self.lastPath = os.path.abspath(os.path.join(unicode(dname), os.pardir)) GUI.JobList.addItem(dname) def selectFile(self): @@ -344,16 +337,9 @@ class Ui_KCC(object): else: fnames = QtGui.QFileDialog.getOpenFileNames(MainWindow, 'Select file', self.lastPath, '*.cbz *.zip *.pdf') - # Lame UTF-8 security measure for fname in fnames: - try: - str(fname) - except Exception: - QtGui.QMessageBox.critical(MainWindow, 'KCC - Error', 'Path cannot contain non-ASCII characters.', - QtGui.QMessageBox.Ok) - return - if str(fname) != "": - self.lastPath = os.path.abspath(os.path.join(str(fname), os.pardir)) + if unicode(fname) != "": + self.lastPath = os.path.abspath(os.path.join(unicode(fname), os.pardir)) GUI.JobList.addItem(fname) def clearJobs(self): diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index 4758466..e98055a 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -184,7 +184,7 @@ def buildNCX(dstdir, title, chapters): "\n", "\n", "\n", - "", title, "\n", + "", title.encode('utf-8'), "\n", "" ]) for chapter in chapters: @@ -192,8 +192,9 @@ def buildNCX(dstdir, title, chapters): if os.path.basename(folder) != "Text": title = os.path.basename(folder) filename = getImageFileName(os.path.join(folder, chapter[1])) - f.write("" + title - + "\n") + f.write("" + + title.encode('utf-8') + "\n") f.write("\n") f.close() return @@ -213,7 +214,7 @@ def buildOPF(dstdir, title, filelist, cover=None): "xmlns=\"http://www.idpf.org/2007/opf\">\n", "\n", - "", title, "\n", + "", title.encode('utf-8'), "\n", "en-US\n", "", options.uuid, "\n", "KCC\n",