Class: Blender::Driver::ShellOut
- Inherits:
-
Base
- Object
- Base
- Blender::Driver::ShellOut
show all
- Defined in:
- lib/blender/drivers/shellout.rb
Instance Attribute Summary
Attributes inherited from Base
#config, #events, #stderr, #stdout
Instance Method Summary
collapse
Constructor Details
#initialize(config = {}) ⇒ ShellOut
Returns a new instance of ShellOut.
23
24
25
26
27
28
29
30
|
# 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
|
Instance Method Details
#execute(tasks, hosts) ⇒ Object
32
33
34
35
36
37
38
39
40
|
# 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) ⇒ Object
42
43
44
45
46
47
48
49
50
51
|
# 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) ⇒ Object
53
54
55
56
57
|
# 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
|