process: show the OCR failure reason in the error
This commit is contained in:
@@ -142,7 +142,8 @@ def check_ocr(cfg, book_dir):
|
|||||||
ocr_pdf = os.path.join(settings.resolve(cfg, "work_dir"), os.path.basename(book_dir), "ocr.pdf")
|
ocr_pdf = os.path.join(settings.resolve(cfg, "work_dir"), os.path.basename(book_dir), "ocr.pdf")
|
||||||
pages = ",".join(map(str, missing))
|
pages = ",".join(map(str, missing))
|
||||||
if not os.path.exists(ocr_pdf):
|
if not os.path.exists(ocr_pdf):
|
||||||
msg = "pdf pages %s have no text layer and OCR did not produce a text copy (is ocrmypdf installed? see warnings.log)" % pages
|
why = " | ".join(ln for ln in read_if(os.path.join(book_dir, bookio.WARN_NAME)).splitlines() if ln.startswith("ingest |"))
|
||||||
|
msg = "pdf pages %s have no text layer and OCR did not produce a text copy. Reason logged: %s" % (pages, why or "none (is ocrmypdf installed?)")
|
||||||
if cfg["ocr"].get("required", True):
|
if cfg["ocr"].get("required", True):
|
||||||
raise Failed("ingest: " + msg)
|
raise Failed("ingest: " + msg)
|
||||||
print("WARNING:", msg)
|
print("WARNING:", msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user