net-scp 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,8 @@
1
1
 
2
+ === 1.2.0 / 11 Apr 2014
3
+
4
+ * Get the error string during download [jkeiser]
5
+
2
6
  === 1.1.2 / 6 Jul 2013
3
7
 
4
8
  * Explicit convert to string in shellescape [jwils]
data/Rakefile CHANGED
@@ -30,8 +30,8 @@ begin
30
30
 
31
31
  s.license = "MIT"
32
32
 
33
- s.signing_key = File.join('/mnt/gem/', 'gem-private_key.pem')
34
- s.cert_chain = ['gem-public_cert.pem']
33
+ #s.signing_key = File.join('/mnt/gem/', 'gem-private_key.pem')
34
+ #s.cert_chain = ['gem-public_cert.pem']
35
35
  end
36
36
  Jeweler::GemcutterTasks.new
37
37
  rescue LoadError
@@ -128,6 +128,11 @@ module Net
128
128
  # * E -- terminator directive. Indicates the end of a directory, and subsequent
129
129
  # files and directories should be received by the parent of the current
130
130
  # directory.
131
+ # * \0 -- indicates a successful response from the other end.
132
+ # * \1 -- warning directive. Indicates a warning from the other end. Text from
133
+ # this warning will be reported if the SCP results in an error.
134
+ # * \2 -- error directive. Indicates an error from the other end. Text from
135
+ # this error will be reported if the SCP results in an error.
131
136
  #
132
137
  # If a 'C' directive is received, we switch over to
133
138
  # Net::SCP::Download#read_data_state. If an 'E' directive is received, and
@@ -355,8 +360,9 @@ module Net
355
360
  channel[:buffer ] = Net::SSH::Buffer.new
356
361
  channel[:state ] = "#{mode}_start"
357
362
  channel[:stack ] = []
363
+ channel[:error_string] = ''
358
364
 
359
- channel.on_close { |ch| raise Net::SCP::Error, "SCP did not finish successfully (#{ch[:exit]})" if ch[:exit] != 0 }
365
+ channel.on_close { |ch| send("#{channel[:state]}_state", channel); raise Net::SCP::Error, "SCP did not finish successfully (#{channel[:exit]}): #{channel[:error_string]}" if channel[:exit] != 0 }
360
366
  channel.on_data { |ch, data| channel[:buffer].append(data) }
361
367
  channel.on_extended_data { |ch, type, data| debug { data.chomp } }
362
368
  channel.on_request("exit-status") { |ch, data| channel[:exit] = data.read_long }
@@ -37,7 +37,13 @@ module Net; class SCP
37
37
 
38
38
  directive = parse_directive(line)
39
39
  case directive[:type]
40
- when :times then
40
+ when :OK
41
+ return
42
+ when :warning
43
+ channel[:error_string] << directive[:message]
44
+ when :error
45
+ channel[:error_string] << directive[:message]
46
+ when :times
41
47
  channel[:times] = directive
42
48
  when :directory
43
49
  read_directory(channel, directive)
@@ -87,6 +93,15 @@ module Net; class SCP
87
93
  # data.
88
94
  def parse_directive(text)
89
95
  case type = text[0]
96
+ when "\x00"
97
+ # Success
98
+ { :type => :OK }
99
+ when "\x01"
100
+ { :type => :warning,
101
+ :message => text[1..-1] }
102
+ when "\x02"
103
+ { :type => :error,
104
+ :message => text[1..-1] }
90
105
  when ?T
91
106
  parts = text[1..-1].split(/ /, 4).map { |i| i.to_i }
92
107
  { :type => :times,
@@ -5,8 +5,8 @@ module Net; class SCP
5
5
  # Describes the current version of the Net::SCP library.
6
6
  class Version < Net::SSH::Version
7
7
  MAJOR = 1
8
- MINOR = 1
9
- TINY = 2
8
+ MINOR = 2
9
+ TINY = 0
10
10
 
11
11
  # The current version, as a Version instance
12
12
  CURRENT = new(MAJOR, MINOR, TINY)
@@ -2,13 +2,15 @@ require 'open-uri'
2
2
  require 'uri/scp'
3
3
  require 'net/scp'
4
4
 
5
+ OpenURI::Options[:ssh] = nil
6
+
5
7
  module URI
6
8
 
7
9
  class SCP
8
10
  def buffer_open(buf, proxy, open_options)
9
11
  options = open_options.merge(:port => port, :password => password)
10
12
  progress = options.delete(:progress_proc)
11
- buf << Net::SCP.download!(host, user, path, nil, open_options, &progress)
13
+ buf << Net::SCP.download!(host, user, path, nil, options, &progress)
12
14
  buf.io.rewind
13
15
  end
14
16
 
@@ -5,12 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "net-scp"
8
- s.version = "1.1.2"
8
+ s.version = "1.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jamis Buck", "Delano Mandelbaum"]
12
- s.cert_chain = ["gem-public_cert.pem"]
13
- s.date = "2013-07-06"
12
+ s.date = "2014-04-11"
14
13
  s.description = "A pure Ruby implementation of the SCP client protocol"
15
14
  s.email = "net-ssh@solutious.com"
16
15
  s.extra_rdoc_files = [
@@ -43,8 +42,7 @@ Gem::Specification.new do |s|
43
42
  s.licenses = ["MIT"]
44
43
  s.require_paths = ["lib"]
45
44
  s.rubyforge_project = "net-scp"
46
- s.rubygems_version = "1.8.25"
47
- s.signing_key = "/mnt/gem/gem-private_key.pem"
45
+ s.rubygems_version = "1.8.23"
48
46
  s.summary = "A pure Ruby implementation of the SCP client protocol"
49
47
 
50
48
  if s.respond_to? :specification_version then
@@ -54,6 +54,33 @@ class TestDownload < Net::SCP::TestCase
54
54
  assert_equal "a" * 1234, file.io.string
55
55
  end
56
56
 
57
+ def test_download_with_error_should_respond_with_error_text
58
+ story do |session|
59
+ channel = session.opens_channel
60
+ channel.sends_exec "scp -f /path/to/remote.txt"
61
+
62
+ channel.sends_ok
63
+ channel.gets_data "\x01File not found: /path/to/remote.txt\n"
64
+ channel.sends_ok
65
+
66
+ channel.gets_eof
67
+ channel.gets_exit_status(1)
68
+ channel.gets_close
69
+ channel.sends_close
70
+ end
71
+
72
+ error = nil
73
+ assert_scripted do
74
+ begin
75
+ scp.download!("/path/to/remote.txt")
76
+ rescue
77
+ error = $!
78
+ end
79
+ end
80
+ assert_equal Net::SCP::Error, error.class
81
+ assert_equal "SCP did not finish successfully (1): File not found: /path/to/remote.txt\n", error.message
82
+ end
83
+
57
84
  def test_download_with_progress_callback_should_invoke_callback
58
85
  prepare_file("/path/to/local.txt", "a" * 3000 + "b" * 3000 + "c" * 3000 + "d" * 3000)
59
86
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-scp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,36 +9,8 @@ authors:
9
9
  - Delano Mandelbaum
10
10
  autorequire:
11
11
  bindir: bin
12
- cert_chain:
13
- - !binary |-
14
- LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUROakNDQWg2Z0F3SUJB
15
- Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREJCTVE4d0RRWURWUVFEREFaa1pX
16
- eGgKYm04eEdUQVhCZ29Ka2lhSmsvSXNaQUVaRmdsemIyeDFkR2x2ZFhNeEV6
17
- QVJCZ29Ka2lhSmsvSXNaQUVaRmdOagpiMjB3SGhjTk1UTXdNakEyTVRFMU56
18
- UTFXaGNOTVRRd01qQTJNVEUxTnpRMVdqQkJNUTh3RFFZRFZRUUREQVprClpX
19
- eGhibTh4R1RBWEJnb0praWFKay9Jc1pBRVpGZ2x6YjJ4MWRHbHZkWE14RXpB
20
- UkJnb0praWFKay9Jc1pBRVoKRmdOamIyMHdnZ0VpTUEwR0NTcUdTSWIzRFFF
21
- QkFRVUFBNElCRHdBd2dnRUtBb0lCQVFEZzFoTXRsMFhzTXVVSwpBS1RnWVd2
22
- M2dqajd2dUVzRTJFalQrdnlCZzgvTHBxVlZ3WnppaWFlYkpUOUlaaVErc0NG
23
- cWJpYWtqMGI1M3BJCmhnMXlPYUJFbUg2L1cwTDdyd3pxYVJWOXNXMWVKczlK
24
- eEZZUUNuZDY3elVuemo4bm5SbE9qRytoaElHK1ZzaWoKbnBzR2J0MjhwZWZ1
25
- TlpKak81cTJjbEFsZlNuaUlJSGZJc1U3L1N0RVl1NkZVR09qbndyeVowcjV5
26
- SmxyOVJyRQpHcytxMERXOFFuWjlVcEFmdURGUVp1SXFlS1FGRkxFN25NbUNH
27
- YUErMEJOMW5MbDNmVkhOYkxIcTdBdms4K1orClp1dXZrZHNjYkhsTy9sKzN4
28
- Q05RNW5Vbkh3cTBBREFiTUxPbG1pWVl6cVhvV0xqbWVJNm1lL2Nsa3RKQ2ZO
29
- MlIKb1pHM1VRdnZBZ01CQUFHak9UQTNNQWtHQTFVZEV3UUNNQUF3SFFZRFZS
30
- ME9CQllFRk1TSk9FdEh6RTRsMGF6dgpNMEpLMGtLTlRvSzFNQXNHQTFVZER3
31
- UUVBd0lFc0RBTkJna3Foa2lHOXcwQkFRVUZBQU9DQVFFQXRPZEU3M3F4Ck9I
32
- MnlkaTlvVDJoUzVmOUcweTFaNzBUbHdoK1ZHRXh5Znh6VkU5WHdDK2lQcEp4
33
- TnJhaUhZZ0YvOS9va3k3WloKUjlxMC90Sm5ldWhBZW5aZGlRa1g3b2k0TzN2
34
- OXdSUzZZSG9XQnhNUEZLVlJMTlR6dlZKc2JtZnBDQWxwNS81ZwpwczR3UUZ5
35
- NW1pYkVsR1ZsT29iZi9naHFaMjVIUzlKNmtkMC9DL3J5MEFVdFRvZ3NMN1R4
36
- R3dUNGtiQ3g2M3ViCjN2eXdFRWhzSlV6ZmQ5N0dDQUJtdFFmUlRsZFgvajdG
37
- MXovNXdkOHAraGZkb3gxaWliZHM5WnRmYVpBM0t6S24Ka2NoV045QjZ6Zzly
38
- MVhNUThCTTJKejBYb1BhblBlMzU0K2xXd2pwa1JLYkZvdy9aYlFIY0NMQ3Ey
39
- NCtONmI2ZwpkZ0tmTkR6d2lEcHFDQT09Ci0tLS0tRU5EIENFUlRJRklDQVRF
40
- LS0tLS0K
41
- date: 2013-07-06 00:00:00.000000000 Z
12
+ cert_chain: []
13
+ date: 2014-04-11 00:00:00.000000000 Z
42
14
  dependencies:
43
15
  - !ruby/object:Gem::Dependency
44
16
  name: net-ssh
@@ -137,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
109
  version: '0'
138
110
  requirements: []
139
111
  rubyforge_project: net-scp
140
- rubygems_version: 1.8.25
112
+ rubygems_version: 1.8.23
141
113
  signing_key:
142
114
  specification_version: 3
143
115
  summary: A pure Ruby implementation of the SCP client protocol
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
@@ -1 +0,0 @@
1
- ��2��=�C��r�K��C�6x�+�?[k�3��j�&����Uz�_V�.lm?ЁDgӕhW�'�?O��j�_ƃP�&q�ģ֣ �Z�M�)+��Y|���Ф���O@!�� w/’_[dxq/���|�=�:I���R�ѷ�h�������d�+dZ�4[ݣ���$g&��{�X)�>�ۓ2ҡ���;U��W��QqA��Ƕ!}j��7-�`(��Y�ʢ�ՕnpE~4�����<x�+R��{r6��D���