From 3e117f46d5f6985126a390d3b9a0194823662014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Fri, 21 Jun 2013 14:35:06 +0200 Subject: [PATCH] Added KindleGen version check --- README.md | 2 +- kcc/KCC_gui.py | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index aad8ec0..6f81943 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ In the meanwhile you can download [version 2.9](http://kcc.vulturis.eu/OSX/Kindl - PDF *(Extracting only contained JPG images)* ## OPTIONAL REQUIREMENTS -- [KindleGen](http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211) v2.8+ in a directory reachable by your _PATH_ or in _KCC_ directory *(For .mobi generation)* +- [KindleGen](http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211) v2.9+ in a directory reachable by your _PATH_ or in _KCC_ directory *(For .mobi generation)* - [UnRAR](http://www.rarlab.com/download.htm) *(For CBR/RAR support)* ### For compiling/running from source: diff --git a/kcc/KCC_gui.py b/kcc/KCC_gui.py index 8f92482..4d8159f 100644 --- a/kcc/KCC_gui.py +++ b/kcc/KCC_gui.py @@ -30,9 +30,10 @@ import urllib2 import comic2ebook import kindlestrip from image import ProfileData -from subprocess import call, STDOUT, PIPE +from subprocess import call, Popen, STDOUT, PIPE from PyQt4 import QtGui, QtCore from xml.dom.minidom import parse +from string import split class Icons: @@ -415,8 +416,22 @@ class Ui_KCC(object): self.addMessage('Welcome!', 'info') self.addMessage('Remember: All options have additional informations in tooltips.', 'info') if call('kindlegen', stdout=PIPE, stderr=STDOUT, shell=True) == 0: - self.KindleGen = True - formats = ['MOBI', 'EPUB', 'CBZ'] + versionCheck = Popen('kindlegen', stdout=PIPE, stderr=STDOUT, shell=True) + for line in versionCheck.stdout: + if "Amazon kindlegen" in line: + versionCheck = line.split('V')[1].split(' ')[0] + if tuple(map(int, (versionCheck.split(".")))) >= tuple(map(int, ('2.9'.split(".")))): + versionCheck = True + else: + versionCheck = False + break + if versionCheck: + self.KindleGen = True + formats = ['MOBI', 'EPUB', 'CBZ'] + else: + self.KindleGen = False + formats = ['EPUB', 'CBZ'] + self.addMessage('KindleGen is outdated! Creating MOBI files is disabled.', 'warning') else: self.KindleGen = False formats = ['EPUB', 'CBZ']