class Blender::Driver::ShellOut

Public Class Methods

new(config = {}) click to toggle source
Calls superclass method Blender::Driver::Base::new
# File lib/blender/drivers/shellout.rb, line 23
def initialize(config = {})
  @options = {}
  cfg = config.dup
  [:user, :group, :cwd, :umask, :returns, :environment, :timeout].each do |key|
    @options[key] = cfg.delete(key) if cfg.key?(key)
  end
  super(cfg)
end

Public Instance Methods

execute(tasks, hosts) click to toggle source
# File lib/blender/drivers/shellout.rb, line 32
def execute(tasks, hosts)
  verify_local_host!(hosts)
  tasks.each do |task|
    cmd = run_command(task.command)
    if cmd.exitstatus != 0 and !task.metadata[:ignore_failure]
      raise ExecutionFailed, cmd.stderr
    end
  end
end
run_command(command) click to toggle source
# File lib/blender/drivers/shellout.rb, line 42
def run_command(command)
  cmd = Mixlib::ShellOut.new(command, @options)
  begin
    cmd.live_stream = stdout
    cmd.run_command
    ExecOutput.new(cmd.exitstatus, cmd.stdout, cmd.stderr)
  rescue Errno::ENOENT => e
    ExecOutput.new(-1, '', e.message)
  end
end
verify_local_host!(hosts) click to toggle source
# File lib/blender/drivers/shellout.rb, line 53
def verify_local_host!(hosts)
  unless hosts.all?{|h|h == 'localhost'}
    raise UnsupportedFeature, 'This driver does not support any host other than localhost'
  end
end