Sha256: 1b6770841eb079d659677d3220c79f67539208f7d0a81726f446abbb08e57b2e
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 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" require "rjobs/job_handler" require 'rjobs/cli_helper' include Rjobs::CliHelper banner = "================ Get the status of jobs described in the jobs file. ================ Usage: rjstatus [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 o end Rjobs::JobHandler.host = opts[:host] Rjobs::JobHandler.password = opts[:password] jobs_file = ARGV[0] raise "The file \"#{jobs_file}\" must exist." unless File.exist?(jobs_file) jobs = get_jobs_info(jobs_file) jFinished = 0 jRunning = 0 jPending = 0 jFailed = 0 jNE =0 jobs.each do |job| puts "#{job.name} - #{job.status_with_color}" case job.status when /Finished/ jFinished +=1 when /Running/ jRunning +=1 when /Failed/ jFailed +=1 when /Not Exist/ jNE+=1 else jPending +=1 end end #output number of success jobs - pending jobs - failed jobs sFinish = "#{jFinished} finished".green sRunning = "- #{jRunning} running".blue if jRunning > 0 sPending = "- #{jPending} pending" if jPending > 0 sFailed = "- #{jFailed} failed".red if jFailed > 0 sNE = "- #{jNE} not exist".red if jNE > 0 puts "#{jobs.count} jobs: #{sFinish} #{sRunning} #{sPending} #{sFailed} #{sNE}"
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rjobs-0.3.3.alpha | bin/rjstatus |
rjobs-0.3.2.alpha | bin/rjstatus |