ghostscript.py: fix missing imports

This commit is contained in:
James R. Barlow
2017-10-11 12:39:16 -07:00
parent c580aa4683
commit 7d73098d6e
+7 -6
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# © 2015 James R. Barlow: github.com/jbarlow83
# © 2017 James R. Barlow: github.com/jbarlow83
from tempfile import NamedTemporaryFile
from subprocess import run, PIPE, STDOUT, CalledProcessError
@@ -8,7 +8,7 @@ from functools import lru_cache
import re
import sys
from . import get_program
from ..exceptions import SubprocessOutputError
from ..exceptions import SubprocessOutputError, MissingDependencyError
from PIL import Image
from ..helpers import fspath
@@ -20,15 +20,16 @@ def version():
'--version'
]
try:
version = check_output(
proc = run(
args_gs, close_fds=True, universal_newlines=True,
stderr=STDOUT)
stdout=PIPE, stderr=STDOUT, check=True)
ver = proc.stdout
except CalledProcessError as e:
print("Could not find Ghostscript executable on system PATH.",
file=sys.stderr)
raise MissingDependencyError from e
return version.strip()
return ver.strip()
def _gs_error_reported(stream):
@@ -166,4 +167,4 @@ def generate_pdfa(pdf_pages, output_file, compression, log,
copy(gs_pdf.name, output_file)
else:
log.error('Ghostscript PDF/A rendering failed')
raise SubprocessOutputError()
raise SubprocessOutputError()