90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/utilities.rb', line 90
def execute_command(command)
*commands=command
if is_jruby?
*commands = RbConfig::CONFIG['SHELL'], is_windows? ? "/C" : "-c", command
end
Open3.popen3(*commands) do |stdin, stdout, stderr, thread|
logs = {:out => "", :err => ""}
if block_given?
{ :out => stdout, :err => stderr }.each do |key, stream|
Thread.new do
while line = stream.gets
privatized_line = BrpmAuto.privatize(line)
logs[key] += privatized_line
yield privatized_line
end
end if block_given?
end
thread.join
else
logs[:out] = stdout.read
logs[:err] = stderr.read
end
return logs[:out], logs[:err], thread.pid, thread.value
end
end
|