Merge branch 'master' of http://github.com/raldred/hydra into raldred

This commit is contained in:
Nick Gauthier 2010-06-07 09:39:06 -04:00
commit d2a14be3e4
2 changed files with 19 additions and 1 deletions

View File

@ -1,11 +1,15 @@
require 'hydra/hash' require 'hydra/hash'
require 'open3' require 'open3'
require 'tmpdir' require 'tmpdir'
require 'erb'
require 'yaml' require 'yaml'
module Hydra #:nodoc: module Hydra #:nodoc:
# Hydra class responsible for delegate work down to workers. # Hydra class responsible for delegate work down to workers.
# #
# The Master is run once for any given testing session. # The Master is run once for any given testing session.
class YmlLoadError < StandardError; end
class Master class Master
include Hydra::Messages::Master include Hydra::Messages::Master
include Open3 include Open3
@ -31,7 +35,20 @@ module Hydra #:nodoc:
opts.stringify_keys! opts.stringify_keys!
config_file = opts.delete('config') { nil } config_file = opts.delete('config') { nil }
if config_file if config_file
opts.merge!(YAML.load_file(config_file).stringify_keys!)
begin
config_erb = ERB.new(IO.read(config_file)).result(binding)
rescue Exception => e
raise(YmlLoadError,"config file was found, but could not be parsed with ERB.\n#{$!.inspect}")
end
begin
config_yml = YAML::load(config_erb)
rescue StandardError => e
raise(YmlLoadError,"config file was found, but could not be parsed.\n#{$!.inspect}")
end
opts.merge!(config_yml.stringify_keys!)
end end
@files = Array(opts.fetch('files') { nil }) @files = Array(opts.fetch('files') { nil })
raise "No files, nothing to do" if @files.empty? raise "No files, nothing to do" if @files.empty?

View File

@ -27,6 +27,7 @@ module Hydra #:nodoc:
# list all the files. # list all the files.
def initialize(connection_options, directory, command) def initialize(connection_options, directory, command)
@writer, @reader, @error = popen3("ssh -tt #{connection_options}") @writer, @reader, @error = popen3("ssh -tt #{connection_options}")
@writer.write("mkdir -p #{directory}\n")
@writer.write("cd #{directory}\n") @writer.write("cd #{directory}\n")
@writer.write(command+"\n") @writer.write(command+"\n")
end end