summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/facter/python_version.rb22
-rw-r--r--lib/facter/virtualenv_version.rb14
2 files changed, 28 insertions, 8 deletions
diff --git a/lib/facter/python_version.rb b/lib/facter/python_version.rb
index 919fd89..bb9ec98 100644
--- a/lib/facter/python_version.rb
+++ b/lib/facter/python_version.rb
@@ -5,8 +5,12 @@ pkg = Puppet::Type.type(:package).new(:name => "python")
Facter.add("system_python_version") do
setcode do
- unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)])
- /^(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1]
+ begin
+ unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)])
+ /^(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1]
+ end
+ rescue
+ false
end
end
end
@@ -14,15 +18,23 @@ end
Facter.add("python_version") do
has_weight 100
setcode do
- /^.*(\d+\.\d+\.\d+)$/.match(Facter::Util::Resolution.exec('python -V 2>&1'))[1]
+ begin
+ /^.*(\d+\.\d+\.\d+)$/.match(Facter::Util::Resolution.exec('python -V 2>&1'))[1]
+ rescue
+ false
+ end
end
end
Facter.add("python_version") do
has_weight 50
setcode do
- unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)])
- /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1]
+ begin
+ unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)])
+ /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1]
+ end
+ rescue
+ false
end
end
end
diff --git a/lib/facter/virtualenv_version.rb b/lib/facter/virtualenv_version.rb
index 9a3b4b0..04736ed 100644
--- a/lib/facter/virtualenv_version.rb
+++ b/lib/facter/virtualenv_version.rb
@@ -5,15 +5,23 @@ pkg = Puppet::Type.type(:package).new(:name => "virtualenv")
Facter.add("virtualenv_version") do
has_weight 100
setcode do
- Facter::Util::Resolution.exec('virtualenv --version')
+ begin
+ Facter::Util::Resolution.exec('virtualenv --version')
+ rescue
+ false
+ end
end
end
Facter.add("virtualenv_version") do
has_weight 50
setcode do
- unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)])
- /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1]
+ begin
+ unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)])
+ /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1]
+ end
+ rescue
+ false
end
end
end