Class: Riiif::CommandRunner
- Inherits:
-
Object
- Object
- Riiif::CommandRunner
- Includes:
- ActiveSupport::Benchmarkable, Open3
- Defined in:
- app/services/riiif/command_runner.rb
Overview
Runs shell commands under benchmark and saves the output
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.execute(command) ⇒ Object
24 25 26 |
# File 'app/services/riiif/command_runner.rb', line 24 def self.execute(command) new.execute(command) end |
Instance Method Details
#execute(command) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/services/riiif/command_runner.rb', line 9 def execute(command) out = nil benchmark("Riiif executed #{command}") do stdin, stdout, stderr, wait_thr = popen3(command) stdin.close stdout.binmode out = stdout.read stdout.close err = stderr.read stderr.close raise "Unable to execute command \"#{command}\"\n#{err}" unless wait_thr.value.success? end out end |