cliaws 1.4.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,46 +0,0 @@
1
- desc 'Release the website and new gem version'
2
- task :deploy => [:check_version, :website, :release] do
3
- puts "Remember to create SVN tag:"
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} "
6
- puts "Suggested comment:"
7
- puts "Tagging release #{CHANGES}"
8
- end
9
-
10
- desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
11
- task :local_deploy => [:website_generate, :install_gem]
12
-
13
- task :check_version do
14
- unless ENV['VERSION']
15
- puts 'Must pass a VERSION=x.y.z release version'
16
- exit
17
- end
18
- unless ENV['VERSION'] == VERS
19
- puts "Please update your version.rb to match the release version, currently #{VERS}"
20
- exit
21
- end
22
- end
23
-
24
- desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
25
- task :install_gem_no_doc => [:clean, :package] do
26
- sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
27
- end
28
-
29
- namespace :manifest do
30
- desc 'Recreate Manifest.txt to include ALL files'
31
- task :refresh do
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
45
- end
46
- end
@@ -1,7 +0,0 @@
1
- task :ruby_env do
2
- RUBY_APP = if RUBY_PLATFORM =~ /java/
3
- "jruby"
4
- else
5
- "ruby"
6
- end unless defined? RUBY_APP
7
- end
data/test/test_cliaws.rb DELETED
@@ -1,11 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class TestCliaws < Test::Unit::TestCase
4
-
5
- def setup
6
- end
7
-
8
- def test_truth
9
- assert true
10
- end
11
- end
data/test/test_helper.rb DELETED
@@ -1,2 +0,0 @@
1
- require 'test/unit'
2
- require File.dirname(__FILE__) + '/../lib/cliaws'
@@ -1,3 +0,0 @@
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.
@@ -1,117 +0,0 @@
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