1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-09-19 18:59:45 +00:00

Better error message on failed convert because of running calibre instance (#3100)

This commit is contained in:
Ozzie Isaacs 2024-07-11 20:30:35 +02:00
parent 6996e813b5
commit 02d2c2bbf8

View File

@ -269,10 +269,18 @@ class TaskConvert(CalibreTask):
'--with-library', library_path] '--with-library', library_path]
p = process_open(opf_command, quotes, my_env) p = process_open(opf_command, quotes, my_env)
p.wait() p.wait()
path_tmp_opf = os.path.join(tmp_dir, "metadata_" + str(uuid4()) + ".opf") check = p.returncode
with open(path_tmp_opf, 'w') as fd: calibre_traceback = p.stderr.readlines()
copyfileobj(p.stdout, fd) if check == 0:
path_tmp_opf = os.path.join(tmp_dir, "metadata_" + str(uuid4()) + ".opf")
with open(path_tmp_opf, 'w') as fd:
copyfileobj(p.stdout, fd)
else:
error_message = ""
for ele in calibre_traceback:
if not ele.startswith('Traceback') and not ele.startswith(' File'):
error_message = N_("Calibre failed with error: %(error)s", error=ele)
return check, error_message
quotes = [1, 2, 4, 6] quotes = [1, 2, 4, 6]
command = [config.config_converterpath, (file_path + format_old_ext), command = [config.config_converterpath, (file_path + format_old_ext),
(file_path + format_new_ext)] (file_path + format_new_ext)]