Sha256: 3804511b069a2ec91a8f48e7e44768ba9d335867cf88a6af637fa815df84fcae
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 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) p.opt :outputFile , "The file that store the mapping between JobName and JobId", :type => String, :default => "" opts = Trollop::with_standard_exception_handling p do o = p.parse ARGV raise Trollop::HelpNeeded if ARGV.empty? # show help screen o end Rjobs::JobHandler.host = opts[:host] Rjobs::JobHandler.password = opts[:password] 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) outputFile = opts[:outputFile].empty? ? "#{jif.jobName}.rjobs" : opts[:outputFile]; if File.exist?(outputFile) continue = true while continue print "File #{outputFile} exists. Would you like to overwrite it? [y/n]: " case STDIN.gets when /^[Yy](es)?$/ continue = false when /^[nN]o?$/ #n or no Process.exit end end end 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(outputFile, jobs) puts "#{jobs.count} job(s) submited.".green
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rjobs-0.3.3.alpha | bin/rjsubmit |