-
-
Notifications
You must be signed in to change notification settings - Fork 376
Expand file tree
/
Copy pathpython_release.rb
More file actions
31 lines (27 loc) · 734 Bytes
/
python_release.rb
File metadata and controls
31 lines (27 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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+\+?(?:rc\d+)?$})
results[1] if results
end
end
Facter.add('python_release') do
setcode do
get_python_release 'python'
end
end
Facter.add('python2_release') do
setcode do
default_release = get_python_release 'python'
if default_release.nil? || !default_release.start_with?('2')
get_python_release 'python2'
else
default_release
end
end
end
Facter.add('python3_release') do
setcode do
get_python_release 'python3'
end
end