From c56f33fccefbf777a8999786455003477c3a536e Mon Sep 17 00:00:00 2001 From: Corporate Gadfly Date: Sun, 13 Sep 2026 16:48:20 -0400 Subject: [PATCH] replace deprecated calls with Facter::Core::Execution Signed-off-by: Corporate Gadfly --- lib/facter/pip_version.rb | 4 +-- lib/facter/python_release.rb | 4 +-- lib/facter/python_version.rb | 4 +-- spec/unit/facter/pip_version_spec.rb | 18 ++++++------- spec/unit/facter/python_release_spec.rb | 36 ++++++++++++------------- spec/unit/facter/python_version_spec.rb | 34 +++++++++++------------ 6 files changed, 50 insertions(+), 50 deletions(-) diff --git a/lib/facter/pip_version.rb b/lib/facter/pip_version.rb index 3303b237..dd789e6b 100644 --- a/lib/facter/pip_version.rb +++ b/lib/facter/pip_version.rb @@ -3,8 +3,8 @@ # Make pip version available as a fact def get_pip_version(executable) - if Facter::Util::Resolution.which(executable) # rubocop:disable Style/GuardClause - results = Facter::Util::Resolution.exec("#{executable} --version 2>&1").match(%r{^pip (\d+\.\d+\.?\d*).*$}) + if Facter::Core::Execution.which(executable) # rubocop:disable Style/GuardClause + results = Facter::Core::Execution.execute("#{executable} --version 2>&1").match(%r{^pip (\d+\.\d+\.?\d*).*$}) results[1] if results end end diff --git a/lib/facter/python_release.rb b/lib/facter/python_release.rb index fab88dbd..e9b06feb 100644 --- a/lib/facter/python_release.rb +++ b/lib/facter/python_release.rb @@ -3,8 +3,8 @@ # Make python release available as facts def get_python_release(executable) - if Facter::Util::Resolution.which(executable) # rubocop:disable Style/GuardClause - results = Facter::Util::Resolution.exec("#{executable} -V 2>&1").match(%r{^.*(\d+\.\d+)\.\d+\+?$}) + if Facter::Core::Execution.which(executable) # rubocop:disable Style/GuardClause + results = Facter::Core::Execution.execute("#{executable} -V 2>&1").match(%r{^.*(\d+\.\d+)\.\d+\+?$}) results[1] if results end end diff --git a/lib/facter/python_version.rb b/lib/facter/python_version.rb index fe70684e..5e627b07 100644 --- a/lib/facter/python_version.rb +++ b/lib/facter/python_version.rb @@ -3,8 +3,8 @@ # Make python versions available as facts def get_python_version(executable) - if Facter::Util::Resolution.which(executable) # rubocop:disable Style/GuardClause - results = Facter::Util::Resolution.exec("#{executable} -V 2>&1").match(%r{^.*(\d+\.\d+\.\d+\+?)$}) + if Facter::Core::Execution.which(executable) # rubocop:disable Style/GuardClause + results = Facter::Core::Execution.execute("#{executable} -V 2>&1").match(%r{^.*(\d+\.\d+\.\d+\+?)$}) results[1] if results end end diff --git a/spec/unit/facter/pip_version_spec.rb b/spec/unit/facter/pip_version_spec.rb index 3e6cd29f..7e37590c 100644 --- a/spec/unit/facter/pip_version_spec.rb +++ b/spec/unit/facter/pip_version_spec.rb @@ -28,15 +28,15 @@ describe 'pip_version' do context 'returns pip version when pip present' do it do - allow(Facter::Util::Resolution).to receive(:which).with('pip').and_return(true) - allow(Facter::Util::Resolution).to receive(:exec).with('pip --version 2>&1').and_return(pip_version_output) + allow(Facter::Core::Execution).to receive(:which).with('pip').and_return(true) + allow(Facter::Core::Execution).to receive(:execute).with('pip --version 2>&1').and_return(pip_version_output) expect(Facter.value(:pip_version)).to eq('6.0.6') end end context 'returns nil when pip not present' do it do - allow(Facter::Util::Resolution).to receive(:which).with('pip').and_return(false) + allow(Facter::Core::Execution).to receive(:which).with('pip').and_return(false) expect(Facter.value(:pip_version)).to be_nil end end @@ -45,15 +45,15 @@ describe 'pip2_version' do context 'returns pip2 version when pip2 present' do it do - allow(Facter::Util::Resolution).to receive(:which).with('pip2').and_return(true) - allow(Facter::Util::Resolution).to receive(:exec).with('pip2 --version 2>&1').and_return(pip2_version_output) + allow(Facter::Core::Execution).to receive(:which).with('pip2').and_return(true) + allow(Facter::Core::Execution).to receive(:execute).with('pip2 --version 2>&1').and_return(pip2_version_output) expect(Facter.value(:pip2_version)).to eq('9.0.1') end end context 'returns nil when pip2 not present' do it do - allow(Facter::Util::Resolution).to receive(:which).with('pip2').and_return(false) + allow(Facter::Core::Execution).to receive(:which).with('pip2').and_return(false) expect(Facter.value(:pip2_version)).to be_nil end end @@ -62,15 +62,15 @@ describe 'pip3_version' do context 'returns pip3 version when pip3 present' do it do - allow(Facter::Util::Resolution).to receive(:which).with('pip3').and_return(true) - allow(Facter::Util::Resolution).to receive(:exec).with('pip3 --version 2>&1').and_return(pip3_version_output) + allow(Facter::Core::Execution).to receive(:which).with('pip3').and_return(true) + allow(Facter::Core::Execution).to receive(:execute).with('pip3 --version 2>&1').and_return(pip3_version_output) expect(Facter.value(:pip3_version)).to eq('18.1') end end context 'returns nil when pip3 not present' do it do - allow(Facter::Util::Resolution).to receive(:which).with('pip3').and_return(false) + allow(Facter::Core::Execution).to receive(:which).with('pip3').and_return(false) expect(Facter.value(:pip3_version)).to be_nil end end diff --git a/spec/unit/facter/python_release_spec.rb b/spec/unit/facter/python_release_spec.rb index 6026c1e3..74df5857 100644 --- a/spec/unit/facter/python_release_spec.rb +++ b/spec/unit/facter/python_release_spec.rb @@ -21,16 +21,16 @@ describe 'python_release' do context 'returns Python release when `python` present' do it do - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(true) - allow(Facter::Util::Resolution).to receive(:exec).with('python -V 2>&1').and_return(python2_version_output) + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(true) + allow(Facter::Core::Execution).to receive(:execute).with('python -V 2>&1').and_return(python2_version_output) expect(Facter.value(:python_release)).to eq('2.7') end end context 'returns nil when `python` not present' do it do - allow(Facter::Util::Resolution).to receive(:exec).and_return(false) - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(false) + allow(Facter::Core::Execution).to receive(:execute).and_return(false) + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(false) expect(Facter.value(:python_release)).to be_nil end end @@ -39,35 +39,35 @@ describe 'python2_release' do context 'returns Python 2 release when `python` is present and Python 2' do it do - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(true) - allow(Facter::Util::Resolution).to receive(:exec).with('python -V 2>&1').and_return(python2_version_output) + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(true) + allow(Facter::Core::Execution).to receive(:execute).with('python -V 2>&1').and_return(python2_version_output) expect(Facter.value(:python2_release)).to eq('2.7') end end context 'returns Python 2 release when `python` is Python 3 and `python2` is present' do it do - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(true) - allow(Facter::Util::Resolution).to receive(:exec).with('python -V 2>&1').and_return(python3_version_output) - allow(Facter::Util::Resolution).to receive(:which).with('python2').and_return(true) - allow(Facter::Util::Resolution).to receive(:exec).with('python2 -V 2>&1').and_return(python2_version_output) + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(true) + allow(Facter::Core::Execution).to receive(:execute).with('python -V 2>&1').and_return(python3_version_output) + allow(Facter::Core::Execution).to receive(:which).with('python2').and_return(true) + allow(Facter::Core::Execution).to receive(:execute).with('python2 -V 2>&1').and_return(python2_version_output) expect(Facter.value(:python2_release)).to eq('2.7') end end context 'returns nil when `python` is Python 3 and `python2` is absent' do it do - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(true) - allow(Facter::Util::Resolution).to receive(:exec).with('python -V 2>&1').and_return(python3_version_output) - allow(Facter::Util::Resolution).to receive(:which).with('python2').and_return(false) + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(true) + allow(Facter::Core::Execution).to receive(:execute).with('python -V 2>&1').and_return(python3_version_output) + allow(Facter::Core::Execution).to receive(:which).with('python2').and_return(false) expect(Facter.value(:python2_release)).to be_nil end end context 'returns nil when `python2` and `python` are absent' do it do - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(false) - allow(Facter::Util::Resolution).to receive(:which).with('python2').and_return(false) + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(false) + allow(Facter::Core::Execution).to receive(:which).with('python2').and_return(false) expect(Facter.value(:python2_release)).to be_nil end end @@ -76,15 +76,15 @@ describe 'python3_release' do context 'returns Python 3 release when `python3` present' do it do - allow(Facter::Util::Resolution).to receive(:which).with('python3').and_return(true) - allow(Facter::Util::Resolution).to receive(:exec).with('python3 -V 2>&1').and_return(python3_version_output) + allow(Facter::Core::Execution).to receive(:which).with('python3').and_return(true) + allow(Facter::Core::Execution).to receive(:execute).with('python3 -V 2>&1').and_return(python3_version_output) expect(Facter.value(:python3_release)).to eq('3.3') end end context 'returns nil when `python3` not present' do it do - allow(Facter::Util::Resolution).to receive(:which).with('python3').and_return(false) + allow(Facter::Core::Execution).to receive(:which).with('python3').and_return(false) expect(Facter.value(:python3_release)).to be_nil end end diff --git a/spec/unit/facter/python_version_spec.rb b/spec/unit/facter/python_version_spec.rb index d66d280b..1595b589 100644 --- a/spec/unit/facter/python_version_spec.rb +++ b/spec/unit/facter/python_version_spec.rb @@ -21,15 +21,15 @@ describe 'python_version' do context 'returns Python version when `python` present' do it do - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(true) - allow(Facter::Util::Resolution).to receive(:exec).with('python -V 2>&1').and_return(python2_version_output) + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(true) + allow(Facter::Core::Execution).to receive(:execute).with('python -V 2>&1').and_return(python2_version_output) expect(Facter.value(:python_version)).to eq('2.7.9') end end context 'returns nil when `python` not present' do it do - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(false) + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(false) expect(Facter.value(:python_version)).to be_nil end end @@ -38,35 +38,35 @@ describe 'python2_version' do context 'returns Python 2 version when `python` is present and Python 2' do it do - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(true) - allow(Facter::Util::Resolution).to receive(:exec).with('python -V 2>&1').and_return(python2_version_output) + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(true) + allow(Facter::Core::Execution).to receive(:execute).with('python -V 2>&1').and_return(python2_version_output) expect(Facter.value(:python2_version)).to eq('2.7.9') end end context 'returns Python 2 version when `python` is Python 3 and `python2` is present' do it do - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(true) - allow(Facter::Util::Resolution).to receive(:exec).with('python -V 2>&1').and_return(python3_version_output) - allow(Facter::Util::Resolution).to receive(:which).with('python2').and_return(true) - allow(Facter::Util::Resolution).to receive(:exec).with('python2 -V 2>&1').and_return(python2_version_output) + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(true) + allow(Facter::Core::Execution).to receive(:execute).with('python -V 2>&1').and_return(python3_version_output) + allow(Facter::Core::Execution).to receive(:which).with('python2').and_return(true) + allow(Facter::Core::Execution).to receive(:execute).with('python2 -V 2>&1').and_return(python2_version_output) expect(Facter.value(:python2_version)).to eq('2.7.9') end end context 'returns nil when `python` is Python 3 and `python2` is absent' do it do - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(true) - allow(Facter::Util::Resolution).to receive(:exec).with('python -V 2>&1').and_return(python3_version_output) - allow(Facter::Util::Resolution).to receive(:which).with('python2').and_return(false) + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(true) + allow(Facter::Core::Execution).to receive(:execute).with('python -V 2>&1').and_return(python3_version_output) + allow(Facter::Core::Execution).to receive(:which).with('python2').and_return(false) expect(Facter.value(:python2_version)).to be_nil end end context 'returns nil when `python2` and `python` are absent' do it do - allow(Facter::Util::Resolution).to receive(:which).with('python2').and_return(false) - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(false) + allow(Facter::Core::Execution).to receive(:which).with('python2').and_return(false) + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(false) expect(Facter.value(:python2_version)).to be_nil end end @@ -75,15 +75,15 @@ describe 'python3_version' do context 'returns Python 3 version when `python3` present' do it do - allow(Facter::Util::Resolution).to receive(:which).with('python3').and_return(true) - allow(Facter::Util::Resolution).to receive(:exec).with('python3 -V 2>&1').and_return(python3_version_output) + allow(Facter::Core::Execution).to receive(:which).with('python3').and_return(true) + allow(Facter::Core::Execution).to receive(:execute).with('python3 -V 2>&1').and_return(python3_version_output) expect(Facter.value(:python3_version)).to eq('3.3.0') end end context 'returns nil when `python3` not present' do it do - allow(Facter::Util::Resolution).to receive(:which).with('python3').and_return(false) + allow(Facter::Core::Execution).to receive(:which).with('python3').and_return(false) expect(Facter.value(:python3_version)).to be_nil end end