summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJames Gartrell <jgartrel@stevenbeulow2.servepath.com>2009-03-04 11:05:30 -0800
committerjtimberman <joshua@opscode.com>2009-06-18 18:45:47 -0600
commit3835e661c761f933a795f9f5ecad96991f711705 (patch)
tree1c347a19659987fcd34614e81fb147f445a7e064 /lib
parentc4387157e51741e9830f82027bd3613b7ed3e1a1 (diff)
downloadohai-3835e661c761f933a795f9f5ecad96991f711705.tar.gz
Erlang plugin now uses run_command, also try to validate output from command so we dont access a nil array element. Coercing nil to string for Java and Python plugins to ensure that split works in all cases.
Diffstat (limited to 'lib')
-rw-r--r--lib/ohai/plugins/erlang.rb17
-rw-r--r--lib/ohai/plugins/java.rb2
-rw-r--r--lib/ohai/plugins/python.rb2
3 files changed, 7 insertions, 14 deletions
diff --git a/lib/ohai/plugins/erlang.rb b/lib/ohai/plugins/erlang.rb
index db1c4475..c96af3aa 100644
--- a/lib/ohai/plugins/erlang.rb
+++ b/lib/ohai/plugins/erlang.rb
@@ -19,27 +19,20 @@
provides "languages/erlang"
require_plugin "languages"
-require_plugin "platform"
output = nil
erlang = Mash.new
-case platform
-when /windows/
- # do nothing
- true
-else
- status = popen4("erl +V") do |pid, stdin, stdout, stderr|
- stdin.close
- output = stderr.gets.split if stderr
+status, stdout, error = run_command(:no_status_check => true, :command => "erl +V")
+
+if status == 0
+ output = stderr.to_s.split
+ if output.length >= 6
options = output[1]
options.gsub!(/(\(|\))/, '')
erlang[:version] = output[5]
erlang[:options] = options.split(',')
erlang[:emulator] = output[2].gsub!(/(\(|\))/, '')
- end
-
- if status == 0
if erlang[:version] and erlang[:options] and erlang[:emulator]
languages[:erlang] = erlang
end
diff --git a/lib/ohai/plugins/java.rb b/lib/ohai/plugins/java.rb
index d4291971..7c19c8c0 100644
--- a/lib/ohai/plugins/java.rb
+++ b/lib/ohai/plugins/java.rb
@@ -23,7 +23,7 @@ java = Mash.new
status, stdout, stderr = run_command(:no_status_check => true, :command => "java -version")
if status == 0
- stderr.split("\n").each do |line|
+ stderr.to_s.split("\n").each do |line|
case line
when /java version \"([0-9\.\_]+)\"/: java[:version] = $1
when /^(.+Runtime Environment.*) \(build (.+)\)$/: java[:runtime] = { "name" => $1, "build" => $2 }
diff --git a/lib/ohai/plugins/python.rb b/lib/ohai/plugins/python.rb
index 0ae375e8..3df29d78 100644
--- a/lib/ohai/plugins/python.rb
+++ b/lib/ohai/plugins/python.rb
@@ -35,7 +35,7 @@ status = popen4("python -c \"import sys; print sys.version\"") do |pid, stdin, s
end
if status == 0
- output = stdout.split
+ output = stdout.to_s.split
python[:version] = output[0]
if output.length >= 6
python[:builddate] = "%s %s %s %s" % [output[2],output[3],output[4],output[5].gsub!(/\)/,'')]