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
-
#execute(command) ⇒ String
TODO: this is being loaded into memory.
Class Method Details
.execute(command) ⇒ Object
26 27 28 |
# File 'app/services/riiif/command_runner.rb', line 26 def self.execute(command) new.execute(command) end |
Instance Method Details
#execute(command) ⇒ String
TODO: this is being loaded into memory. We could make this a stream.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/services/riiif/command_runner.rb', line 11 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 ConversionError, "Unable to execute command \"#{command}\"\n#{err}" unless wait_thr.value.success? end out end |