Refactor obtaining version from subprocesses

Issue #196 raised the need to deal with linker warnings on --version.
This commit is contained in:
James R. Barlow
2017-11-01 01:44:36 -07:00
parent c7b8b6e18b
commit fcbf34a4d3
5 changed files with 43 additions and 60 deletions
+2 -16
View File
@@ -8,28 +8,14 @@ from functools import lru_cache
import re
import sys
from PIL import Image
from . import get_program
from . import get_program, get_version
from ..exceptions import SubprocessOutputError, MissingDependencyError
from ..helpers import fspath
@lru_cache(maxsize=1)
def version():
args_gs = [
get_program('gs'),
'--version'
]
try:
proc = run(
args_gs, close_fds=True, universal_newlines=True,
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 ver.strip()
return get_version('gs')
def _gs_error_reported(stream):