rbbt-util 5.13.24 → 5.13.25

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: 4cb02f1584dee7188f5a2bc771f733eb81c46f1a
4
- data.tar.gz: 47850a9f40b69fc8cb761dbefea3aec895c1c955
3
+ metadata.gz: 5239dbb15f48c166b31834d3f927f4c46103dd2d
4
+ data.tar.gz: eef931195c348851b6aeb3de3ba35f4e043884f6
5
5
  SHA512:
6
- metadata.gz: f3459787e3d4aa401917919e6a70bbb4c314477dbce5f9251f0723dbc905af70170f0e844b6d905fe9fd86a232acd1cc98553d3ed84ebca91743a06f0149610c
7
- data.tar.gz: 2028a7f0dc8de1adfb4a69e54f139d4a2a329c6e094b4043618792314874e7ee4da08b72327912800d899cca258cccbf015dee6f10f13ffabb9283132f823929
6
+ metadata.gz: 60e3af52f609fce5ac4ef7c129bc31dff0bf06576bad4b10e2dabb9840388240bc4556f01eb045b24a0bd4206b8e7dde95566d3bb7fd01d88153e37f21f9e1ed
7
+ data.tar.gz: 50a0e08c13bb120b2b111de91f6446eb9d42cd0b6ca1897e8a2308e1f547cf2bb7d4d1198eeecf89ce2c2bf457456e3234403726cbdc314c2dcd8519187ee33f
data/bin/rbbt CHANGED
@@ -1,8 +1,34 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ dev_dir = nil
4
+ if _i = ARGV.index("--dev")
5
+ dev_dir = ARGV[_i+1]
6
+ ARGV.delete "--dev"
7
+ end
8
+
9
+ if dev_dir.nil?
10
+ _s = nil
11
+ ARGV.each_with_index do |s,i|
12
+ if s.match(/^--dev(?:=(.*))?/)
13
+ dev_dir = $1
14
+ _s = s
15
+ next
16
+ end
17
+ end
18
+ ARGV.delete _s if _s
19
+ end
20
+
21
+ if dev_dir
22
+ Dir.glob(File.join(File.expand_path(dev_dir),'rbbt-*')).each do |f|
23
+ $LOAD_PATH << f
24
+ end
25
+ end
26
+
3
27
  require 'rbbt'
4
28
  require 'rbbt/util/simpleopt'
5
29
 
30
+ Log.nocolor = true if ARGV.include? "--nocolor"
31
+
6
32
  options = SOPT.setup <<EOF
7
33
  Ruby bioinformatics toolkit
8
34
 
@@ -10,6 +36,7 @@ $ rbbt <command> <subcommand> ... -a --arg1 --arg2='value' --arg3 'another-value
10
36
 
11
37
 
12
38
  --log* #{Log.color :yellow, "Log level from 0 (debug) 6 (errors)"}
39
+ --dev* #{Log.color :yellow, "Find development libraries in the directory specified"}
13
40
  -cd--command_dir* #{Log.color :yellow, "Directory from where to load command scripts"}
14
41
  --profile #{Log.color :yellow, "Profile execution"}
15
42
  --nocolor #{Log.color :yellow, "Disable colored output"}
@@ -17,10 +44,6 @@ $ rbbt <command> <subcommand> ... -a --arg1 --arg2='value' --arg3 'another-value
17
44
  --locate_file #{Log.color :yellow, "Report the location of the script instead of executing it"}
18
45
  EOF
19
46
 
20
- if options[:nocolor]
21
- Log.nocolor = true
22
- end
23
-
24
47
  if options.delete :nobar
25
48
  ENV["RBBT_NO_PROGRESS"] = "true"
26
49
  end
@@ -29,7 +52,14 @@ locate = options.delete :locate_file
29
52
 
30
53
  if options[:log]
31
54
  Log.severity = options[:log].to_i
32
- SOPT.input_descriptions.each{|t,d| d.replace Log.uncolor(d) }
55
+ else
56
+ global_severity = Log.get_level(Rbbt.etc.log_severity.read.strip) if Rbbt.etc.log_severity.exists?
57
+ if ENV["RBBT_LOG"]
58
+ Log.severity = ENV["RBBT_LOG"].to_i
59
+ else
60
+ global_severity = Log.get_level(Rbbt.etc.log_severity.read.strip) if Rbbt.etc.log_severity.exists?
61
+ Log.severity = global_severity.to_i if global_severity
62
+ end
33
63
  end
34
64
 
35
65
  if options[:command_dir]
data/lib/rbbt/resource.rb CHANGED
@@ -65,7 +65,8 @@ module Resource
65
65
  begin
66
66
  @server_missing_resource_cache ||= Set.new
67
67
  raise "Resource Not Found" if @server_missing_resource_cache.include? url
68
- Net::HTTP.get_response URI(url) do |response|
68
+ Misc.lock final_path do
69
+ Net::HTTP.get_response URI(url) do |response|
69
70
  case response
70
71
  when Net::HTTPSuccess, Net::HTTPOK
71
72
  Misc.sensiblewrite(final_path) do |file|
@@ -77,15 +78,19 @@ module Resource
77
78
  location = response['location']
78
79
  Log.debug("Feching directory from: #{location}. Into: #{final_path}")
79
80
  FileUtils.mkdir_p final_path unless File.exists? final_path
80
- Misc.in_dir final_path do
81
- CMD.cmd('tar xvfz -', :in => Open.open(location, :nocache => true))
81
+ TmpFile.with_file do |tmp_dir|
82
+ Misc.in_dir tmp_dir do
83
+ CMD.cmd('tar xvfz -', :in => Open.open(location, :nocache => true))
84
+ end
82
85
  end
86
+ File.utils tmp_dir, final_path
83
87
  when Net::HTTPInternalServerError
84
88
  @server_missing_resource_cache << url
85
89
  raise "Resource Not Found"
86
90
  else
87
91
  raise "Response not understood: #{response.inspect}"
88
92
  end
93
+ end
89
94
  end
90
95
  rescue
91
96
  Log.warn "Could not retrieve (#{self.to_s}) #{ path } from #{ remote_server }"
@@ -459,6 +459,7 @@ module TSV
459
459
  stream.abort if stream and stream.respond_to? :abort
460
460
  stream = obj_stream(into)
461
461
  stream.abort if stream and stream.respond_to? :abort
462
+ parent.raise $!
462
463
  raise $!
463
464
  end
464
465
  end
data/lib/rbbt/util/log.rb CHANGED
@@ -205,7 +205,7 @@ module Log
205
205
  error("BACKTRACE:\n" + e.backtrace * "\n")
206
206
  end
207
207
 
208
- case ENV['RBBT_LOG']
208
+ case ENV['RBBT_LOG']
209
209
  when 'DEBUG'
210
210
  self.severity = DEBUG
211
211
  when 'LOW'
@@ -54,10 +54,6 @@ module ConcurrentStream
54
54
  if @threads and @threads.any?
55
55
  @threads.each do |t|
56
56
  t.join unless t == Thread.current
57
- #begin
58
- #ensure
59
- # t.join unless t == Thread.current
60
- #end
61
57
  end
62
58
  @threads = []
63
59
  end
@@ -94,7 +90,33 @@ module ConcurrentStream
94
90
  end
95
91
 
96
92
  def abort_threads
97
- @threads.each{|t| t.raise Aborted.new unless t == Thread.current } if @threads
93
+ Log.medium "Aborting threads (#{Thread.current.inspect}) #{@threads.collect{|t| t.inspect } * ", "}"
94
+
95
+ @threads.each do |t|
96
+ @aborted = false if t == Thread.current
97
+ next if t == Thread.current
98
+ Log.medium "Aborting thread #{t.inspect}"
99
+ t.raise Aborted.new "Hey"
100
+ end if @threads
101
+
102
+ sleeped = false
103
+ @threads.each do |t|
104
+ next if t == Thread.current
105
+ if t.alive?
106
+ sleep 1 unless sleeped
107
+ sleeped = true
108
+ Log.medium "Kill thread #{t.inspect}"
109
+ t.kill
110
+ end
111
+ begin
112
+ Log.medium "Join thread #{t.inspect}"
113
+ t.join unless t == Thread.current
114
+ rescue Aborted
115
+ rescue Exception
116
+ Log.exception $!
117
+ end
118
+ end
119
+ Log.medium "Aborted threads (#{Thread.current.inspect}) #{@threads.collect{|t| t.inspect } * ", "}"
98
120
  end
99
121
 
100
122
  def abort_pids
@@ -103,9 +125,9 @@ module ConcurrentStream
103
125
  end
104
126
 
105
127
  def abort
106
- Log.medium "Aborting stream #{Misc.fingerprint self} -- #{@abort_callback} [#{@aborted}]"
107
128
  return if @aborted
108
- @aborted = true
129
+ Log.medium "Aborting stream #{Misc.fingerprint self} -- #{@abort_callback} [#{@aborted}]"
130
+ @aborted = true
109
131
  begin
110
132
  @callback = nil
111
133
  @abort_callback.call if @abort_callback
@@ -115,6 +137,7 @@ module ConcurrentStream
115
137
  abort_threads
116
138
  abort_pids
117
139
  end
140
+ Log.medium "Aborted stream #{Misc.fingerprint self} -- #{@abort_callback} [#{@aborted}]"
118
141
  end
119
142
 
120
143
  def super(*args)
@@ -358,6 +358,7 @@ class Step
358
358
  #stream.close unless stream.closed?
359
359
  rescue Aborted
360
360
  Log.medium "Aborting job stream #{stream.inspect} ABORTED RETRY -- #{Log.color :blue, path}"
361
+ Log.exception $!
361
362
  retry
362
363
  end
363
364
  end
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rbbt-util'
4
+ require 'rbbt/util/simpleopt'
5
+
6
+ $0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands
7
+
8
+ options = SOPT.setup <<EOF
9
+
10
+ Change log level
11
+
12
+ $ rbbt log <level>
13
+
14
+ DEBUG
15
+ LOW
16
+ MEDIUM
17
+ HIGH
18
+ INFO
19
+ WARN
20
+ ERROR
21
+
22
+ -h--help Print this help
23
+
24
+ EOF
25
+ rbbt_usage and exit 0 if options[:help]
26
+ if ARGV.empty?
27
+ puts Rbbt.etc.log_severity.read
28
+ else
29
+ Open.write(Rbbt.etc.log_severity, ARGV[0].upcase)
30
+ end
31
+
32
+
@@ -55,6 +55,8 @@ if inputs and inputs.any?
55
55
  puts Log.color(:magenta, "Inputs")
56
56
  inputs.each do |input,value|
57
57
  case value
58
+ when nil
59
+ puts " " << Misc.format_definition_list_item(input, 'nil', 80, 20, :blue)
58
60
  when Array
59
61
  puts " " << Misc.format_definition_list_item(input, value[0..5]*"\n", 80, 20, :blue)
60
62
  when TrueClass, FalseClass
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.13.24
4
+ version: 5.13.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-29 00:00:00.000000000 Z
11
+ date: 2014-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -236,6 +236,7 @@ files:
236
236
  - share/rbbt_commands/file_server/add
237
237
  - share/rbbt_commands/file_server/list
238
238
  - share/rbbt_commands/file_server/remove
239
+ - share/rbbt_commands/log
239
240
  - share/rbbt_commands/resource/exists
240
241
  - share/rbbt_commands/resource/find
241
242
  - share/rbbt_commands/resource/get