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
|
import logging
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
import re
|
import re
|
||||||
|
import shutil
|
||||||
from subprocess import check_output, CalledProcessError, STDOUT
|
from subprocess import check_output, CalledProcessError, STDOUT
|
||||||
|
|
||||||
from openlp.core.utils import AppLocation
|
from openlp.core.utils import AppLocation
|
||||||
@ -144,17 +145,10 @@ class PdfController(PresentationController):
|
|||||||
else:
|
else:
|
||||||
DEVNULL = open(os.devnull, 'wb')
|
DEVNULL = open(os.devnull, 'wb')
|
||||||
# First try to find mupdf
|
# First try to find mupdf
|
||||||
try:
|
self.mudrawbin = shutil.which('mudraw')
|
||||||
self.mudrawbin = check_output(['which', 'mudraw'],
|
|
||||||
stderr=DEVNULL).decode(encoding='UTF-8').rstrip('\n')
|
|
||||||
except CalledProcessError:
|
|
||||||
self.mudrawbin = ''
|
|
||||||
# if mupdf isn't installed, fallback to ghostscript
|
# if mupdf isn't installed, fallback to ghostscript
|
||||||
if not self.mudrawbin:
|
if not self.mudrawbin:
|
||||||
try:
|
self.gsbin = shutil.which('gs')
|
||||||
self.gsbin = check_output(['which', 'gs'], stderr=DEVNULL).decode(encoding='UTF-8').rstrip('\n')
|
|
||||||
except CalledProcessError:
|
|
||||||
self.gsbin = ''
|
|
||||||
# Last option: check if mudraw is placed in OpenLP base folder
|
# Last option: check if mudraw is placed in OpenLP base folder
|
||||||
if not self.mudrawbin and not self.gsbin:
|
if not self.mudrawbin and not self.gsbin:
|
||||||
application_path = AppLocation.get_directory(AppLocation.AppDir)
|
application_path = AppLocation.get_directory(AppLocation.AppDir)
|
||||||
|
Loading…
Reference in New Issue
Block a user