From c3b0fa30dcfee25d0c05ee0b23cac81b746aa371 Mon Sep 17 00:00:00 2001 From: Vinayak Mehta Date: Sun, 4 Jul 2021 20:02:47 +0530 Subject: [PATCH] Remove logger.info and use shutil.which to find pdftopng executable --- camelot/backends/image_conversion.py | 2 -- camelot/backends/poppler_backend.py | 9 ++++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/camelot/backends/image_conversion.py b/camelot/backends/image_conversion.py index f79c236..a9b6004 100644 --- a/camelot/backends/image_conversion.py +++ b/camelot/backends/image_conversion.py @@ -24,8 +24,6 @@ class ImageConversionBackend(object): if self.use_fallback: for fallback in self.fallbacks: - logger.info(f"Falling back on '{fallback}'") - try: converter = backends[fallback]() converter.convert(pdf_path, png_path) diff --git a/camelot/backends/poppler_backend.py b/camelot/backends/poppler_backend.py index 76c4667..ab12bcf 100644 --- a/camelot/backends/poppler_backend.py +++ b/camelot/backends/poppler_backend.py @@ -1,11 +1,18 @@ # -*- coding: utf-8 -*- +import shutil import subprocess class PopplerBackend(object): def convert(self, pdf_path, png_path): - pdftopng_command = ["pdftopng", pdf_path, png_path] + pdftopng_executable = shutil.which("pdftopng") + if pdftopng_executable is None: + raise OSError( + "pdftopng is not installed. Please install it using the `pip install pdftopng` command." + ) + + pdftopng_command = [pdftopng_executable, pdf_path, png_path] try: subprocess.check_output(