|
|
@ -297,11 +297,6 @@ class WorkerThread(threading.Thread):
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
# check which converter to use kindlegen is "1"
|
|
|
|
|
|
|
|
if format_old_ext == '.epub' and format_new_ext == '.mobi':
|
|
|
|
|
|
|
|
if config.config_ebookconverter == 1:
|
|
|
|
|
|
|
|
command = [config.config_converterpath, file_path + u'.epub']
|
|
|
|
|
|
|
|
quotes = [1]
|
|
|
|
|
|
|
|
if config.config_ebookconverter == 2:
|
|
|
|
if config.config_ebookconverter == 2:
|
|
|
|
# Linux py2.7 encode as list without quotes no empty element for parameters
|
|
|
|
# Linux py2.7 encode as list without quotes no empty element for parameters
|
|
|
|
# linux py3.x no encode and as list without quotes no empty element for parameters
|
|
|
|
# linux py3.x no encode and as list without quotes no empty element for parameters
|
|
|
@ -324,28 +319,17 @@ class WorkerThread(threading.Thread):
|
|
|
|
self._handleError(_(u"Ebook-converter failed: %(error)s", error=e))
|
|
|
|
self._handleError(_(u"Ebook-converter failed: %(error)s", error=e))
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
if config.config_ebookconverter == 1:
|
|
|
|
while p.poll() is None:
|
|
|
|
nextline = p.communicate()[0]
|
|
|
|
nextline = p.stdout.readline()
|
|
|
|
# Format of error message (kindlegen translates its output texts):
|
|
|
|
if os.name == 'nt' and sys.version_info < (3, 0):
|
|
|
|
# Error(prcgen):E23006: Language not recognized in metadata.The dc:Language field is mandatory.Aborting.
|
|
|
|
nextline = nextline.decode('windows-1252')
|
|
|
|
conv_error = re.search(r".*\(.*\):(E\d+):\s(.*)", nextline, re.MULTILINE)
|
|
|
|
elif os.name == 'posix' and sys.version_info < (3, 0):
|
|
|
|
# If error occoures, store error message for logfile
|
|
|
|
nextline = nextline.decode('utf-8')
|
|
|
|
if conv_error:
|
|
|
|
log.debug(nextline.strip('\r\n'))
|
|
|
|
error_message = _(u"Kindlegen failed with Error %(error)s. Message: %(message)s",
|
|
|
|
# parse progress string from calibre-converter
|
|
|
|
error=conv_error.group(1), message=conv_error.group(2).strip())
|
|
|
|
progress = re.search(r"(\d+)%\s.*", nextline)
|
|
|
|
log.debug("convert_kindlegen: %s", nextline)
|
|
|
|
if progress:
|
|
|
|
else:
|
|
|
|
self.UIqueue[index]['progress'] = progress.group(1) + ' %'
|
|
|
|
while p.poll() is None:
|
|
|
|
|
|
|
|
nextline = p.stdout.readline()
|
|
|
|
|
|
|
|
if os.name == 'nt' and sys.version_info < (3, 0):
|
|
|
|
|
|
|
|
nextline = nextline.decode('windows-1252')
|
|
|
|
|
|
|
|
elif os.name == 'posix' and sys.version_info < (3, 0):
|
|
|
|
|
|
|
|
nextline = nextline.decode('utf-8')
|
|
|
|
|
|
|
|
log.debug(nextline.strip('\r\n'))
|
|
|
|
|
|
|
|
# parse progress string from calibre-converter
|
|
|
|
|
|
|
|
progress = re.search(r"(\d+)%\s.*", nextline)
|
|
|
|
|
|
|
|
if progress:
|
|
|
|
|
|
|
|
self.UIqueue[index]['progress'] = progress.group(1) + ' %'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# process returncode
|
|
|
|
# process returncode
|
|
|
|
check = p.returncode
|
|
|
|
check = p.returncode
|
|
|
@ -361,8 +345,7 @@ class WorkerThread(threading.Thread):
|
|
|
|
# 0 = Info(prcgen):I1036: Mobi file built successfully
|
|
|
|
# 0 = Info(prcgen):I1036: Mobi file built successfully
|
|
|
|
# 1 = Info(prcgen):I1037: Mobi file built with WARNINGS!
|
|
|
|
# 1 = Info(prcgen):I1037: Mobi file built with WARNINGS!
|
|
|
|
# 2 = Info(prcgen):I1038: MOBI file could not be generated because of errors!
|
|
|
|
# 2 = Info(prcgen):I1038: MOBI file could not be generated because of errors!
|
|
|
|
if (check < 2 and config.config_ebookconverter == 1) or \
|
|
|
|
if check == 0 and config.config_ebookconverter == 2:
|
|
|
|
(check == 0 and config.config_ebookconverter == 2):
|
|
|
|
|
|
|
|
cur_book = db.session.query(db.Books).filter(db.Books.id == bookid).first()
|
|
|
|
cur_book = db.session.query(db.Books).filter(db.Books.id == bookid).first()
|
|
|
|
if os.path.isfile(file_path + format_new_ext):
|
|
|
|
if os.path.isfile(file_path + format_new_ext):
|
|
|
|
new_format = db.Data(name=cur_book.data[0].name,
|
|
|
|
new_format = db.Data(name=cur_book.data[0].name,
|
|
|
|