Ignore stderr when checking for Python version

https://review.openstack.org/504171 prevented Python version detection
from failing when python3 is not installed. However, "which python3"
returns a message in stderr when python3 is not there, and this output
can make diskimage-builder get confused when parsing
source-repository-images.

Change-Id: Idb649dc341ede73c39954b0432ef3cacf379ed37
This commit is contained in:
Javier Pena 2017-09-15 15:55:00 +02:00
parent f56a0ae2ec
commit 6bd4924cec

View File

@ -2081,7 +2081,7 @@ function _get_python_version {
local interp=$1
local version
# disable erroring out here, otherwise if python 3 doesn't exist we fail hard.
if [[ -x $(which $interp) ]]; then
if [[ -x $(which $interp 2> /dev/null) ]]; then
version=$($interp -c 'import sys; print("%s.%s" % sys.version_info[0:2])')
fi
echo ${version}