From be12ce54bbbd1f15ba14b3370a443b80d7ad4d3d Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Fri, 5 Dec 2014 21:10:58 +0000 Subject: [PATCH] Use shutil.which instead of calling which with check_output. --- openlp/plugins/presentations/lib/pdfcontroller.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/openlp/plugins/presentations/lib/pdfcontroller.py b/openlp/plugins/presentations/lib/pdfcontroller.py index e1d0dc8f0..941be3fe1 100644 --- a/openlp/plugins/presentations/lib/pdfcontroller.py +++ b/openlp/plugins/presentations/lib/pdfcontroller.py @@ -31,6 +31,7 @@ import os import logging from tempfile import NamedTemporaryFile import re +import shutil from subprocess import check_output, CalledProcessError, STDOUT from openlp.core.utils import AppLocation @@ -144,17 +145,10 @@ class PdfController(PresentationController): else: DEVNULL = open(os.devnull, 'wb') # First try to find mupdf - try: - self.mudrawbin = check_output(['which', 'mudraw'], - stderr=DEVNULL).decode(encoding='UTF-8').rstrip('\n') - except CalledProcessError: - self.mudrawbin = '' + self.mudrawbin = shutil.which('mudraw') # if mupdf isn't installed, fallback to ghostscript if not self.mudrawbin: - try: - self.gsbin = check_output(['which', 'gs'], stderr=DEVNULL).decode(encoding='UTF-8').rstrip('\n') - except CalledProcessError: - self.gsbin = '' + self.gsbin = shutil.which('gs') # Last option: check if mudraw is placed in OpenLP base folder if not self.mudrawbin and not self.gsbin: application_path = AppLocation.get_directory(AppLocation.AppDir)