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.13.5 share/rbbt_commands/workflow/provenance
rbbt-util-5.13.4 share/rbbt_commands/workflow/provenance
rbbt-util-5.13.3 share/rbbt_commands/workflow/provenance
rbbt-util-5.13.2 share/rbbt_commands/workflow/provenance
rbbt-util-5.13.1 share/rbbt_commands/workflow/provenance
rbbt-util-5.13.0 share/rbbt_commands/workflow/provenance
rbbt-util-5.12.3 share/rbbt_commands/workflow/provenance
rbbt-util-5.12.2 share/rbbt_commands/workflow/provenance
rbbt-util-5.12.1 share/rbbt_commands/workflow/provenance
rbbt-util-5.12.0 share/rbbt_commands/workflow/provenance
rbbt-util-5.11.9 share/rbbt_commands/workflow/provenance
rbbt-util-5.11.8 share/rbbt_commands/workflow/provenance
rbbt-util-5.11.7 share/rbbt_commands/workflow/provenance
rbbt-util-5.11.6 share/rbbt_commands/workflow/provenance
rbbt-util-5.11.5 share/rbbt_commands/workflow/provenance
rbbt-util-5.11.4 share/rbbt_commands/workflow/provenance
rbbt-util-5.11.3 share/rbbt_commands/workflow/provenance
rbbt-util-5.11.2 share/rbbt_commands/workflow/provenance
rbbt-util-5.11.1 share/rbbt_commands/workflow/provenance
rbbt-util-5.10.2 share/rbbt_commands/workflow/provenance