evrone-common-spawn 0.0.4 → 0.0.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.
- checksums.yaml +4 -4
- data/lib/evrone/common/spawn/ssh.rb +20 -18
- data/lib/evrone/common/spawn/version.rb +1 -1
- data/spec/lib/spawn/ssh_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72883bae873f531ba9e9ce5ee18c03f28807b12b
|
4
|
+
data.tar.gz: 32639657615dd8156849cdd1a53b0c8c9007bb6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1a7f84c8110e41e836a365d4b39dc692fa1bde96a903c2394be257f111d62ba48d000e5a8d2209bfa977e6324c11b9eb44b42e1b3228e8a1a7ff419ebd02c82
|
7
|
+
data.tar.gz: dc18782286c1295e04902be3ad1888bfcfecd762bc8ae1d7f7c1557d69aad2710d8011cf5f24364bc6c646bce3ccc99cc932c05e035983aa9c898ff4e0bd42f8
|
@@ -45,6 +45,10 @@ module Evrone
|
|
45
45
|
|
46
46
|
private
|
47
47
|
|
48
|
+
def normalize_nl(str)
|
49
|
+
str.gsub(/\r\n?/, "\n")
|
50
|
+
end
|
51
|
+
|
48
52
|
def build_command(env, command, options)
|
49
53
|
cmd = command
|
50
54
|
unless env.empty?
|
@@ -80,30 +84,28 @@ module Evrone
|
|
80
84
|
end
|
81
85
|
|
82
86
|
def spawn_channel(command, read_timeout, &block)
|
83
|
-
|
84
87
|
@connection.open_channel do |channel|
|
85
|
-
read_timeout.reset
|
86
88
|
|
87
|
-
|
88
|
-
|
89
|
-
# yield "FAILED: couldn't execute command (ssh.channel.env)\n" if block_given?
|
90
|
-
# end
|
91
|
-
#end
|
89
|
+
channel.request_pty do |_, pty_status|
|
90
|
+
raise StandardError, "could not obtain pty" unless pty_status
|
92
91
|
|
93
|
-
|
92
|
+
read_timeout.reset
|
94
93
|
|
95
|
-
|
96
|
-
yield "FAILED: couldn't execute command (ssh.channel.exec)\n" if block_given?
|
97
|
-
end
|
94
|
+
channel.exec command do |_, success|
|
98
95
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
96
|
+
unless success
|
97
|
+
yield "FAILED: couldn't execute command (ssh.channel.exec)\n" if block_given?
|
98
|
+
end
|
99
|
+
|
100
|
+
channel.on_data do |_, data|
|
101
|
+
yield normalize_nl(data) if block_given?
|
102
|
+
read_timeout.reset
|
103
|
+
end
|
103
104
|
|
104
|
-
|
105
|
-
|
106
|
-
|
105
|
+
channel.on_extended_data do |_, _, data|
|
106
|
+
yield normalize_nl(data) if block_given?
|
107
|
+
read_timeout.reset
|
108
|
+
end
|
107
109
|
end
|
108
110
|
end
|
109
111
|
end
|
data/spec/lib/spawn/ssh_spec.rb
CHANGED
@@ -51,7 +51,7 @@ describe Evrone::Common::Spawn::SSH, ssh: true do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'run command with timeout successfuly' do
|
54
|
-
code = run_ssh('echo $USER; sleep 0.2', timeout:
|
54
|
+
code = run_ssh('echo $USER; sleep 0.2', timeout: 1)
|
55
55
|
expect(collected).to eq "#{user}\n"
|
56
56
|
expect(code).to eq 0
|
57
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evrone-common-spawn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Galinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|