Sha256: 95b0ff7e5f755a39f971a875b2680efe5f379003e7e6f39d8bd5b0576667e7c8

Contents?: true

Size: 1.87 KB

Versions: 53

Compression:

Stored size: 1.87 KB

Contents

#!/usr/bin/env ruby

require 'rbbt/workflow'



require 'rbbt-util'
require 'fileutils'
require 'rbbt/util/simpleopt'
require 'rbbt/workflow/step'
require 'rbbt/util/misc'

$workdir = Path.setup(File.expand_path(ARGV[0] || '.'))

def info_files
  $workdir.glob(Step.info_file('**/*'))
end

def running?(info)
  Misc.pid_exists? info[:pid]
end

def job_str(file, info, severity_color = nil)
  clean_file = file.sub('./','').sub('.info','').gsub('/', Term::ANSIColor.blue(' => '))
  if $name
    clean_file
  else
    info ||= {:status => :missing_info_file}
    str = [clean_file, info[:status].to_s] * "\t\t\t[ STATUS = " + " ]" 
    if info[:status] != :error and info[:status] != :aborted and not info[:status] == :done
      str += " (#{running?(info)? :running : :dead} #{info[:pid]})" if info[:pid]
      str += " (children: #{info[:children_pids].collect{|pid| [pid, Misc.pid_exists?(pid) ? "R" : "D"] * ":"} * ", "})" if info.include? :children_pids
    end

    if severity_color
      "#{severity_color}" <<  str  << "\033[0m" 
    else
      str
    end
  end
end

file = ARGV[0]

deps = {}

$done = []
def print(file, offset = 1)
  if not $done.include? file
    putc "*"
  end

  step = Step.new file.sub('.info','')
  
  info = step.info
  dependencies = info[:dependencies] || []
  color = case
          when (not info)
            Log::SEVERITY_COLOR[3]
          when info[:status] == :error 
            Log::SEVERITY_COLOR[3]
          when info[:status] == :aborted 
            Log::SEVERITY_COLOR[2]
          when (info[:status] != :done and info[:pid] and not running? info)
            Log::SEVERITY_COLOR[2]
          end

  puts (" " * offset * 2) << job_str(step.path, step.info, color)
  $done << file
  root = File.dirname(File.dirname(file))
  dependencies.each do |task,new_file|
    new_file = File.join(root, task.to_s, new_file)
    print(new_file, offset+1)
  end
end

print(file)

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
rbbt-util-5.8.2 share/rbbt_commands/workflow/provenance
rbbt-util-5.8.1 share/rbbt_commands/workflow/provenance
rbbt-util-5.8.0 share/rbbt_commands/workflow/provenance
rbbt-util-5.7.0 share/rbbt_commands/workflow/provenance
rbbt-util-5.6.17 share/rbbt_commands/workflow/provenance
rbbt-util-5.6.16 share/rbbt_commands/workflow/provenance
rbbt-util-5.6.15 share/rbbt_commands/workflow/provenance
rbbt-util-5.6.14 share/rbbt_commands/workflow/provenance
rbbt-util-5.6.13 share/rbbt_commands/workflow/provenance
rbbt-util-5.6.12 share/rbbt_commands/workflow/provenance
rbbt-util-5.6.11 share/rbbt_commands/workflow/provenance
rbbt-util-5.6.10 share/rbbt_commands/workflow/provenance
rbbt-util-5.6.9 share/rbbt_commands/workflow/provenance