2016-09-15 22:32:53 -04:00
|
|
|
require 'open3'
|
|
|
|
|
2016-07-21 22:45:39 -04:00
|
|
|
module BackupRestore
|
|
|
|
module Utils
|
2016-09-15 22:32:53 -04:00
|
|
|
def execute_command(*command, failure_message: "")
|
|
|
|
stdout, stderr, status = Open3.capture3(*command)
|
2016-07-21 22:45:39 -04:00
|
|
|
|
2016-09-15 22:32:53 -04:00
|
|
|
if !status.success?
|
2016-07-21 22:45:39 -04:00
|
|
|
failure_message = "#{failure_message}\n" if !failure_message.blank?
|
2016-09-15 22:32:53 -04:00
|
|
|
raise "#{failure_message}#{stderr}"
|
2016-07-21 22:45:39 -04:00
|
|
|
end
|
|
|
|
|
2016-09-15 22:32:53 -04:00
|
|
|
stdout
|
2016-07-21 22:45:39 -04:00
|
|
|
end
|
2016-08-03 04:18:35 -04:00
|
|
|
|
|
|
|
def pretty_logs(logs)
|
|
|
|
logs.join("\n")
|
|
|
|
end
|
2016-07-21 22:45:39 -04:00
|
|
|
end
|
|
|
|
end
|