diff --git a/python/lib/facter/python.rb b/python/lib/facter/python.rb index 3506f7e..0b39745 100644 --- a/python/lib/facter/python.rb +++ b/python/lib/facter/python.rb @@ -3,9 +3,14 @@ Facter.add('pythonsitedir') do if File.exists?('/usr/local/bin/python') pythonbin='/usr/local/bin/python' else - pythonbin='python' + 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 - %x{#{pythonbin} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"}.chomp end end @@ -14,8 +19,13 @@ Facter.add('pythonversion') do if File.exists?('/usr/local/bin/python') pythonbin='/usr/local/bin/python' else - pythonbin='python' + 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 - %x{#{pythonbin} -c "import platform; print platform.python_version()"}.chomp end end