|
|
@ -86,8 +86,14 @@ def make_mobi(book_id, calibrepath):
|
|
|
|
|
|
|
|
|
|
|
|
file_path = os.path.join(calibrepath, book.path, data.name)
|
|
|
|
file_path = os.path.join(calibrepath, book.path, data.name)
|
|
|
|
if os.path.exists(file_path + u".epub"):
|
|
|
|
if os.path.exists(file_path + u".epub"):
|
|
|
|
|
|
|
|
try:
|
|
|
|
p = subprocess.Popen((kindlegen + " \"" + file_path + u".epub\"").encode(sys.getfilesystemencoding()),
|
|
|
|
p = subprocess.Popen((kindlegen + " \"" + file_path + u".epub\"").encode(sys.getfilesystemencoding()),
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
error_message = _(u"kindlegen failed, no excecution permissions")
|
|
|
|
|
|
|
|
app.logger.error("make_mobi: "+error_message)
|
|
|
|
|
|
|
|
return error_message, RET_FAIL
|
|
|
|
|
|
|
|
|
|
|
|
# Poll process for new output until finished
|
|
|
|
# Poll process for new output until finished
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
nextline = p.stdout.readline()
|
|
|
|
nextline = p.stdout.readline()
|
|
|
@ -117,7 +123,7 @@ def make_mobi(book_id, calibrepath):
|
|
|
|
return file_path + ".mobi", RET_SUCCESS
|
|
|
|
return file_path + ".mobi", RET_SUCCESS
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
app.logger.error("make_mobi: kindlegen failed with error while converting book")
|
|
|
|
app.logger.error("make_mobi: kindlegen failed with error while converting book")
|
|
|
|
return error_message, RET_FAIL
|
|
|
|
return None, RET_FAIL
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
app.logger.error("make_mobi: epub not found: %s.epub" % file_path)
|
|
|
|
app.logger.error("make_mobi: epub not found: %s.epub" % file_path)
|
|
|
|
return None, RET_FAIL
|
|
|
|
return None, RET_FAIL
|
|
|
|