This commit is contained in:
Jake Poznanski 2024-11-01 17:13:11 +00:00
parent 9f010e6ab0
commit 5ebc8cdd88

View File

@ -7,12 +7,15 @@ logger = logging.getLogger(__name__)
def check_poppler_version():
try:
result = subprocess.run(['pdftoppm', '-h'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
if result.returncode == 0 and "pdftoppm" in result.stdout:
if result.returncode == 0 and result.stderr.startswith("pdftoppm"):
logger.info("pdftoppm is installed and working.")
else:
logger.error("pdftoppm is installed but returned an error.")
logger.error(f"pdftoppm is installed but returned an error.")
sys.exit(1)
except FileNotFoundError:
logger.error("pdftoppm is not installed.")
logger.error("Check the README in the https://github.com/allenai/pdelfin/blob/main/README.md for installation instructions")
sys.exit(1)
sys.exit(1)
if __name__ == "__main__":
check_poppler_version()