Fixed errors from python facts if no python is installed.

This commit is contained in:
Timo Mkinen 2012-03-12 10:52:55 +02:00
parent 24c0218ff1
commit 706c81645a

View file

@ -3,19 +3,29 @@ Facter.add('pythonsitedir') do
if File.exists?('/usr/local/bin/python')
pythonbin='/usr/local/bin/python'
else
system('which python > /dev/null 2>&1')
if $? == 0
pythonbin='python'
end
end
if pythonbin
%x{#{pythonbin} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"}.chomp
end
end
end
Facter.add('pythonversion') do
setcode do
if File.exists?('/usr/local/bin/python')
pythonbin='/usr/local/bin/python'
else
system('which python > /dev/null 2>&1')
if $? == 0
pythonbin='python'
end
end
if pythonbin
%x{#{pythonbin} -c "import platform; print platform.python_version()"}.chomp
end
end
end