Sha256: ad328cf0c4a20aa384185108883b2175b8cee472a4e8039f51b77ca4318df674

Contents?: true

Size: 1.93 KB

Versions: 8

Compression:

Stored size: 1.93 KB

Contents

#!/usr/bin/env ruby

require 'rbbt/workflow'

require 'rbbt-util'
require 'rbbt-util'
require 'rbbt/util/simpleopt'

$0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands

options = SOPT.setup <<EOF
Examine the info of a job result

$ rbbt workflow info <job-result>

-h--help Help
EOF

SOPT.usage if options[:help]

file = ARGV.shift

def get_step(file)
  file = file.sub(/\.(info|files)/,'')
  Step.new file
end

def status_msg(status)
  color = case status
          when :error, :aborted, :missing
            :red
          when :streaming
            :yellow
          when :done
            :green
          else
            nil
          end
  Log.color(color, status)
end

step = get_step file

info = step.info
dependencies = info[:dependencies]
inputs = info[:inputs]
status = info[:status]
time = info[:time_elapsed]
messages = info[:messages]

puts Log.color(:magenta, "File") << ": " << step.path
puts Log.color(:magenta, "Status") << ": " << status_msg(status)
puts Log.color(:magenta, "Time") << ": " << time.to_i.to_s << " sec." if time
if inputs and inputs.any?
  puts Log.color(:magenta, "Inputs")
  inputs.each do |input,value|
    case value
    when nil
      puts "  " << Misc.format_definition_list_item(input, 'nil', 80, 20, :blue)
    when Array
      puts "  " << Misc.format_definition_list_item(input, value[0..5]*"\n", 80, 20, :blue)
    when TrueClass, FalseClass
      puts "  " << Misc.format_definition_list_item(input, value.to_s, 80, 20, :blue)
    else
      text = value.to_s.split("\n")[0..5].compact * "\n\n"
      puts "  " << Misc.format_definition_list_item(input, text, 80, 20, :blue)
    end
  end
end

if dependencies and dependencies.any?
  puts Log.color(:magenta, "Dependencies") << ": "
  dependencies.each do |name,task,file|
    puts "  " << file
  end 
end

if messages and messages.any?
  puts Log.color(:magenta, "Messages") << ": "
  messages.each do |msg|
    puts "  " << msg
  end 
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rbbt-util-5.13.37 share/rbbt_commands/workflow/info
rbbt-util-5.13.36 share/rbbt_commands/workflow/info
rbbt-util-5.13.35 share/rbbt_commands/workflow/info
rbbt-util-5.13.34 share/rbbt_commands/workflow/info
rbbt-util-5.13.33 share/rbbt_commands/workflow/info
rbbt-util-5.13.32 share/rbbt_commands/workflow/info
rbbt-util-5.13.31 share/rbbt_commands/workflow/info
rbbt-util-5.13.30 share/rbbt_commands/workflow/info