From aabfc3218332db741a50151a010d3e0c5a9947c1 Mon Sep 17 00:00:00 2001 From: Trenton Holmes <797416+stumpylog@users.noreply.github.com> Date: Sun, 8 Sep 2024 11:06:26 -0700 Subject: [PATCH] Reworks this logic so it doesn' need a test --- src/paperless/checks.py | 2 +- src/paperless_tesseract/checks.py | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/paperless/checks.py b/src/paperless/checks.py index 4ba322666..150fcb201 100644 --- a/src/paperless/checks.py +++ b/src/paperless/checks.py @@ -78,7 +78,7 @@ def binaries_check(app_configs, **kwargs): error = "Paperless can't find {}. Without it, consumption is impossible." hint = "Either it's not in your ${PATH} or it's not installed." - binaries = (settings.CONVERT_BINARY, "tesseract") + binaries = (settings.CONVERT_BINARY, "tesseract", "gs") check_messages = [] for binary in binaries: diff --git a/src/paperless_tesseract/checks.py b/src/paperless_tesseract/checks.py index 4d5d98284..8e729d797 100644 --- a/src/paperless_tesseract/checks.py +++ b/src/paperless_tesseract/checks.py @@ -21,10 +21,22 @@ def get_tesseract_langs(): @register() def check_default_language_available(app_configs, **kwargs): - if shutil.which("tesseract") is None: - return [Error("Executable 'tesseract' was not located")] + # binaries_check in paperless will check and report if this doesn't exist + # So skip trying to do anything here and let that handle missing binaries + if shutil.which("tesseract") is not None: + installed_langs = get_tesseract_langs() - installed_langs = get_tesseract_langs() + specified_langs = settings.OCR_LANGUAGE.split("+") + + for lang in specified_langs: + if lang not in installed_langs: + return [ + Error( + f"The selected ocr language {lang} is " + f"not installed. Paperless cannot OCR your documents " + f"without it. Please fix PAPERLESS_OCR_LANGUAGE.", + ), + ] if not settings.OCR_LANGUAGE: return [ @@ -34,16 +46,4 @@ def check_default_language_available(app_configs, **kwargs): ), ] - specified_langs = settings.OCR_LANGUAGE.split("+") - - for lang in specified_langs: - if lang not in installed_langs: - return [ - Error( - f"The selected ocr language {lang} is " - f"not installed. Paperless cannot OCR your documents " - f"without it. Please fix PAPERLESS_OCR_LANGUAGE.", - ), - ] - return []