From c77f01affc19e851a792f76a0162b42f99591efc Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Wed, 9 Oct 2019 23:12:49 +0530 Subject: Update exception message Signed-off-by: Vivek Singh --- lib/chef/provider/package/dnf/python_helper.rb | 7 ++----- lib/chef/provider/package/yum/python_helper.rb | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) (limited to 'lib/chef/provider') diff --git a/lib/chef/provider/package/dnf/python_helper.rb b/lib/chef/provider/package/dnf/python_helper.rb index bd227c79f7..36686f0d71 100644 --- a/lib/chef/provider/package/dnf/python_helper.rb +++ b/lib/chef/provider/package/dnf/python_helper.rb @@ -40,12 +40,9 @@ class Chef # platform-python is used for system tools on RHEL 8 and is installed under /usr/libexec @dnf_command ||= begin cmd = which("platform-python", "python", "python3", "python2", "python2.7", extra_path: "/usr/libexec") do |f| - res = shell_out("#{f} -c 'import dnf'") - raise res.stderr if res.exitstatus != 0 - - true + shell_out("#{f} -c 'import dnf'").exitstatus == 0 end - + raise Chef::Exceptions::Package, "cannot find dnf libraries, you may need to use yum_package" unless cmd "#{cmd} #{DNF_HELPER}" end end diff --git a/lib/chef/provider/package/yum/python_helper.rb b/lib/chef/provider/package/yum/python_helper.rb index b1c4b20ce8..cea58bf0bd 100644 --- a/lib/chef/provider/package/yum/python_helper.rb +++ b/lib/chef/provider/package/yum/python_helper.rb @@ -42,12 +42,9 @@ class Chef def yum_command @yum_command ||= begin cmd = which("platform-python", "python", "python2", "python2.7", extra_path: "/usr/libexec") do |f| - res = shell_out("#{f} -c 'import yum'") - raise res.stderr if res.exitstatus != 0 - - true + shell_out("#{f} -c 'import yum'").exitstatus == 0 end - + raise Chef::Exceptions::Package, "cannot find yum libraries, you may need to use dnf_package" unless cmd "#{cmd} #{YUM_HELPER}" end end -- cgit v1.2.1