rbbt-util 5.6.8 → 5.6.9

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: 604a8028d6171f4fbffbc559fdb542860e8fad07
4
- data.tar.gz: 7ceb01cd346987e440d5ded8aec7e741ade11831
3
+ metadata.gz: 3a45eff8cafc9d26b4eb4e6c670af1d2fe17ec0d
4
+ data.tar.gz: e889c0fafcc84778750f7093ed9a1a408de7c31f
5
5
  SHA512:
6
- metadata.gz: 635cec0dc4621e5a5414e6894c5e9c5d146f152fd7aabdb1b6fdca8b8ad6689f7e0bdbe6d52cd3853f5b62aec4fcea6bd8a15322951419baa5eb59b80f5cd669
7
- data.tar.gz: 87d12e3c415a8bf309b952dbc71ab73d40912e19d3e28a123fc2e5aedac661759129c62529e2cdc6fe5c5a47044e4549ccfa1daa6a7cc00986a6d304ca517ff6
6
+ metadata.gz: f7dccdd9729516b74d7ab8ab162d7290e5b4e4485efc1839bea45bba479b088641b988320f994fd0e4ee0d27a29fa1f671a7a7fd171261ab9ceaea50479a5bf6
7
+ data.tar.gz: 5e1531954628ba52e9afd7f57690af8f3955c7bbab949235ca2c537a71270677ac19eaf64d16d8f168f7322b5c09b29c0dfdd7aac0fb857ad4774d3e99d31c98
data/bin/rbbt CHANGED
@@ -3,9 +3,9 @@
3
3
  require 'rbbt'
4
4
  require 'rbbt/util/simpleopt'
5
5
 
6
- options = SOPT.get("--log* Log level from 0 (debug) 6 (errors):-cd--command_dir* Directory from where to load commands:--profile Profile execution:--no_color Disable colored output:--locate_file Locate file been executed")
6
+ options = SOPT.get("--log* Log level from 0 (debug) 6 (errors):-cd--command_dir* Directory from where to load commands:--profile Profile execution:--nocolor Disable colored output:--locate_file Locate file been executed")
7
7
 
8
- ENV["RBBT_NOCOLOR"] = "true" if options[:no_color]
8
+ Log.nocolor = true if options[:nocolor]
9
9
  locate = options.delete :locate_file
10
10
 
11
11
  if options[:log]
@@ -67,12 +67,12 @@ def rbbt_usage(prev = nil)
67
67
  end
68
68
 
69
69
  def print_error(error, backtrace = nil)
70
- puts Term::ANSIColor.red("Error:")
70
+ puts Log.color :red, "Error:"
71
71
  puts
72
72
  puts error
73
73
  if backtrace
74
74
  puts
75
- puts Term::ANSIColor.red("Backtrace:")
75
+ puts Log.color :red, "Backtrace:"
76
76
  puts
77
77
  puts backtrace * "\n"
78
78
  end
@@ -109,6 +109,7 @@ begin
109
109
  exit 0
110
110
 
111
111
  rescue ParameterException
112
+ ddd "EXCEPTION"
112
113
  puts
113
114
  rbbt_usage
114
115
  print_error($!.message, $!.backtrace)
data/etc/app.d/init.rb CHANGED
@@ -7,5 +7,3 @@ require 'rbbt/rest/entity'
7
7
  require 'rbbt/rest/workflow'
8
8
  require 'rbbt/rest/file_server'
9
9
  require 'rbbt/rest/helpers'
10
-
11
- YAML::ENGINE.yamler = 'syck' if defined? YAML::ENGINE and YAML::ENGINE.respond_to? :yamler
data/lib/rbbt/util/log.rb CHANGED
@@ -13,8 +13,9 @@ module Log
13
13
  ERROR = 6
14
14
 
15
15
  class << self
16
- attr_accessor :logfile, :severity
16
+ attr_accessor :logfile, :severity, :nocolor
17
17
  end
18
+ self.nocolor = ENV["RBBT_NOCOLOR"] == 'true'
18
19
 
19
20
 
20
21
  def self.logfile
@@ -23,16 +24,11 @@ module Log
23
24
 
24
25
  WHITE, DARK, GREEN, YELLOW, RED = Color::SOLARIZED.values_at :base0, :base00, :green, :yellow, :magenta
25
26
 
26
- if ENV["RBBT_NOCOLOR"] == "true"
27
- SEVERITY_COLOR = [reset, "", "", "", "", "", ""] #.collect{|e| "\033[#{e}"}
28
- else
29
- SEVERITY_COLOR = [reset, cyan, green, magenta, blue, yellow, red] #.collect{|e| "\033[#{e}"}
30
- end
31
-
27
+ SEVERITY_COLOR = [reset, cyan, green, magenta, blue, yellow, red] #.collect{|e| "\033[#{e}"}
32
28
  HIGHLIGHT = "\033[1m"
33
29
 
34
30
  def self.color(severity, str = nil)
35
- return str || "" if ENV["RBBT_NOCOLOR"] == "true"
31
+ return str || "" if nocolor
36
32
  color = SEVERITY_COLOR[severity] if Fixnum === severity
37
33
  color = Term::ANSIColor.send(severity) if Symbol === severity and Term::ANSIColor.respond_to? severity
38
34
  if str.nil?
@@ -44,8 +40,10 @@ module Log
44
40
 
45
41
  def self.highlight(str = nil)
46
42
  if str.nil?
43
+ return "" if nocolor
47
44
  HIGHLIGHT
48
45
  else
46
+ return str if nocolor
49
47
  HIGHLIGHT + str + color(0)
50
48
  end
51
49
  end
@@ -118,7 +116,7 @@ end
118
116
 
119
117
  def ppp(message)
120
118
  stack = caller
121
- puts "#{Log::SEVERITY_COLOR[1]}PRINT:#{Log::SEVERITY_COLOR[0]} " << stack.first
119
+ puts "#{Log.color :cyan, "PRINT:"} " << stack.first
122
120
  puts ""
123
121
  puts "=> " << message
124
122
  puts ""
@@ -126,7 +124,7 @@ end
126
124
 
127
125
  def ddd(message, file = $stdout)
128
126
  stack = caller
129
- Log.debug{"#{Log::SEVERITY_COLOR[1]}DEVEL:#{Log::SEVERITY_COLOR[0]} " << stack.first}
127
+ Log.debug{"#{Log.color :cyan, "DEBUG:"} " << stack.first}
130
128
  Log.debug{""}
131
129
  Log.debug{"=> " << message.inspect}
132
130
  Log.debug{""}
@@ -134,7 +132,7 @@ end
134
132
 
135
133
  def fff(object)
136
134
  stack = caller
137
- Log.debug{"#{Log::SEVERITY_COLOR[1]}FINGERPRINT:#{Log::SEVERITY_COLOR[0]} " << stack.first}
135
+ Log.debug{"#{Log.color :cyan, "FINGERPRINT:"} " << stack.first}
138
136
  Log.debug{""}
139
137
  Log.debug{require 'rbbt/util/misc'; "=> " << Misc.fingerprint(object) }
140
138
  Log.debug{""}
@@ -932,7 +932,7 @@ end
932
932
 
933
933
  begin
934
934
  if File.exists? lockfile and
935
- Misc.hostname == (info = YAML.load_file(lockfile))["host"] and
935
+ Misc.hostname == (info = Open.open(lockfile){|f| YAML.load(f) })["host"] and
936
936
  info["pid"] and not Misc.pid_exists?(info["pid"])
937
937
 
938
938
  Log.info("Removing lockfile: #{lockfile}. This pid #{Process.pid}. Content: #{info.inspect}")
@@ -945,11 +945,12 @@ end
945
945
 
946
946
  begin
947
947
  lockfile.lock do
948
- res = yield file, *args
948
+ yield file, *args
949
949
  end
950
950
  rescue Interrupt
951
951
  Log.error "Process #{Process.pid} interrupted while in lock: #{ lock_path }"
952
952
  raise $!
953
+ ensure
953
954
  end
954
955
 
955
956
  res
@@ -1362,8 +1363,8 @@ end
1362
1363
 
1363
1364
 
1364
1365
  def self.zip_fields(array)
1365
- return [] if array.empty?
1366
- array[0].zip(*array[1..-1])
1366
+ return [] if array.empty? or (first = array.first).nil?
1367
+ first.zip(*array[1..-1])
1367
1368
  end
1368
1369
 
1369
1370
  def self.camel_case(string)
@@ -330,9 +330,7 @@ module Open
330
330
  # What about grep?
331
331
  wget(url, wget_options)
332
332
  when (options[:nocache] != :update and in_cache(url, wget_options))
333
- Misc.lock(in_cache(url, wget_options)) do
334
- file_open(in_cache(url, wget_options), options[:grep], mode, options[:invert_grep])
335
- end
333
+ file_open(in_cache(url, wget_options), options[:grep], mode, options[:invert_grep])
336
334
  else
337
335
  io = wget(url, wget_options)
338
336
  add_cache(url, io, wget_options)
@@ -8,8 +8,6 @@ require 'rbbt/util/misc'
8
8
 
9
9
  options = SOPT.get("-l--list:-z--zombies:-e--errors:-c--clean:-n--name:-a--all:-w--wipe:-f--file*:-q--quick:-d--directory*")
10
10
 
11
- YAML::ENGINE.yamler = 'syck' if defined? YAML::ENGINE and YAML::ENGINE.respond_to? :yamler
12
-
13
11
  def info_files
14
12
  Dir.glob('**/*.info')
15
13
  end
@@ -12,9 +12,6 @@ require 'rbbt/util/misc'
12
12
 
13
13
  $workdir = Path.setup(File.expand_path(ARGV[0] || '.'))
14
14
 
15
-
16
- YAML::ENGINE.yamler = 'syck' if defined? YAML::ENGINE and YAML::ENGINE.respond_to? :yamler
17
-
18
15
  def info_files
19
16
  $workdir.glob(Step.info_file('**/*'))
20
17
  end
@@ -4,8 +4,6 @@ require 'rbbt/util/simpleopt'
4
4
  require 'rbbt/workflow'
5
5
  require 'rbbt/workflow/usage'
6
6
 
7
- YAML::ENGINE.yamler = 'syck' if defined? YAML::ENGINE and YAML::ENGINE.respond_to? :yamler
8
-
9
7
  def load_inputs(dir, task)
10
8
  inputs = {}
11
9
  dir = Path.setup(dir.dup)
@@ -43,8 +41,8 @@ def usage(workflow = nil, task = nil, exception=nil)
43
41
  workflow.doc(task)
44
42
  end
45
43
 
46
- raise exception if exception
47
- exit 0
44
+ print_error(exception.message, exception.backtrace) if exception
45
+ exit -1
48
46
  end
49
47
 
50
48
  def SOPT_options(workflow, task)
@@ -1,3 +1,5 @@
1
+ #ENV['LOCKFILE_DEBUG'] = "true";; require 'lockfile'
2
+
1
3
  require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
2
4
  require 'rbbt/util/misc'
3
5
  require 'test/unit'
@@ -283,4 +285,14 @@ class TestMisc < Test::Unit::TestCase
283
285
  assert time_spent <= (t+1) * 0.5
284
286
  assert_equal (0..t-1).to_a.collect{|i| "LINE #{ i }"}, lines
285
287
  end
288
+
289
+ def __test_lock_fd
290
+ require 'rbbt/workflow'
291
+ Rbbt.var.jobs.Structure.neighbour_map.glob("*")[0..1000].each do |file|
292
+ next if file =~ /\.info$/
293
+ step = Step.new file
294
+ TSV.open step.path
295
+ end
296
+ puts `ls -l /proc/#{ Process.pid }/fd`
297
+ end
286
298
  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.6.8
4
+ version: 5.6.9
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-02-24 00:00:00.000000000 Z
11
+ date: 2014-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake