cliaws 1.2.4 → 1.2.5

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.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 1.2.5 2008-09-15
2
+
3
+ * More testing for "clis3 put - S3_OBJECT" and "cat x | clis3 put S3_OBJECT" highlighted
4
+ errors. Fixed those so now it works for real.
5
+ WARNING: "clis3 put - S3_OBJECT" is horribly broken: the stream's size is unknown and
6
+ reported as 0, and the Amazon servers faithfully create a 0 sized object...
7
+
1
8
  == 1.2.4 2008-09-15
2
9
 
3
10
  * Released too soon - was missing some testing on clis3 put LOCAL REMOTE
data/Manifest.txt CHANGED
@@ -23,6 +23,8 @@ tasks/environment.rake
23
23
  tasks/website.rake
24
24
  test/test_cliaws.rb
25
25
  test/test_helper.rb
26
+ vendor/right_http_connection-1.2.1/README.txt
27
+ vendor/right_http_connection-1.2.1/lib/right_http_connection.rb
26
28
  website/index.html
27
29
  website/index.txt
28
30
  website/javascripts/rounded_corners_lite.inc.js
data/bin/clis3 CHANGED
@@ -80,10 +80,13 @@ Main {
80
80
  else
81
81
  targets = paths.map {|filename| filename.to_s}
82
82
  case targets.length
83
+ when 0
84
+ source = STDIN
83
85
  when 1
84
86
  File.open(targets.first, "rb") do |source|
85
87
  Cliaws.s3.put(source, s3_object)
86
88
  end
89
+ exit 0
87
90
  else
88
91
  targets.each do |local_file|
89
92
  File.open(local_file, "rb") do |source|
@@ -92,9 +95,8 @@ Main {
92
95
  Cliaws.s3.put(source, remote_file)
93
96
  end
94
97
  end
98
+ exit 0
95
99
  end
96
-
97
- exit 0
98
100
  end
99
101
 
100
102
  raise ArgumentError, "Target is a directory, but input is not a local file -- cannot proceed" if s3_object =~ /\/$/
data/lib/cliaws/s3.rb CHANGED
@@ -1,6 +1,12 @@
1
1
  require "right_aws"
2
2
  require "activesupport"
3
3
 
4
+ # Load vendor code through RubyGems
5
+ require "right_http_connection"
6
+
7
+ # Then patch it here
8
+ require File.dirname(__FILE__) + "/../../vendor/right_http_connection-1.2.1/lib/right_http_connection"
9
+
4
10
  module Cliaws
5
11
  class S3
6
12
  attr_reader :access_key_id, :secret_access_key
@@ -2,7 +2,7 @@ module Cliaws #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 2
5
- TINY = 4
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -2,7 +2,7 @@ desc 'Release the website and new gem version'
2
2
  task :deploy => [:check_version, :website, :release] do
3
3
  puts "Remember to create SVN tag:"
4
4
  puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
5
- "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
5
+ "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
6
6
  puts "Suggested comment:"
7
7
  puts "Tagging release #{CHANGES}"
8
8
  end
@@ -29,6 +29,18 @@ end
29
29
  namespace :manifest do
30
30
  desc 'Recreate Manifest.txt to include ALL files'
31
31
  task :refresh do
32
- `rake check_manifest | patch -p0 > Manifest.txt`
32
+ require "find"
33
+
34
+ home = File.expand_path(File.dirname(__FILE__) + "/../") + "/"
35
+ files = []
36
+ Find.find(File.dirname(__FILE__) + "/..") do |entry|
37
+ Find.prune if entry =~ /\.git$/
38
+ next if File.directory?(entry)
39
+ files << File.expand_path(entry).sub(home, "")
40
+ end
41
+
42
+ File.open(File.dirname(__FILE__) + "/../Manifest.txt", "w") do |io|
43
+ io.puts files.sort.join("\n")
44
+ end
33
45
  end
34
- end
46
+ end
@@ -0,0 +1,3 @@
1
+ == INFORMATION
2
+
3
+ Patched #request to not crash if the request's body is an IO that doesn't respond_to?(:lstat) and #size.
@@ -0,0 +1,117 @@
1
+ #
2
+ # Copyright (c) 2007-2008 RightScale Inc
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ module Rightscale
25
+ class HttpConnection
26
+ def request(request_params, &block)
27
+ loop do
28
+ # if we are inside a delay between retries: no requests this time!
29
+ if error_count > HTTP_CONNECTION_RETRY_COUNT \
30
+ && error_time + HTTP_CONNECTION_RETRY_DELAY > Time.now
31
+ @logger.warn("#{err_header} re-raising same error: #{banana_message} " +
32
+ "-- error count: #{error_count}, error age: #{Time.now.to_i - error_time.to_i}")
33
+ exception = get_param(:exception) || RuntimeError
34
+ raise exception.new(banana_message)
35
+ end
36
+
37
+ # try to connect server(if connection does not exist) and get response data
38
+ begin
39
+ request_params[:protocol] ||= (request_params[:port] == 443 ? 'https' : 'http')
40
+ # (re)open connection to server if none exists or params has changed
41
+ unless @http &&
42
+ @http.started? &&
43
+ @server == request_params[:server] &&
44
+ @port == request_params[:port] &&
45
+ @protocol == request_params[:protocol]
46
+ start(request_params)
47
+ end
48
+
49
+ # get response and return it
50
+ request = request_params[:request]
51
+ request['User-Agent'] = get_param(:user_agent) || ''
52
+
53
+ # Detect if the body is a streamable object like a file or socket. If so, stream that
54
+ # bad boy.
55
+ if(request.body && request.body.respond_to?(:read))
56
+ body = request.body
57
+ request.content_length = if body.respond_to?(:lstat) then
58
+ body.lstat.size
59
+ elsif body.respond_to?(:stat) then
60
+ body.stat.size
61
+ elsif body.respond_to?(:length) then
62
+ body.length
63
+ elsif body.respond_to?(:size) then
64
+ body.size
65
+ else
66
+ raise "Cannot determine request's Content-Length header for #{body.inspect}. #{body} doesn't respond to #lstat, #stat, #length or #size."
67
+ end
68
+ request.body_stream = request.body
69
+ end
70
+ response = @http.request(request, &block)
71
+
72
+ error_reset
73
+ eof_reset
74
+ return response
75
+
76
+ # We treat EOF errors and the timeout/network errors differently. Both
77
+ # are tracked in different statistics blocks. Note below that EOF
78
+ # errors will sleep for a certain (exponentially increasing) period.
79
+ # Other errors don't sleep because there is already an inherent delay
80
+ # in them; connect and read timeouts (for example) have already
81
+ # 'slept'. It is still not clear which way we should treat errors
82
+ # like RST and resolution failures. For now, there is no additional
83
+ # delay for these errors although this may change in the future.
84
+
85
+ # EOFError means the server closed the connection on us.
86
+ rescue EOFError => e
87
+ @logger.debug("#{err_header} server #{@server} closed connection")
88
+ @http = nil
89
+
90
+ # if we have waited long enough - raise an exception...
91
+ if raise_on_eof_exception?
92
+ exception = get_param(:exception) || RuntimeError
93
+ @logger.warn("#{err_header} raising #{exception} due to permanent EOF being received from #{@server}, error age: #{Time.now.to_i - eof_time.to_i}")
94
+ raise exception.new("Permanent EOF is being received from #{@server}.")
95
+ else
96
+ # ... else just sleep a bit before new retry
97
+ sleep(add_eof)
98
+ end
99
+ rescue Exception => e # See comment at bottom for the list of errors seen...
100
+ @http = nil
101
+ # if ctrl+c is pressed - we have to reraise exception to terminate proggy
102
+ if e.is_a?(Interrupt) && !( e.is_a?(Errno::ETIMEDOUT) || e.is_a?(Timeout::Error))
103
+ @logger.debug( "#{err_header} request to server #{@server} interrupted by ctrl-c")
104
+ raise
105
+ elsif e.is_a?(ArgumentError) && e.message.include?('wrong number of arguments (5 for 4)')
106
+ # seems our net_fix patch was overriden...
107
+ exception = get_param(:exception) || RuntimeError
108
+ raise exception.new('incompatible Net::HTTP monkey-patch')
109
+ end
110
+ # oops - we got a banana: log it
111
+ error_add(e.message)
112
+ @logger.warn("#{err_header} request failure count: #{error_count}, exception: #{e.inspect}")
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cliaws
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Fran\xC3\xA7ois Beausoleil"
@@ -65,6 +65,7 @@ extra_rdoc_files:
65
65
  - License.txt
66
66
  - Manifest.txt
67
67
  - README.txt
68
+ - vendor/right_http_connection-1.2.1/README.txt
68
69
  - website/index.txt
69
70
  files:
70
71
  - .gitignore
@@ -92,6 +93,8 @@ files:
92
93
  - tasks/website.rake
93
94
  - test/test_cliaws.rb
94
95
  - test/test_helper.rb
96
+ - vendor/right_http_connection-1.2.1/README.txt
97
+ - vendor/right_http_connection-1.2.1/lib/right_http_connection.rb
95
98
  - website/index.html
96
99
  - website/index.txt
97
100
  - website/javascripts/rounded_corners_lite.inc.js