forked from openlp/openlp
Use shutil.which instead of calling which with check_output.
This commit is contained in:
parent
fd57f81376
commit
be12ce54bb
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user