ztk 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ztk/ssh.rb +7 -0
- data/lib/ztk/ssh/download.rb +1 -1
- data/lib/ztk/ssh/exec.rb +1 -1
- data/lib/ztk/ssh/file.rb +7 -4
- data/lib/ztk/ssh/upload.rb +1 -1
- data/lib/ztk/version.rb +1 -1
- metadata +3 -3
data/lib/ztk/ssh.rb
CHANGED
@@ -185,6 +185,13 @@ module ZTK
|
|
185
185
|
ssh and !ssh.closed? and ssh.close
|
186
186
|
end
|
187
187
|
|
188
|
+
# The on_retry method we'll use with the RescueRetry class.
|
189
|
+
def on_retry(exception)
|
190
|
+
close
|
191
|
+
@ssh = nil
|
192
|
+
@sftp = nil
|
193
|
+
end
|
194
|
+
|
188
195
|
# Launches an SSH console, replacing the current process with the console
|
189
196
|
# process.
|
190
197
|
#
|
data/lib/ztk/ssh/download.rb
CHANGED
@@ -41,7 +41,7 @@ module ZTK
|
|
41
41
|
config.ui.logger.debug { "config=#{config.send(:table).inspect}" }
|
42
42
|
config.ui.logger.info { "download(#{remote.inspect}, #{local.inspect})" }
|
43
43
|
|
44
|
-
ZTK::RescueRetry.try(:tries => 3, :on => EOFError) do
|
44
|
+
ZTK::RescueRetry.try(:tries => 3, :on => EOFError, :on_retry => method(:on_retry)) do
|
45
45
|
sftp.download!(remote.to_s, local.to_s) do |event, downloader, *args|
|
46
46
|
case event
|
47
47
|
when :open
|
data/lib/ztk/ssh/exec.rb
CHANGED
@@ -58,7 +58,7 @@ module ZTK
|
|
58
58
|
|
59
59
|
begin
|
60
60
|
Timeout.timeout(options.timeout) do
|
61
|
-
ZTK::RescueRetry.try(:tries => 3, :on => EOFError) do
|
61
|
+
ZTK::RescueRetry.try(:tries => 3, :on => EOFError, :on_retry => method(:on_retry)) do
|
62
62
|
|
63
63
|
channel = ssh.open_channel do |chan|
|
64
64
|
options.ui.logger.debug { "Channel opened." }
|
data/lib/ztk/ssh/file.rb
CHANGED
@@ -49,12 +49,15 @@ module ZTK
|
|
49
49
|
::File.open(tempfile, 'w') do |file|
|
50
50
|
yield(file)
|
51
51
|
end
|
52
|
-
self.upload(tempfile.path, tempfile.path)
|
53
52
|
|
54
|
-
|
53
|
+
ZTK::RescueRetry.try(:tries => 2, :on_retry => method(:on_retry)) do
|
54
|
+
upload(tempfile.path, tempfile.path)
|
55
55
|
|
56
|
-
|
57
|
-
|
56
|
+
exec(%(sudo mv -v #{tempfile.path} #{target}), :silence => true)
|
57
|
+
|
58
|
+
exec(%(sudo chown -v #{chown} #{target}), :silence => true) if !chown.nil?
|
59
|
+
exec(%(sudo chmod -v #{chmod} #{target}), :silence => true) if !chmod.nil?
|
60
|
+
end
|
58
61
|
|
59
62
|
true
|
60
63
|
end
|
data/lib/ztk/ssh/upload.rb
CHANGED
@@ -41,7 +41,7 @@ module ZTK
|
|
41
41
|
config.ui.logger.debug { "config=#{config.send(:table).inspect}" }
|
42
42
|
config.ui.logger.info { "upload(#{local.inspect}, #{remote.inspect})" }
|
43
43
|
|
44
|
-
ZTK::RescueRetry.try(:tries => 3, :on => EOFError) do
|
44
|
+
ZTK::RescueRetry.try(:tries => 3, :on => EOFError, :on_retry => method(:on_retry)) do
|
45
45
|
sftp.upload!(local.to_s, remote.to_s) do |event, uploader, *args|
|
46
46
|
case event
|
47
47
|
when :open
|
data/lib/ztk/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ztk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -263,7 +263,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
263
263
|
version: '0'
|
264
264
|
segments:
|
265
265
|
- 0
|
266
|
-
hash: -
|
266
|
+
hash: -1475474265463745848
|
267
267
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
268
268
|
none: false
|
269
269
|
requirements:
|
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
272
|
version: '0'
|
273
273
|
segments:
|
274
274
|
- 0
|
275
|
-
hash: -
|
275
|
+
hash: -1475474265463745848
|
276
276
|
requirements: []
|
277
277
|
rubyforge_project:
|
278
278
|
rubygems_version: 1.8.25
|