Refactor Remote#execute

This commit is contained in:
Thibault Jouan 2014-09-27 13:12:02 +00:00
parent 52dcfcedd3
commit ff0287b545

View File

@ -25,7 +25,7 @@ module Producer
end end
def execute(command, output = '', error_output = '') def execute(command, output = '', error_output = '')
channel = session.open_channel do |channel| session.open_channel do |channel|
channel.exec command do |ch, success| channel.exec command do |ch, success|
ch.on_data do |c, data| ch.on_data do |c, data|
output << data output << data
@ -40,8 +40,7 @@ module Producer
fail RemoteCommandExecutionError, command if exit_status != 0 fail RemoteCommandExecutionError, command if exit_status != 0
end end
end end
end end.wait
channel.wait
output output
end end