From 7b3bf4618fc37ec017abe2c49ed20804f2cdc9c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Sat, 12 Sep 2015 09:48:17 +0200 Subject: [PATCH 01/10] Yet another Windows file lock fixes --- kcc/comic2ebook.py | 3 ++- kcc/metadata.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index 0fc3db77..200c6343 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -678,7 +678,8 @@ def getWorkFolder(afile): rmtree(workdir, True) raise UserWarning("Failed to detect archive format.") newpath = mkdtemp('', 'KCC-') - move(path, os.path.join(newpath, 'OEBPS', 'Images')) + copytree(path, os.path.join(newpath, 'OEBPS', 'Images')) + rmtree(src, True) return newpath diff --git a/kcc/metadata.py b/kcc/metadata.py index 19770999..da57e121 100644 --- a/kcc/metadata.py +++ b/kcc/metadata.py @@ -75,12 +75,12 @@ def __init__(self, source): extracted = True if not extracted: rmtree(workdir) - raise OSError + raise OSError('Failed to extract 7ZIP file.') if os.path.isfile(tmpXML): self.rawdata = parse(tmpXML) rmtree(workdir) else: - raise OSError + raise OSError('Failed to detect archive format.') if self.rawdata: self.parseXML() @@ -168,5 +168,5 @@ def saveXML(self): extracted = True if not extracted: rmtree(workdir) - raise OSError + raise OSError('Failed to modify 7ZIP file.') rmtree(workdir) From 14f677ec68389382c4554d96fd02f8e5e8d076ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Tue, 15 Sep 2015 15:44:52 +0200 Subject: [PATCH 02/10] Python 3.5+ include scandir --- kcc/cbxarchive.py | 5 ++++- kcc/comic2ebook.py | 5 ++++- kcc/comic2panel.py | 5 ++++- kcc/shared.py | 14 ++++++++------ setup.py | 10 ++++++---- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/kcc/cbxarchive.py b/kcc/cbxarchive.py index 9332eefd..97c26bab 100644 --- a/kcc/cbxarchive.py +++ b/kcc/cbxarchive.py @@ -22,7 +22,10 @@ from subprocess import STDOUT, PIPE from psutil import Popen from shutil import move, copy -from scandir import walk +try: + from scandir import walk +except ImportError: + walk = os.walk from . import rarfile from .shared import check7ZFile as is_7zfile, saferReplace diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index 200c6343..dfb3994d 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -37,12 +37,15 @@ from PIL import Image from subprocess import STDOUT, PIPE from psutil import Popen, virtual_memory -from scandir import walk from html import escape try: from PyQt5 import QtCore except ImportError: QtCore = None +try: + from scandir import walk +except ImportError: + walk = os.walk from .shared import md5Checksum, getImageFileName, walkSort, walkLevel, saferReplace from . import comic2panel from . import image diff --git a/kcc/comic2panel.py b/kcc/comic2panel.py index 2bfe3d97..8625fb84 100644 --- a/kcc/comic2panel.py +++ b/kcc/comic2panel.py @@ -24,12 +24,15 @@ from optparse import OptionParser, OptionGroup from multiprocessing import Pool from PIL import Image, ImageStat, ImageOps -from scandir import walk from .shared import getImageFileName, walkLevel, walkSort try: from PyQt5 import QtCore except ImportError: QtCore = None +try: + from scandir import walk +except ImportError: + walk = os.walk def mergeDirectoryTick(output): diff --git a/kcc/shared.py b/kcc/shared.py index eac6bf8f..89d59902 100644 --- a/kcc/shared.py +++ b/kcc/shared.py @@ -17,6 +17,7 @@ # import os +from sys import version_info from hashlib import md5 from html.parser import HTMLParser from distutils.version import StrictVersion @@ -29,7 +30,7 @@ try: from scandir import walk except ImportError: - walk = None + walk = os.walk class HTMLStripper(HTMLParser): @@ -156,12 +157,13 @@ def dependencyCheck(level): missing.append('Pillow 2.8.2+') except ImportError: missing.append('Pillow 2.8.2+') - try: - from scandir import __version__ as scandirVersion - if StrictVersion('1.1') > StrictVersion(scandirVersion): + if version_info[1] < 5: + try: + from scandir import __version__ as scandirVersion + if StrictVersion('1.1') > StrictVersion(scandirVersion): + missing.append('scandir 1.1+') + except ImportError: missing.append('scandir 1.1+') - except ImportError: - missing.append('scandir 1.1+') if len(missing) > 0: print('ERROR: ' + ', '.join(missing) + ' is not installed!') exit(1) diff --git a/setup.py b/setup.py index 8a7c8cc0..0857e8f8 100755 --- a/setup.py +++ b/setup.py @@ -11,17 +11,17 @@ Usage (Mac OS X): python3 setup.py py2app """ + from sys import platform, version_info, argv from kcc import __version__ -if version_info[0] != 3: - print('ERROR: This is Python 3 script!') - exit(1) + NAME = 'KindleComicConverter' VERSION = __version__ MAIN = 'kcc.py' extra_options = {} + if platform == 'darwin': from setuptools import setup from os import chmod, makedirs, system @@ -136,10 +136,12 @@ 'Pillow>=2.8.2', 'psutil>=3.0.0', 'python-slugify>=1.1.3', - 'scandir>=1.1.0', ], zip_safe=False, ) + if version_info[1] < 5: + extra_options['install_requires'].append('scandir>=1.1.0') + setup( name=NAME, From f2238b16a64a48b245db6c88f98550bd363b6edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Tue, 15 Sep 2015 17:44:55 +0200 Subject: [PATCH 03/10] os.access acts unpredictably on Windows --- kcc/comic2ebook.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index dfb3994d..f777a92c 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -28,7 +28,7 @@ from re import sub from stat import S_IWRITE, S_IREAD, S_IEXEC from zipfile import ZipFile, ZIP_STORED, ZIP_DEFLATED -from tempfile import mkdtemp, gettempdir +from tempfile import mkdtemp, gettempdir, TemporaryFile from shutil import move, copytree, rmtree from optparse import OptionParser, OptionGroup from multiprocessing import Pool @@ -1215,10 +1215,13 @@ def checkPre(source): rmtree(os.path.join(root, tempdir), True) # Make sure that target directory is writable if os.path.isdir(source): - writable = os.access(os.path.abspath(os.path.join(source, '..')), os.W_OK) + src = os.path.abspath(os.path.join(source, '..')) else: - writable = os.access(os.path.dirname(source), os.W_OK) - if not writable: + src = os.path.dirname(source) + try: + with TemporaryFile(prefix='KCC-', dir=src): + pass + except: raise UserWarning("Target directory is not writable.") From 21f738b44af0abd369601976a5029cd4e4c07b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Tue, 15 Sep 2015 21:24:49 +0200 Subject: [PATCH 04/10] Yet another Windows file lock fix --- kcc/shared.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kcc/shared.py b/kcc/shared.py index 89d59902..8a2aa86a 100644 --- a/kcc/shared.py +++ b/kcc/shared.py @@ -22,7 +22,7 @@ from html.parser import HTMLParser from distutils.version import StrictVersion from time import sleep -from shutil import rmtree, move +from shutil import rmtree, move, copy from tempfile import mkdtemp from zipfile import ZipFile, ZIP_DEFLATED from re import split @@ -117,9 +117,9 @@ def removeFromZIP(zipfname, *filenames): for item in zipread.infolist(): if item.filename not in filenames: zipwrite.writestr(item, zipread.read(item.filename)) - move(tempname, zipfname) + copy(tempname, zipfname) finally: - rmtree(tempdir) + rmtree(tempdir, True) def sanitizeTrace(traceback): From 00969a373938c66f8d31adc7e0c197d60347f022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Wed, 16 Sep 2015 08:47:59 +0200 Subject: [PATCH 05/10] Allow older PyQT --- README.md | 2 +- kcc/shared.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0d227193..2f8d0ef4 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ You can find the latest released binary at the following links: ## DEPENDENCIES Following software is required to run Linux version of **KCC** and/or bare sources: - Python 3.3+ -- [PyQt](http://www.riverbankcomputing.co.uk/software/pyqt/download5) 5.4.0+ +- [PyQt](http://www.riverbankcomputing.co.uk/software/pyqt/download5) 5.2.1+ - [Pillow](http://pypi.python.org/pypi/Pillow/) 2.8.2+ - [psutil](https://pypi.python.org/pypi/psutil) 3.0.0+ - [python-slugify](http://pypi.python.org/pypi/python-slugify) 1.1.3+ diff --git a/kcc/shared.py b/kcc/shared.py index 8a2aa86a..6393c322 100644 --- a/kcc/shared.py +++ b/kcc/shared.py @@ -134,10 +134,10 @@ def dependencyCheck(level): if level > 2: try: from PyQt5.QtCore import qVersion as qtVersion - if StrictVersion('5.4.0') > StrictVersion(qtVersion()): - missing.append('PyQt 5.4.0+') + if StrictVersion('5.2.1') > StrictVersion(qtVersion()): + missing.append('PyQt 5.2.1+') except ImportError: - missing.append('PyQt 5.4.0+') + missing.append('PyQt 5.2.1+') if level > 1: try: from psutil import __version__ as psutilVersion From ac9f3a5d873cab16584a5ff6206d9199f3c39a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Wed, 16 Sep 2015 10:22:53 +0200 Subject: [PATCH 06/10] KindleGen detection tweak --- kcc/KCC_gui.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kcc/KCC_gui.py b/kcc/KCC_gui.py index 45e5ba7b..5a837f76 100644 --- a/kcc/KCC_gui.py +++ b/kcc/KCC_gui.py @@ -1127,6 +1127,8 @@ def detectKindleGen(self, startup=False): 'KindleGen! MOBI conversion will be unavailable!', 'error') if sys.platform.startswith('win'): self.addMessage('Download it and place EXE in KCC directory.', 'error') + elif sys.platform.startswith('darwin'): + self.addMessage('Install it using Brew.', 'error') else: self.addMessage('Download it and place executable in /usr/local/bin directory.', 'error') From b12825045bd1e5c65d6e0266ee6b70401eae53b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Wed, 16 Sep 2015 11:52:17 +0200 Subject: [PATCH 07/10] Fixed stupid typo --- kcc/comic2ebook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index f777a92c..bad18658 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -682,7 +682,7 @@ def getWorkFolder(afile): raise UserWarning("Failed to detect archive format.") newpath = mkdtemp('', 'KCC-') copytree(path, os.path.join(newpath, 'OEBPS', 'Images')) - rmtree(src, True) + rmtree(path, True) return newpath From 7b3ce8827fbaded0b3de28f84965314edec1231b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Wed, 16 Sep 2015 19:00:45 +0200 Subject: [PATCH 08/10] Updated OS X build environment --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0857e8f8..bd038b86 100755 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ py2app=dict( argv_emulation=True, iconfile='icons/comic2ebook.icns', - includes=['sip'], + includes=['sip', 'PyQt5.QtPrintSupport'], resources=['LICENSE.txt', 'other/qt.conf', 'other/Additional-LICENSE.txt', 'other/unrar', 'other/7za'], plist=dict( CFBundleName='Kindle Comic Converter', @@ -49,6 +49,7 @@ CFBundleTypeRole='Editor', ) ], + CFBundleIdentifier='re.iosphe.kcc', LSMinimumSystemVersion='10.8.0', LSEnvironment=dict( PATH='./../Resources:/usr/local/bin:/usr/bin:/bin' From 65774c6f12054a0310c536f7efb09606df94bee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Wed, 16 Sep 2015 19:13:32 +0200 Subject: [PATCH 09/10] Updated README + version bump --- README.md | 4 ++++ kcc.iss | 2 +- kcc/__init__.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2f8d0ef4..4cbb6b2d 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,10 @@ The app relies and includes the following scripts: * [Kobo Aura H2O](http://kcc.iosphe.re/Samples/Ubunchu-KoAH2O.kepub.epub) ## CHANGELOG +####4.6.5: +* Fixed multiple Windows and OS X issues +* Allowed Linux release to use older PyQT5 version + ####4.6.4: * Fixed multiple Windows specific problems * Improved error handling diff --git a/kcc.iss b/kcc.iss index eb720e87..1b3708da 100644 --- a/kcc.iss +++ b/kcc.iss @@ -1,5 +1,5 @@ #define MyAppName "Kindle Comic Converter" -#define MyAppVersion "4.6.4" +#define MyAppVersion "4.6.5" #define MyAppPublisher "Ciro Mattia Gonano, Paweł Jastrzębski" #define MyAppURL "http://kcc.iosphe.re/" #define MyAppExeName "KCC.exe" diff --git a/kcc/__init__.py b/kcc/__init__.py index 6d9142d2..0670e9cc 100644 --- a/kcc/__init__.py +++ b/kcc/__init__.py @@ -1,4 +1,4 @@ -__version__ = '4.6.4' +__version__ = '4.6.5' __license__ = 'ISC' __copyright__ = '2012-2015, Ciro Mattia Gonano , Pawel Jastrzebski ' __docformat__ = 'restructuredtext en' From 112917754ac6e319f3d7d24eae31d8ba584c1930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Thu, 17 Sep 2015 10:35:54 +0200 Subject: [PATCH 10/10] Fixed OS X GUI anomalies --- kcc.py | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/kcc.py b/kcc.py index f9ca259b..dd245cb7 100755 --- a/kcc.py +++ b/kcc.py @@ -30,6 +30,7 @@ os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + '/other/:' + os.environ['PATH'] else: os.environ['PATH'] = './../Resources:/usr/local/bin:/usr/bin:/bin' + os.system('defaults write com.kindlecomicconverter.KindleComicConverter ApplePersistenceIgnoreState YES') elif sys.platform.startswith('win'): if getattr(sys, 'frozen', False): os.chdir(os.path.dirname(os.path.abspath(sys.executable))) diff --git a/setup.py b/setup.py index bd038b86..52efd134 100755 --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ CFBundleTypeRole='Editor', ) ], - CFBundleIdentifier='re.iosphe.kcc', + CFBundleIdentifier='com.kindlecomicconverter.KindleComicConverter', LSMinimumSystemVersion='10.8.0', LSEnvironment=dict( PATH='./../Resources:/usr/local/bin:/usr/bin:/bin'