Sha256: 072a0aa315dc5f64d6d3925831192a60c8ff5cf676ad322d27bb80dfe84d97d8

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 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
  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.0.alpha bin/rjsubmit