Remove logger.info and use shutil.which to find pdftopng executable

pull/198/head
Vinayak Mehta 2021-07-04 20:02:47 +05:30
parent 4628be9251
commit c3b0fa30dc
No known key found for this signature in database
GPG Key ID: 2DE013537A15A9A4
2 changed files with 8 additions and 3 deletions

View File

@ -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)

View File

@ -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(