Skip to content

Commit

Permalink
Merge pull request #153 from ciromattia/dev
Browse files Browse the repository at this point in the history
4.6.4
  • Loading branch information
AcidWeb committed Sep 11, 2015
2 parents b1bc140 + 2128104 commit eab63a0
Show file tree
Hide file tree
Showing 16 changed files with 190 additions and 151 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ 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.2.0+
- [PyQt](http://www.riverbankcomputing.co.uk/software/pyqt/download5) 5.4.0+
- [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.2+
- [python-slugify](http://pypi.python.org/pypi/python-slugify) 1.1.3+
- [scandir](https://pypi.python.org/pypi/scandir) 1.1.0+

On Debian based distributions these two commands should install all needed dependencies:
Expand Down Expand Up @@ -156,6 +156,12 @@ The app relies and includes the following scripts:
* [Kobo Aura H2O](http://kcc.iosphe.re/Samples/Ubunchu-KoAH2O.kepub.epub)

## CHANGELOG
####4.6.4:
* Fixed multiple Windows specific problems
* Improved error handling
* Improved color detection algorithm
* New, slimmer OS X release

####4.6.3:
* Implemented remote bug reporting
* Minor bug fixes and GUI tweaks
Expand Down
6 changes: 6 additions & 0 deletions gui/KCC-OSX.ui
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,12 @@
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
</widget>
<widget class="QPushButton" name="BasicModeButton">
<property name="geometry">
Expand Down
Binary file added icons/WizardOSX.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion kcc.iss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define MyAppName "Kindle Comic Converter"
#define MyAppVersion "4.6.3"
#define MyAppVersion "4.6.4"
#define MyAppPublisher "Ciro Mattia Gonano, Paweł Jastrzębski"
#define MyAppURL "http://kcc.iosphe.re/"
#define MyAppExeName "KCC.exe"
Expand Down
65 changes: 32 additions & 33 deletions kcc/KCC_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from urllib.parse import unquote
from urllib.request import urlopen, urlretrieve, Request
from socket import gethostbyname_ex, gethostname
from traceback import format_tb
from time import sleep, time
from datetime import datetime
from shutil import move
Expand All @@ -36,7 +35,7 @@
from distutils.version import StrictVersion
from xml.sax.saxutils import escape
from platform import platform
from .shared import md5Checksum, HTMLStripper
from .shared import md5Checksum, HTMLStripper, sanitizeTrace
from . import __version__
from . import comic2ebook
from . import KCC_rc_web
Expand Down Expand Up @@ -67,7 +66,6 @@ def __init__(self, argv):
socket.connectToServer(self._key, QtCore.QIODevice.WriteOnly)
if not socket.waitForConnected(self._timeout):
self._server = QtNetwork.QLocalServer(self)
# noinspection PyUnresolvedReferences
self._server.newConnection.connect(self.handleMessage)
self._server.listen(self._key)
else:
Expand Down Expand Up @@ -140,7 +138,7 @@ def __init__(self):


class WebServerHandler(BaseHTTPRequestHandler):
# noinspection PyAttributeOutsideInit, PyArgumentList
# noinspection PyAttributeOutsideInit
def do_GET(self):
if self.path == '/':
self.path = '/index.html'
Expand Down Expand Up @@ -277,8 +275,8 @@ def getNewVersion(self):
try:
MW.modeConvert.emit(-1)
MW.progressBarTick.emit('Downloading update')
path = urlretrieve('https://kcc.iosphe.re/Windows/KindleComicConverter_win_'
+ self.newVersion + '.exe', reporthook=self.getNewVersionTick)
path = urlretrieve('https://kcc.iosphe.re/Windows/KindleComicConverter_win_' +
self.newVersion + '.exe', reporthook=self.getNewVersionTick)
if self.md5 != md5Checksum(path[0]):
raise Exception
move(path[0], path[0] + '.exe')
Expand Down Expand Up @@ -325,7 +323,6 @@ def stop(self):


class WorkerThread(QtCore.QThread):
# noinspection PyArgumentList
def __init__(self):
QtCore.QThread.__init__(self)
self.conversionAlive = False
Expand All @@ -350,12 +347,6 @@ def clean(self):
MW.addTrayMessage.emit('Conversion interrupted.', 'Critical')
MW.modeConvert.emit(1)

def sanitizeTrace(self, traceback):
return ''.join(format_tb(traceback))\
.replace('C:\\Users\\pawel\\Documents\\Projekty\\KCC\\', '')\
.replace('C:\\Python34\\', '')\
.replace('C:\\Python34_64\\', '')

def run(self):
MW.modeConvert.emit(0)

Expand Down Expand Up @@ -439,16 +430,20 @@ def run(self):
GUI.progress.content = ''
self.errors = True
MW.addMessage.emit(str(warn), 'warning', False)
MW.addMessage.emit('Failed to create output file!', 'error', False)
MW.addTrayMessage.emit('Failed to create output file!', 'Critical')
MW.addMessage.emit('Error during conversion! Please consult '
'<a href="https://github.com/ciromattia/kcc/wiki/Error-messages">wiki</a> '
'for more details.', 'error', False)
MW.addTrayMessage.emit('Error during conversion!', 'Critical')
except Exception as err:
GUI.progress.content = ''
self.errors = True
_, _, traceback = sys.exc_info()
MW.showDialog.emit("Error during conversion %s:\n\n%s\n\nTraceback:\n%s"
% (jobargv[-1], str(err), self.sanitizeTrace(traceback)), 'error')
MW.addMessage.emit('Failed to create EPUB!', 'error', False)
MW.addTrayMessage.emit('Failed to create EPUB!', 'Critical')
% (jobargv[-1], str(err), sanitizeTrace(traceback)), 'error')
MW.addMessage.emit('Error during conversion! Please consult '
'<a href="https://github.com/ciromattia/kcc/wiki/Error-messages">wiki</a> '
'for more details.', 'error', False)
MW.addTrayMessage.emit('Error during conversion!', 'Critical')
if not self.conversionAlive:
for item in outputPath:
if os.path.exists(item):
Expand All @@ -463,7 +458,7 @@ def run(self):
MW.addMessage.emit('Creating EPUB files... <b>Done!</b>', 'info', True)
if str(GUI.FormatBox.currentText()) == 'MOBI':
MW.progressBarTick.emit('Creating MOBI files')
MW.progressBarTick.emit(str(len(outputPath)*2+1))
MW.progressBarTick.emit(str(len(outputPath) * 2 + 1))
MW.progressBarTick.emit('tick')
MW.addMessage.emit('Creating MOBI files', 'info', False)
GUI.progress.content = 'Creating MOBI files'
Expand Down Expand Up @@ -502,7 +497,7 @@ def run(self):
GUI.progress.content = ''
mobiPath = item.replace('.epub', '.mobi')
os.remove(mobiPath + '_toclean')
if GUI.targetDirectory and GUI.targetDirectory != os.path.split(mobiPath)[0]:
if GUI.targetDirectory and GUI.targetDirectory != os.path.dirname(mobiPath):
try:
move(mobiPath, GUI.targetDirectory)
mobiPath = os.path.join(GUI.targetDirectory, os.path.basename(mobiPath))
Expand All @@ -522,7 +517,7 @@ def run(self):
MW.addTrayMessage.emit('Failed to process MOBI file!', 'Critical')
else:
GUI.progress.content = ''
epubSize = (os.path.getsize(self.kindlegenErrorCode[2]))//1024//1024
epubSize = (os.path.getsize(self.kindlegenErrorCode[2])) // 1024 // 1024
for item in outputPath:
if os.path.exists(item):
os.remove(item)
Expand All @@ -538,7 +533,7 @@ def run(self):
False)
else:
for item in outputPath:
if GUI.targetDirectory and GUI.targetDirectory != os.path.split(item)[0]:
if GUI.targetDirectory and GUI.targetDirectory != os.path.dirname(item):
try:
move(item, GUI.targetDirectory)
item = os.path.join(GUI.targetDirectory, os.path.basename(item))
Expand All @@ -549,8 +544,9 @@ def run(self):
GUI.progress.stop()
MW.hideProgressBar.emit()
GUI.needClean = True
MW.addMessage.emit('<b>All jobs completed.</b>', 'info', False)
MW.addTrayMessage.emit('All jobs completed.', 'Information')
if not self.errors:
MW.addMessage.emit('<b>All jobs completed.</b>', 'info', False)
MW.addTrayMessage.emit('All jobs completed.', 'Information')
MW.modeConvert.emit(1)


Expand All @@ -559,7 +555,6 @@ def __init__(self):
super().__init__()
if self.isSystemTrayAvailable():
QtWidgets.QSystemTrayIcon.__init__(self, GUI.icons.programIcon, MW)
# noinspection PyUnresolvedReferences
self.activated.connect(self.catchClicks)

def catchClicks(self):
Expand Down Expand Up @@ -635,8 +630,10 @@ def selectFileMetaEditor(self):
self.lastPath = os.path.abspath(os.path.join(fname, os.pardir))
try:
self.editor.loadData(fname)
except:
self.showDialog('Failed to parse metadata!', 'error')
except Exception as err:
_, _, traceback = sys.exc_info()
self.showDialog("Failed to parse metadata!\n\n%s\n\nTraceback:\n%s"
% (str(err), sanitizeTrace(traceback)), 'error')
else:
self.editor.ui.exec_()

Expand Down Expand Up @@ -845,7 +842,7 @@ def toggleQualityBox(self, value):

def changeGamma(self, value):
value = float(value)
value = '%.2f' % (value/100)
value = '%.2f' % (value / 100)
if float(value) <= 0.09:
GUI.GammaLabel.setText('Gamma: Auto')
else:
Expand Down Expand Up @@ -913,7 +910,7 @@ def addMessage(self, message, icon, replace=False):
else:
item = QtWidgets.QListWidgetItem(' ' + self.stripTags(message))
if replace:
GUI.JobList.takeItem(GUI.JobList.count()-1)
GUI.JobList.takeItem(GUI.JobList.count() - 1)
# Due to lack of HTML support in QListWidgetItem we overlay text field with QLabel
# We still fill original text field with transparent content to trigger creation of horizontal scrollbar
item.setForeground(QtGui.QColor('transparent'))
Expand Down Expand Up @@ -1053,7 +1050,7 @@ def saveSettings(self, event):
'ColorBox': GUI.ColorBox.checkState(),
'customWidth': GUI.customWidth.text(),
'customHeight': GUI.customHeight.text(),
'GammaSlider': float(self.GammaValue)*100})
'GammaSlider': float(self.GammaValue) * 100})
self.settings.sync()
self.tray.hide()

Expand Down Expand Up @@ -1300,7 +1297,7 @@ def __init__(self, KCCAplication, KCCWindow):
if profile == "Other":
GUI.DeviceBox.addItem(self.icons.deviceOther, profile)
elif profile == "Separator":
GUI.DeviceBox.insertSeparator(GUI.DeviceBox.count()+1)
GUI.DeviceBox.insertSeparator(GUI.DeviceBox.count() + 1)
elif 'Ko' in profile:
GUI.DeviceBox.addItem(self.icons.deviceKobo, profile)
else:
Expand Down Expand Up @@ -1381,8 +1378,10 @@ def saveData(self):
self.parser.data[field.objectName()[:-4] + 's'] = tmpData
try:
self.parser.saveXML()
except:
GUI.showDialog('Failed to save metadata!', 'error')
except Exception as err:
_, _, traceback = sys.exc_info()
GUI.showDialog("Failed to save metadata!\n\n%s\n\nTraceback:\n%s"
% (str(err), sanitizeTrace(traceback)), 'error')
self.ui.close()

def cleanData(self, s):
Expand Down
2 changes: 2 additions & 0 deletions kcc/KCC_ui_osx.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ def setupUi(self, KCC):
self.JobList.setStyleSheet("QListWidget#JobList {background:#ffffff;background-image:url(:/Other/icons/list_background.png);background-position:center center;background-repeat:no-repeat;}QScrollBar:vertical{border:1px solid #999;background:#FFF;width:5px;margin:0}QScrollBar::handle:vertical{background:DarkGray;min-height:0}QScrollBar::add-line:vertical{height:0;background:DarkGray;subcontrol-position:bottom;subcontrol-origin:margin}QScrollBar::sub-line:vertical{height:0;background:DarkGray;subcontrol-position:top;subcontrol-origin:margin}QScrollBar:horizontal{border:1px solid #999;background:#FFF;height:5px;margin:0}QScrollBar::handle:horizontal{background:DarkGray;min-width:0}QScrollBar::add-line:horizontal{width:0;background:DarkGray;subcontrol-position:bottom;subcontrol-origin:margin}QScrollBar::sub-line:horizontal{width:0;background:DarkGray;subcontrol-position:top;subcontrol-origin:margin}")
self.JobList.setProperty("showDropIndicator", False)
self.JobList.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection)
self.JobList.setVerticalScrollMode(QtWidgets.QAbstractItemView.ScrollPerPixel)
self.JobList.setHorizontalScrollMode(QtWidgets.QAbstractItemView.ScrollPerPixel)
self.JobList.setObjectName("JobList")
self.BasicModeButton = QtWidgets.QPushButton(self.Form)
self.BasicModeButton.setGeometry(QtCore.QRect(5, 10, 156, 41))
Expand Down
2 changes: 1 addition & 1 deletion kcc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '4.6.3'
__version__ = '4.6.4'
__license__ = 'ISC'
__copyright__ = '2012-2015, Ciro Mattia Gonano <[email protected]>, Pawel Jastrzebski <[email protected]>'
__docformat__ = 'restructuredtext en'
4 changes: 2 additions & 2 deletions kcc/cbxarchive.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def extractCB7(self, targetdir):
if sys.platform.startswith('darwin'):
copy(self.origFileName, os.path.join(os.path.dirname(self.origFileName), 'TMP_KCC_TMP'))
self.origFileName = os.path.join(os.path.dirname(self.origFileName), 'TMP_KCC_TMP')
output = Popen('7za x "' + self.origFileName + '" -xr!__MACOSX -xr!.DS_Store -xr!thumbs.db -xr!Thumbs.db -o"'
+ targetdir + '"', stdout=PIPE, stderr=STDOUT, shell=True)
output = Popen('7za x "' + self.origFileName + '" -xr!__MACOSX -xr!.DS_Store -xr!thumbs.db -xr!Thumbs.db -o"' +
targetdir + '"', stdout=PIPE, stderr=STDOUT, shell=True)
extracted = False
for line in output.stdout:
if b"Everything is Ok" in line:
Expand Down
Loading

0 comments on commit eab63a0

Please sign in to comment.