Sha256: ae383e77180a5fe9ffb5413c6aa56a75b5f282b3b4c4bf8fdac552072270dede

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

#!/usr/bin/env ruby

$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') unless $LOAD_PATH.include?(File.dirname(__FILE__) + '/../lib')

require 'trollop'
require "rjobs/jobs_file"
require "rjobs/job_input_file"
require "rjobs/job"
require "rjobs/job_handler"
require 'rjobs/cli_helper'
include  Rjobs::CliHelper   

banner = "================
Submit jobs described in the YAML input file.
================
Usage:
       rjsubmit [options] <filename>
where [options] are:
"

p = parser(banner)

opts = Trollop::with_standard_exception_handling p do
  o = p.parse ARGV
  raise Trollop::HelpNeeded if ARGV.empty? # show help screen
end


jobs_input_file = ARGV[0]
raise "The file \"#{jobs_input_file}\" must exist." unless File.exist?(jobs_input_file) 


jif = Rjobs::JobInputFile.new(jobs_input_file)
jobs = []
length = jif.jobIdTo.length
(jif.jobIdFrom .. jif.jobIdTo).each do |id| 
  j = Rjobs::Job.new()
  j.name = "%s%0#{length}d" % [jif.jobName,id]
  j.command = jif.command.gsub /\$\{JobId\}/,id
  jobs << j        
end

jobs.each do |job|        
  Rjobs::JobHandler.submit_job(job)        
end

jf = Rjobs::JobsFile.new()
jf.write(jif.jobName+".rjobs",jobs)

puts "#{jobs.count} job(s) submited.".green

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rjobs-0.3.1.alpha bin/rjsubmit