rbbt-util 5.23.27 → 5.23.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 727fd7ea14a972a4bbd10a93b3d5ff270f049d7d
4
- data.tar.gz: 8f60c11ea14eca70d231e8a4e55208a51207d989
3
+ metadata.gz: 2275f8b0ef9e0fd2bf6a6b964aa0bb8541f7bd35
4
+ data.tar.gz: 3ddc1b829d1990a27fbbfec708cc41e89a7b4926
5
5
  SHA512:
6
- metadata.gz: 4bfcfd6f510295128945a4f3a759b755777063776f5b9478e3c94865854ecbc755714d61a9bb783b5beb18fd88f85ce03b4e87aa26f4bf794e40acee282f3972
7
- data.tar.gz: 9c7d620f5acd24e129c210fe35476b8f055bb5170ce5698217b90406fc314b3b9a02d2d80142a5c744f5817f0c84ccdae6a1dd4a57b34703aa47a4a6b70ba8c9
6
+ metadata.gz: fd83f6e4487f0f36f33720ded3a875cb123c4bb1398b69ab49affb229af0b1b5e63a464ea74bf1a4946929a68bf334087163de762cc1edc6b7ae85c4cd908947
7
+ data.tar.gz: 19109b2be3083248f31b1fb9cad1596b201f4801566d7c3a608fe24536557e44611f5a224f9cdd1e7a76aab17c7e3834c84037243e2a16254b80b7903319c6d6
@@ -105,7 +105,7 @@ module TSV
105
105
  workbook = Spreadsheet.open Open.open(file)
106
106
 
107
107
  if sheet && sheet.to_s =~ /^\d+$/
108
- sheet = workbook.worksheets.collect{|s| s.sheet_name }[sheet.to_i]
108
+ sheet = workbook.worksheets.collect{|s| s.name }[sheet.to_i]
109
109
  end
110
110
  sheet_name = sheet
111
111
  Log.debug "Opening LSX #{file} sheet #{ sheet_name }"
@@ -1,5 +1,6 @@
1
1
  require 'rbbt/util/log'
2
2
  require 'stringio'
3
+ require 'open3'
3
4
 
4
5
  module CMD
5
6
 
@@ -53,50 +54,58 @@ module CMD
53
54
 
54
55
  in_content = StringIO.new in_content if String === in_content
55
56
 
56
- sout, serr, sin = Misc.pipe, Misc.pipe, Misc.pipe
57
+ #sout, serr, sin = Misc.pipe, Misc.pipe, Misc.pipe
57
58
 
58
- pid = fork {
59
- begin
60
- Misc.purge_pipes(sin.last,sout.last,serr.last)
59
+ #pid = fork {
60
+ # begin
61
+ # Misc.purge_pipes(sin.last,sout.last,serr.last)
61
62
 
62
- sin.last.close
63
- sout.first.close
64
- serr.first.close
63
+ # sin.last.close
64
+ # sout.first.close
65
+ # serr.first.close
65
66
 
66
- if IO === in_content
67
- in_content.close if in_content.respond_to?(:close) and not in_content.closed?
68
- end
67
+ # if IO === in_content
68
+ # in_content.close if in_content.respond_to?(:close) and not in_content.closed?
69
+ # end
69
70
 
70
- STDERR.reopen serr.last
71
- serr.last.close
71
+ # STDERR.reopen serr.last
72
+ # serr.last.close
72
73
 
73
- STDIN.reopen sin.first
74
- sin.first.close
74
+ # STDIN.reopen sin.first
75
+ # sin.first.close
75
76
 
76
- STDOUT.reopen sout.last
77
- sout.last.close
77
+ # STDOUT.reopen sout.last
78
+ # sout.last.close
78
79
 
79
- STDOUT.sync = STDERR.sync = true
80
+ # STDOUT.sync = STDERR.sync = true
80
81
 
81
- exec(ENV, cmd)
82
+ # exec(ENV, cmd)
82
83
 
83
- exit(-1)
84
- rescue Exception
85
- Log.debug{ "ProcessFailed: #{$!.message}" } if log
86
- Log.debug{ "Backtrace: \n" + $!.backtrace * "\n" } if log
87
- raise ProcessFailed, $!.message
88
- end
89
- }
84
+ # exit(-1)
85
+ # rescue Exception
86
+ # Log.debug{ "ProcessFailed: #{$!.message}" } if log
87
+ # Log.debug{ "Backtrace: \n" + $!.backtrace * "\n" } if log
88
+ # raise ProcessFailed, $!.message
89
+ # end
90
+ #}
90
91
 
91
- sin.first.close
92
- sout.last.close
93
- serr.last.close
92
+ #sin.first.close
93
+ #sout.last.close
94
+ #serr.last.close
94
95
 
95
96
 
96
- sin = sin.last
97
- sout = sout.first
98
- serr = serr.first
97
+ #sin = sin.last
98
+ #sout = sout.first
99
+ #serr = serr.first
99
100
 
101
+ sin, sout, serr, wait_thr = begin
102
+ Open3.popen3(ENV, cmd)
103
+ rescue
104
+ Log.warn $!.message
105
+ raise ProcessFailed, cmd unless no_fail
106
+ return
107
+ end
108
+ pid = wait_thr.pid
100
109
 
101
110
  Log.debug{"CMD: [#{pid}] #{cmd}" if log}
102
111
 
@@ -160,10 +169,9 @@ module CMD
160
169
  out = StringIO.new sout.read
161
170
  sout.close unless sout.closed?
162
171
 
163
- Process.waitpid pid
164
-
165
- if not $?.success? and not no_fail
166
- raise ProcessFailed.new "Command [#{pid}] #{cmd} failed with error status #{$?.exitstatus}.\n#{err}"
172
+ status = wait_thr.value
173
+ if not status.success? and not no_fail
174
+ raise ProcessFailed.new "Command [#{pid}] #{cmd} failed with error status #{status.exitstatus}.\n#{err}"
167
175
  else
168
176
  Log.log err, stderr if Integer === stderr and log
169
177
  end
@@ -126,7 +126,7 @@ class RbbtProcessQueue
126
126
  @count += 1
127
127
  @total -= 1
128
128
  next unless processes.length > 1
129
- last = processes.last
129
+ last = processes.reject{|p| p.stopping }.last
130
130
  last.stop
131
131
  Log.warn "Removed process #{last.pid} from #{Process.pid} (#{processes.length})"
132
132
  end
@@ -1,7 +1,7 @@
1
1
  require 'rbbt/util/concurrency/processes/socket'
2
2
  class RbbtProcessQueue
3
3
  class RbbtProcessQueueWorker
4
- attr_reader :pid, :queue, :callback_queue, :cleanup, :block
4
+ attr_reader :pid, :queue, :callback_queue, :cleanup, :block, :stopping
5
5
 
6
6
  class Respawn < Exception
7
7
  attr_accessor :payload
@@ -277,6 +277,7 @@ class RbbtProcessQueue
277
277
 
278
278
  def stop
279
279
  begin
280
+ @stoping = true
280
281
  Process.kill :USR2, @pid
281
282
  rescue Errno::ESRCH
282
283
  rescue Exception
@@ -84,13 +84,14 @@ module Rbbt::Config
84
84
  l =~ /rbbt\/(?:resource\.rb|workflow\.rb)/ or
85
85
  l =~ /rbbt\/resource\/path\.rb/ or
86
86
  l =~ /rbbt\/util\/misc\.rb/ or
87
+ l =~ /accessor\.rb/ or
87
88
  l =~ /progress-monitor\.rb/
88
89
  }.first.partition(":")
89
90
 
90
91
  File.expand_path(file)
91
92
 
92
93
  tokens << ("file:" << file)
93
- tokens << ("line:" << file << ":" << line)
94
+ tokens << ("line:" << file << ":" << line.sub(/:in \`.*/,''))
94
95
 
95
96
  entries = CACHE[key.to_s]
96
97
  priorities = {}
@@ -105,7 +106,9 @@ module Rbbt::Config
105
106
 
106
107
  return nil if priorities.empty?
107
108
 
108
- priorities.sort_by{|p,v| p}.first.last.first
109
+ value = priorities.sort_by{|p,v| p}.first.last.first
110
+ Log.debug "Value '#{value}' for config key '#{ key }': #{tokens * ", "}"
111
+ value
109
112
  end
110
113
 
111
114
  self.load_config
@@ -252,6 +252,7 @@ module Misc
252
252
  end
253
253
  tee1, *rest = Misc.tee_stream stream_dup, num + 1
254
254
  stream.reopen(tee1)
255
+ tee1.annotate(stream)
255
256
  rest
256
257
  end
257
258
 
@@ -426,7 +426,7 @@ module Open
426
426
  exists_in_repo(*dir_sub_path)
427
427
  else
428
428
  file = file.find if Path === file
429
- File.exist?(file) || File.symlink?(file)
429
+ File.exist?(file) #|| File.symlink?(file)
430
430
  end
431
431
  end
432
432
  class << self
@@ -711,8 +711,8 @@ module Open
711
711
  get_time_from_repo(*dir_sub_path)
712
712
  else
713
713
  file = file.find if Path === file
714
- file = Pathname.new(file).realpath.to_s if File.symlink?(file)
715
714
  begin
715
+ file = Pathname.new(file).realpath.to_s if File.symlink?(file)
716
716
  File.mtime(file)
717
717
  rescue
718
718
  nil
@@ -315,7 +315,7 @@ module Workflow
315
315
  missing_inputs = []
316
316
  task.required_inputs.each do |input|
317
317
  missing_inputs << input if inputs[input].nil?
318
- end
318
+ end if task.required_inputs
319
319
 
320
320
  if missing_inputs.length == 1
321
321
  raise ParameterException, "Input #{missing_inputs.first} is required but was not provided or is nil"
@@ -436,7 +436,7 @@ class Step
436
436
  else
437
437
  e = get_exception
438
438
  if e
439
- Log.error "Raising exception in produced job #{job.path}: #{e.message}"
439
+ Log.error "Raising exception in produced job #{self.path}: #{e.message}"
440
440
  raise e
441
441
  else
442
442
  raise "Error in job: #{self.path}"
@@ -97,10 +97,12 @@ TSV.traverse jobs, :_bar => "Checking job status" do |file,i|
97
97
  pid = info[:pid]
98
98
 
99
99
  status = info[:status].to_s
100
- status = :missing if status == "done" and not File.exist? file
101
- status = :nopid if status != "done" and pid.nil?
102
- status = :dead if status != "done" and pid and not Misc.pid_exists?(pid)
103
- status = :sync if status != "done" and File.exist? file
100
+ if status != "noinfo"
101
+ status = :missing if status == "done" and not File.exist? file
102
+ status = :nopid if status != "done" and pid.nil?
103
+ status = :dead if status != "done" and pid and not Misc.pid_exists?(pid)
104
+ status = :sync if status != "done" and File.exist? file
105
+ end
104
106
 
105
107
  status = :dirty if info[:status].to_s == "done" and dirty and Workflow.load_step(file).dirty?
106
108
  if info[:status] == :error
@@ -120,6 +120,7 @@ def report(step, offset = 0, task = nil)
120
120
  path = dep.path
121
121
  new = ! $seen.include?(path)
122
122
  if new
123
+ $seen << path
123
124
  str << report(dep, offset + 1, task)
124
125
  else
125
126
  str << Log.color(:blue, Log.uncolor(report(dep, offset+1, task)))
@@ -35,8 +35,8 @@ class TestCmd < Test::Unit::TestCase
35
35
  assert_raise ProcessFailed do CMD.cmd('fake-command', :stderr => true) end
36
36
  assert_raise ProcessFailed do CMD.cmd('ls -fake_option', :stderr => true) end
37
37
 
38
- assert_nothing_raised ProcessFailed do CMD.cmd('fake-command', :stderr => false, :pipe => true) end
39
- assert_nothing_raised ProcessFailed do CMD.cmd('ls -fake_option', :stderr => false, :pipe => true) end
38
+ assert_nothing_raised ProcessFailed do CMD.cmd('fake-command', :no_fail => true, :pipe => true) end
39
+ assert_nothing_raised ProcessFailed do CMD.cmd('ls -fake_option', :no_fail => true, :pipe => true) end
40
40
 
41
41
  assert_raise ProcessFailed do CMD.cmd('fake-command', :stderr => true, :pipe => true).join end
42
42
  assert_raise ProcessFailed do CMD.cmd('ls -fake_option', :stderr => true, :pipe => true).join end
@@ -63,4 +63,16 @@ line33
63
63
  end
64
64
  end
65
65
 
66
+ def test_STDIN_close
67
+ TmpFile.with_file("Hello") do |file|
68
+ STDIN.close
69
+ Open.open(file) do |f|
70
+ io = CMD.cmd("tr 'e' 'E'", :in => f, :pipe => true)
71
+ txt = io.read
72
+ io.join
73
+ assert_equal "HEllo", txt
74
+ end
75
+ end
76
+ end
77
+
66
78
  end
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.23.27
4
+ version: 5.23.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-24 00:00:00.000000000 Z
11
+ date: 2018-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake