about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaweł Jastrzębski <[email protected]>2015-09-17 15:44:42 +0200
committerPaweł Jastrzębski <[email protected]>2015-09-17 15:44:42 +0200
commit1fa6d315b19bce915b920252983a3ed3505528b9 (patch)
tree8b9aa7883674b906c2677dbedd18395ab5c84023
parentMerge pull request #153 from ciromattia/dev (diff)
parentFixed OS X GUI anomalies (diff)
downloadkcc-1fa6d315b19bce915b920252983a3ed3505528b9.tar.gz
kcc-1fa6d315b19bce915b920252983a3ed3505528b9.tar.bz2
kcc-1fa6d315b19bce915b920252983a3ed3505528b9.zip
Merge pull request #156 from ciromattia/dev
4.6.5
-rw-r--r--README.md6
-rw-r--r--kcc.iss2
-rwxr-xr-xkcc.py1
-rw-r--r--kcc/KCC_gui.py2
-rw-r--r--kcc/__init__.py2
-rw-r--r--kcc/cbxarchive.py5
-rwxr-xr-xkcc/comic2ebook.py19
-rw-r--r--kcc/comic2panel.py5
-rw-r--r--kcc/metadata.py6
-rw-r--r--kcc/shared.py26
-rwxr-xr-xsetup.py13
11 files changed, 56 insertions, 31 deletions
diff --git a/README.md b/README.md
index 0d22719..4cbb6b2 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+
@@ -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 eb720e8..1b3708d 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.py b/kcc.py
index f9ca259..dd245cb 100755
--- a/kcc.py
+++ b/kcc.py
@@ -30,6 +30,7 @@ if sys.platform.startswith('darwin'):
         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/kcc/KCC_gui.py b/kcc/KCC_gui.py
index 45e5ba7..5a837f7 100644
--- a/kcc/KCC_gui.py
+++ b/kcc/KCC_gui.py
@@ -1127,6 +1127,8 @@ class KCCGUI(KCC_ui.Ui_KCC):
                                 '<b>KindleGen</b></a>! 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 <a href="http://brew.sh/">Brew</a>.', 'error')
                 else:
                     self.addMessage('Download it and place executable in /usr/local/bin directory.', 'error')
 
diff --git a/kcc/__init__.py b/kcc/__init__.py
index 6d9142d..0670e9c 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 <[email protected]>, Pawel Jastrzebski <[email protected]>'
 __docformat__ = 'restructuredtext en'
diff --git a/kcc/cbxarchive.py b/kcc/cbxarchive.py
index 9332eef..97c26ba 100644
--- a/kcc/cbxarchive.py
+++ b/kcc/cbxarchive.py
@@ -22,7 +22,10 @@ from zipfile import is_zipfile, ZipFile
 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 0fc3db7..bad1865 100755
--- a/kcc/comic2ebook.py
+++ b/kcc/comic2ebook.py
@@ -28,7 +28,7 @@ from urllib.request import Request, urlopen
 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
@@ -37,12 +37,15 @@ from slugify import slugify as slugifyExt
 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
@@ -678,7 +681,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(path, True)
     return newpath
 
 
@@ -1211,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.")
 
 
diff --git a/kcc/comic2panel.py b/kcc/comic2panel.py
index 2bfe3d9..8625fb8 100644
--- a/kcc/comic2panel.py
+++ b/kcc/comic2panel.py
@@ -24,12 +24,15 @@ from shutil import rmtree, copytree, move
 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/metadata.py b/kcc/metadata.py
index 1977099..da57e12 100644
--- a/kcc/metadata.py
+++ b/kcc/metadata.py
@@ -75,12 +75,12 @@ class MetadataParser:
                         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 @@ class MetadataParser:
                         extracted = True
                 if not extracted:
                     rmtree(workdir)
-                    raise OSError
+                    raise OSError('Failed to modify 7ZIP file.')
             rmtree(workdir)
diff --git a/kcc/shared.py b/kcc/shared.py
index eac6bf8..6393c32 100644
--- a/kcc/shared.py
+++ b/kcc/shared.py
@@ -17,11 +17,12 @@
 #
 
 import os
+from sys import version_info
 from hashlib import md5
 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
@@ -29,7 +30,7 @@ from traceback import format_tb
 try:
     from scandir import walk
 except ImportError:
-    walk = None
+    walk = os.walk
 
 
 class HTMLStripper(HTMLParser):
@@ -116,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):
@@ -133,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
@@ -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 8a7c8cc..52efd13 100755
--- a/setup.py
+++ b/setup.py
@@ -11,17 +11,17 @@ Usage (Linux):
 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
@@ -33,7 +33,7 @@ if platform == 'darwin':
             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 @@ if platform == 'darwin':
                             CFBundleTypeRole='Editor',
                         )
                     ],
+                    CFBundleIdentifier='com.kindlecomicconverter.KindleComicConverter',
                     LSMinimumSystemVersion='10.8.0',
                     LSEnvironment=dict(
                         PATH='./../Resources:/usr/local/bin:/usr/bin:/bin'
@@ -136,10 +137,12 @@ else:
                 '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,