Project

General

Profile

Download (926 Bytes) Statistics
| Branch: | Tag: | Revision:
module Proxy::Puppet
class Runner
include Proxy::Log
include Proxy::Util

def initialize(opts)
@nodes = opts[:nodes]
end

protected
attr_reader :nodes

def shell_escaped_nodes
nodes.collect { |n| escape_for_shell(n) }
end

def shell_command(cmd, wait = true)
begin
c = popen(cmd)
unless wait
Process.detach(c.pid)
return 0
end
Process.wait(c.pid)
rescue Exception => e
logger.error("Exception '#{e}' when executing '#{cmd}'")
return false
end
logger.warn("Non-null exit code when executing '#{cmd}'") if $?.exitstatus != 0
$?.exitstatus == 0
end

def popen(cmd)
# 1.8.7 note: this assumes that cli options are space-separated
cmd = cmd.join(' ') if RUBY_VERSION <= '1.8.7'
logger.debug("about to execute: #{cmd}")
IO.popen(cmd)
end
end
end
(20-20/21)