rbbt-util 5.5.50 → 5.5.51

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGM4ZjliYTA2Y2UxYzNiZWY2NWM0N2Q5ZTI3MTFhNGU2ODI2Nzk3ZQ==
4
+ ZjQ0ZDU1ZWJkNWY0MDJhYzZhNTZiOGMxZTQ1ZGY1YTcxYTg2YmMxZg==
5
5
  data.tar.gz: !binary |-
6
- NmI0MTM4MjRhYTM3NjJmMWRiN2NjOTg3NDNjYTYxYjhjN2IzNDRhOQ==
6
+ ZTlhYjJjZDE0MTEyMWYxNTM0ZTQ3NmJiYjIwM2UxM2NiNTM3ZGJkYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTc0MThjZDQ5ZTMyMjM0MjM2ZTFhMDZiYTg5YzU5ZDJmZGE1Y2ExNTZmZWU0
10
- M2RkOWI3NTJkNmU3NWVkYzFiZDRiY2M2YTExMTg4MmQ1M2U4N2Y3YWRmN2U4
11
- NDFiMjFiNzRhMmJmNzgwOTEyYzM2MDk2YjkxNzIxMTY5YjA0YmY=
9
+ YTE4Njc0ODNiYjY5MjJjYjQ4YjIwZDBjZWUyMjdmMWVlZTA1OGQ2MTZlYjlm
10
+ NjgxODBjNzJjZTMxYzMwMjJhODJkYTk0ZWZiMDJiNmJjMDNlNjI1NmQxMWRh
11
+ NDUwOTQyYzFlYTc4MDIwOGM3MmQwMmEwYmY0M2YzNTdjYTcwZTY=
12
12
  data.tar.gz: !binary |-
13
- M2UyM2MyMmZjODBhZjU4N2MzNzA1MTcyMWZlYTEzYTU3MmVmNWRlZGY5ZmU1
14
- MWU1MTIyMzNiNTQyMzBiNDc4OGZjNmE3NDZhNjk3YTk3MTU2ODNmMjY1NmRj
15
- NTliMWJiOTBiZDRjYmQwZTg1NWEyZDM3NmZlMzUzZTQ3NzIwNTI=
13
+ NmI3MWVjMDEyM2U3YjRkM2MyYTUyZjc5NDY4NThkMzI0YTEyNDg1ZjAwNzdi
14
+ NWVhYTE2OWRlMDAyN2FkMzU4NTA2MTJhNTMzZjg4ZDQ3NzU2OGZlMzcwOTYy
15
+ ODA5M2EwZjJlODAzOGQwMzRhMWRmMTYyOWU1NDM3MDMwMDFhYjI=
@@ -2,6 +2,7 @@ require 'rbbt/util/open'
2
2
  require 'rbbt/util/log'
3
3
  require 'rbbt/resource/path'
4
4
  require 'net/http'
5
+ require 'set'
5
6
 
6
7
 
7
8
  module Resource
@@ -55,11 +56,14 @@ module Resource
55
56
  end
56
57
  end
57
58
 
59
+ attr_accessor :server_missing_resource_cache
58
60
  def get_from_server(path, final_path)
59
61
  url = File.join(remote_server, '/resource/', self.to_s, 'get_file')
60
62
  url << "?" << Misc.hash2GET_params(:file => path, :create => false)
61
63
 
62
64
  begin
65
+ @server_missing_resource_cache ||= Set.new
66
+ raise "Resource Not Found" if @server_missing_resource_cache.include? url
63
67
  Net::HTTP.get_response URI(url) do |response|
64
68
  case response
65
69
  when Net::HTTPSuccess, Net::HTTPOK
@@ -70,22 +74,23 @@ module Resource
70
74
  end
71
75
  end
72
76
 
73
- when Net::HTTPRedirection, Net::HTTPFound
74
- location = response['location']
75
- Log.debug("Feching directory from: #{location}. Into: #{final_path}")
76
- FileUtils.mkdir_p final_path unless File.exists? final_path
77
- Misc.in_dir final_path do
78
- CMD.cmd('tar xvfz -', :in => Open.open(location))
79
- end
77
+ when Net::HTTPRedirection, Net::HTTPFound
78
+ location = response['location']
79
+ Log.debug("Feching directory from: #{location}. Into: #{final_path}")
80
+ FileUtils.mkdir_p final_path unless File.exists? final_path
81
+ Misc.in_dir final_path do
82
+ CMD.cmd('tar xvfz -', :in => Open.open(location))
83
+ end
84
+ when Net::HTTPInternalServerError
85
+ @server_missing_resource_cache << url
86
+ raise "Resource Not Found"
80
87
  else
81
- exit
82
88
  raise "Response not understood: #{response.inspect}"
83
89
  end
84
90
  end
85
91
  rescue
86
92
  Log.warn "Could not retrieve (#{self.to_s}) #{ path } from #{ remote_server }"
87
93
  Log.error $!.message
88
- Log.error $!.backtrace * "\n"
89
94
  FileUtils.rm_rf final_path if File.exists? final_path
90
95
  return false
91
96
  end
@@ -249,12 +249,19 @@ module TSV
249
249
  when :double
250
250
  new_key_field_name, new_field_names = through new_key_field, new_fields, uniq, zipped do |key, value|
251
251
  if data[key].nil?
252
- #data[key] = value.collect{|v| v.dup}
253
- data[key] = value.collect{|v| v.dup}
252
+ #data[key] = value.collect{|v| v.nil? ? nil : v.dup}
253
+ data[key] = value.dup
254
254
  else
255
- current = data[key]
256
- value.each_with_index do |v, i|
257
- current[i].concat v
255
+ if current = data[key]
256
+ value.each_with_index do |v, i|
257
+ if _c = current[i]
258
+ _c.concat v if v
259
+ else
260
+ current[i] = v || []
261
+ end
262
+ end
263
+ else
264
+ current = v.collect{|e| [e] }
258
265
  end
259
266
  data[key] = current if data.respond_to? :tokyocabinet_class
260
267
  end
@@ -28,13 +28,16 @@ class Step
28
28
  def info
29
29
  return {} if info_file.nil? or not Open.exists? info_file
30
30
  begin
31
- Misc.insist(2, 0.5) do
32
- Open.open(info_file) do |file|
33
- INFO_SERIALIAZER.load(file) || {}
31
+ Misc.insist(2, 2) do
32
+ Misc.insist(2, 0.5) do
33
+ Open.open(info_file) do |file|
34
+ INFO_SERIALIAZER.load(file) || {}
35
+ end
34
36
  end
35
37
  end
36
38
  rescue Exception
37
39
  Log.debug{"Error loading info file: " + info_file}
40
+ Open.write(info_file, {:status => :error, :messages => ["Info file lost"]}.to_yaml)
38
41
  raise $!
39
42
  end
40
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.50
4
+ version: 5.5.51
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez