Added KindleGen version check

This commit is contained in:
Paweł Jastrzębski
2013-06-21 14:35:06 +02:00
parent dbb14e37fa
commit 3e117f46d5
2 changed files with 19 additions and 4 deletions
+1 -1
View File
@@ -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)* - PDF *(Extracting only contained JPG images)*
## OPTIONAL REQUIREMENTS ## 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)* - [UnRAR](http://www.rarlab.com/download.htm) *(For CBR/RAR support)*
### For compiling/running from source: ### For compiling/running from source:
+18 -3
View File
@@ -30,9 +30,10 @@ import urllib2
import comic2ebook import comic2ebook
import kindlestrip import kindlestrip
from image import ProfileData from image import ProfileData
from subprocess import call, STDOUT, PIPE from subprocess import call, Popen, STDOUT, PIPE
from PyQt4 import QtGui, QtCore from PyQt4 import QtGui, QtCore
from xml.dom.minidom import parse from xml.dom.minidom import parse
from string import split
class Icons: class Icons:
@@ -415,8 +416,22 @@ class Ui_KCC(object):
self.addMessage('Welcome!', 'info') self.addMessage('Welcome!', 'info')
self.addMessage('Remember: All options have additional informations in tooltips.', 'info') self.addMessage('Remember: All options have additional informations in tooltips.', 'info')
if call('kindlegen', stdout=PIPE, stderr=STDOUT, shell=True) == 0: if call('kindlegen', stdout=PIPE, stderr=STDOUT, shell=True) == 0:
self.KindleGen = True versionCheck = Popen('kindlegen', stdout=PIPE, stderr=STDOUT, shell=True)
formats = ['MOBI', 'EPUB', 'CBZ'] 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: else:
self.KindleGen = False self.KindleGen = False
formats = ['EPUB', 'CBZ'] formats = ['EPUB', 'CBZ']