module Patriot::Tool::PatriotCommands::Execute
execute PBC directory
Public Instance Methods
create_job_store_with_commands(commands, config)
click to toggle source
# File lib/patriot/tool/patriot_commands/execute.rb, line 65 def create_job_store_with_commands(commands, config) job_store = Patriot::JobStore::InMemoryStore.new(Patriot::JobStore::ROOT_STORE_ID, config) # ignore products not defined here products = commands.map{|cmd| cmd['products']}.flatten.compact jobs = commands.map do |cmd| cmd.instance_variable_set(:@state, Patriot::JobStore::JobState::INIT) cmd['requisites'].delete_if{|ref| !products.include?(ref)} cmd.to_job end job_store.register(Time.now.to_i, jobs) return job_store end
execute(date, *paths)
click to toggle source
# File lib/patriot/tool/patriot_commands/execute.rb, line 29 def execute(date, *paths) begin # set config/options opts = symbolize_options(options) conf = {:type => 'execute'} conf[:path] = opts[:config] if opts.has_key?(:config) config = load_config(conf) if opts[:debug] && opts[:test] message = "invalid option: both of debug and test are specified" raise ArgumentError, message end # parse and process commands parser = Patriot::Tool::BatchParser.new(config) commands = parser.process(date, paths, opts) if opts[:strict] job_store = create_job_store_with_commands(commands, config) until (executables = job_store.get_job_tickets(nil,nil)).empty? executables.each do |job_ticket| cmd = job_store.offer_to_execute(job_ticket) execute_command(cmd[:command], opts) job_ticket.exit_code = Patriot::Command::ExitCode::SUCCEEDED job_store.report_completion_status(job_ticket) end end else commands.each{|cmd| execute_command(cmd, opts)} end rescue => e puts e.message $@.each {|message| puts message} raise e end end
execute_command(command, opts = {})
click to toggle source
# File lib/patriot/tool/patriot_commands/execute.rb, line 78 def execute_command(command, opts = {}) puts "executing #{command.job_id}" if opts[:debug] puts command.description return end command.test_mode = true if opts[:test] command.execute end