rbbt-util 5.17.41 → 5.17.42

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ed9dd3f321ca95c42e5a49fc9c3eeb598ad61d6
4
- data.tar.gz: 08d83cb895399a8a883f0f3b1381865140e914d4
3
+ metadata.gz: 9f0745b484e891381f6695758305c67ca5613107
4
+ data.tar.gz: c423abd687f02d9bd62842e122acc2717ca54952
5
5
  SHA512:
6
- metadata.gz: 9efc01d608b2fd778045967ed52877f22a766e223bc813673e52a0ed7c2774c70a564d89434482de78abd0d3a1b71acec46bac799174653d5b0dc54d644cfe1a
7
- data.tar.gz: d076a19ad91b79d21b22209f3f3059041b9c06325dfbdccbb2ebcf2ec87db873d9cbc9c2d283fe25fb10439eca0b258eaa112fe6fb3493d24ee2a0581fc73606
6
+ metadata.gz: 14913302cb087a67d728f8bddcdcfe287795c03ff369ef0a746dab82810160fad0826c290c9ac47722027e91a3fc180ad020ae11e9cb4992ea374d780247a3eb
7
+ data.tar.gz: 5cb69dd9cf4401b1c87f6f18972aef61d5a287a3b1e12b3943f5024182c25e2e64ec64ce066ba7bbd3f93f73f500d56e740195d9eda74195b454e3e163155bb2
@@ -541,7 +541,7 @@ module TSV
541
541
  desc = monitor[:desc] if monitor.include? :desc
542
542
  step = monitor[:step] if monitor.include? :step
543
543
  end
544
- progress_monitor = Log::ProgressBar.new_bar(size, :desc => desc)
544
+ progress_monitor = Log::ProgressBar.new_bar(size, :desc => desc, :bytes => true)
545
545
  elsif progress_monitor
546
546
 
547
547
  size = case
@@ -551,6 +551,7 @@ module TSV
551
551
  stream.stat.size
552
552
  end
553
553
 
554
+ progress_monitor.bytes = true
554
555
  progress_monitor.max = size unless size.to_i == 0
555
556
  end
556
557
 
@@ -4,10 +4,10 @@ require 'rbbt/util/log/progress/report'
4
4
  module Log
5
5
  class ProgressBar
6
6
 
7
- attr_accessor :max, :ticks, :frequency, :depth, :desc, :file
7
+ attr_accessor :max, :ticks, :frequency, :depth, :desc, :file, :bytes
8
8
  def initialize(max = nil, options = {})
9
9
  options = Misc.add_defaults options, :depth => 0, :num_reports => 100, :desc => "Progress", :io => STDERR, :severity => Log.severity
10
- depth, num_reports, desc, io, severity, file = Misc.process_options options, :depth, :num_reports, :desc, :io, :severity, :file
10
+ depth, num_reports, desc, io, severity, file, bytes = Misc.process_options options, :depth, :num_reports, :desc, :io, :severity, :file, :bytes
11
11
 
12
12
  @max = max
13
13
  @ticks = 0
@@ -31,7 +31,7 @@ module Log
31
31
  def thr_msg
32
32
  thr = self.thr
33
33
  if @history.nil?
34
- @history ||= []
34
+ @history ||= [thr]
35
35
  else
36
36
  @history << thr
37
37
  @history.shift if @history.length > 20
@@ -73,7 +73,8 @@ module Log
73
73
  used = Misc.format_seconds(used)
74
74
  eta = [eta/3600, eta/60 % 60, eta % 60].map{|t| "%02i" % t }.join(':')
75
75
 
76
- indicator << " #{Log.color :yellow, used} used #{Log.color :yellow, eta} left - #{Log.color :yellow, ticks.to_s} of #{Log.color :yellow, @max.to_s}"
76
+ #indicator << " #{Log.color :yellow, used} used #{Log.color :yellow, eta} left - #{Log.color :yellow, ticks.to_s} of #{Log.color :yellow, @max.to_s} #{bytes ? 'bytes' : 'items'}"
77
+ indicator << " #{Log.color :yellow, eta} => #{Log.color :yellow, used} - #{Log.color :yellow, ticks.to_s} of #{Log.color :yellow, @max.to_s} #{bytes ? 'bytes' : 'items'}"
77
78
 
78
79
  indicator
79
80
  end
@@ -82,7 +83,7 @@ module Log
82
83
  str = Log.color :magenta, desc
83
84
  if @ticks == 0
84
85
  if @max
85
- return str << " " << Log.color(:yellow, "waiting on #{@max} - #{Process.pid}")
86
+ return str << " " << Log.color(:yellow, "waiting on #{@max} #{bytes ? 'bytes' : 'items'} - #{Process.pid}")
86
87
  else
87
88
  return str << " " << Log.color(:yellow, "waiting - #{Process.pid}")
88
89
  end
@@ -91,7 +92,7 @@ module Log
91
92
  if max
92
93
  str << Log.color(:blue, " -- ") << eta_msg
93
94
  else
94
- str << Log.color(:blue, " -- ") << ticks.to_s
95
+ str << Log.color(:blue, " -- ") << ticks.to_s << " #{bytes ? 'bytes' : 'items'}"
95
96
  end
96
97
  str
97
98
  end
@@ -116,6 +117,7 @@ module Log
116
117
  else
117
118
  bars = BARS
118
119
  end
120
+
119
121
  print(io, up_lines(bars.length) << Log.color(:yellow, "...Progress\n") << down_lines(bars.length))
120
122
  print(io, up_lines(@depth) << report_msg << down_lines(@depth))
121
123
  @last_time = Time.now
@@ -8,7 +8,7 @@ module Log
8
8
  def self.new_bar(max, options = {})
9
9
  cleanup_bars
10
10
  BAR_MUTEX.synchronize do
11
- Log::LAST.replace "new_bar" if Log::LAST == "progress"
11
+ #Log::LAST.replace "new_bar" if Log::LAST == "progress"
12
12
  options = Misc.add_defaults options, :depth => BARS.length
13
13
  BARS << (bar = ProgressBar.new(max, options))
14
14
  bar
@@ -239,7 +239,7 @@ class Step
239
239
 
240
240
  def progress_bar(msg, options = {})
241
241
  max = options[:max]
242
- Log::ProgressBar.new max, {:desc => msg, :file => file(:progress)}.merge(options)
242
+ Log::ProgressBar.new_bar(max, {:desc => msg, :file => file(:progress)}.merge(options))
243
243
  end
244
244
 
245
245
  def self.log(status, message, path, &block)
@@ -279,9 +279,16 @@ class Step
279
279
  end
280
280
  end
281
281
 
282
- def produce
282
+ def produce(force=true)
283
283
  return self if done? and not dirty?
284
- clean if dirty?
284
+ if error? or aborted?
285
+ if force
286
+ clean
287
+ else
288
+ raise "Error in job: #{status}"
289
+ end
290
+ end
291
+ clean if dirty?
285
292
  run(true) unless started?
286
293
  join unless done?
287
294
  self
@@ -53,5 +53,22 @@ class TestProgress < Test::Unit::TestCase
53
53
  t1.join
54
54
  t2.join
55
55
  end
56
+
57
+ def test_bar_nested
58
+ Log::ProgressBar.with_bar(20, :desc => "Bar 1") do |bar|
59
+ bar.init
60
+ 20.times do
61
+ Log::ProgressBar.with_bar(5, :desc => "Bar 2") do |bar|
62
+ 5.times do
63
+ bar.tick
64
+ sleep 0.2
65
+ end
66
+ end
67
+ bar.tick
68
+ sleep 0.2
69
+ end
70
+ end
71
+
72
+ end
56
73
  end
57
74
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.17.41
4
+ version: 5.17.42
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-02 00:00:00.000000000 Z
11
+ date: 2015-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake