1
0
mirror of https://github.com/ciromattia/kcc synced 2026-01-27 23:47:41 +00:00

kindlegen is now forced to terminate

A bug in kindlegen causes it randonly to hang when converting epub to mobi. This happens above 90% of the time it is called so this change foce it to be killed as soon kcc detects it's donne the job.

For this to work shell arg must be false. Otherwise terminate() will try to kill the new opened cmd/terminal instead of kindlegen.
This commit is contained in:
tamodolo
2016-01-03 14:49:21 -02:00
parent 4b1c7b3124
commit cb9059c231

View File

@@ -1226,8 +1226,9 @@ def makeMOBIWorker(item):
kindlegenError = ''
try:
if os.path.getsize(item) < 629145600:
print("Creating MOBI file...")
output = Popen('kindlegen -dont_append_source -locale en "' + item + '"',
stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=False)
for line in output.stdout:
line = line.decode('utf-8')
# ERROR: Generic error
@@ -1239,6 +1240,8 @@ def makeMOBIWorker(item):
kindlegenErrorCode = 23026
if kindlegenErrorCode > 0:
break
if "Mobi file built successfully" in line:
output.terminate()
else:
# ERROR: EPUB too big
kindlegenErrorCode = 23026