ro_thor 4.5.6 → 4.5.7
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/ro_thor/ssh.rb +15 -10
- data/spec/lib/ro_thor/ssh_spec.rb +19 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f2c130067f45ad0815676db4152f971063e03487b82ef35d6824a7146a04425
|
4
|
+
data.tar.gz: d939307abbefe9260132cb92d160568e0a0ebfd594d9c7d211d8a6d6c2a7136f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf49e3f59b18ae2cff4cda9093c4b49f63ec69f9febcc98b1b138c88c25758093b7494ec2d7cbd0b8e4ef647b1d3311a10b88645043a06fa3deff181f4ec25cd
|
7
|
+
data.tar.gz: 020ef1946c6d6b40cdbb26aa497bbd1f2c99409f7b76b83713c5ea1253050de1655b2ac56257eb52f5515d4f040aac838221bf3eb2976c528ca6f37667dde707
|
data/lib/ro_thor/ssh.rb
CHANGED
@@ -4,6 +4,7 @@ require 'net/ssh'
|
|
4
4
|
require_relative 'helper'
|
5
5
|
require_relative 'sh'
|
6
6
|
require_relative 'ro_file'
|
7
|
+
require 'term/ansicolor'
|
7
8
|
|
8
9
|
class RoThor
|
9
10
|
class SSH
|
@@ -42,7 +43,7 @@ class RoThor
|
|
42
43
|
|
43
44
|
ch = se.open_channel do |ch|
|
44
45
|
ch.exec(cmd) do |ch, success|
|
45
|
-
|
46
|
+
if !success
|
46
47
|
raise ::RoErr::RmtErr, "could not exe cmd: #{command.inspect}"
|
47
48
|
end
|
48
49
|
|
@@ -74,12 +75,14 @@ class RoThor
|
|
74
75
|
ch.wait
|
75
76
|
ch.close
|
76
77
|
|
78
|
+
stdout = out_a.join('')
|
79
|
+
|
77
80
|
stderr_lines = stderr_lines.hits
|
78
81
|
stderr_lines.delete_if do |l|
|
79
82
|
l.match(%r{^/.*warning\:.*$})
|
80
83
|
end
|
81
84
|
|
82
|
-
|
85
|
+
if !stderr_lines.empty?
|
83
86
|
if stderr_lines.any? do |l|
|
84
87
|
l.match(%r{\tfrom})
|
85
88
|
end
|
@@ -95,19 +98,21 @@ class RoThor
|
|
95
98
|
end
|
96
99
|
end
|
97
100
|
|
98
|
-
e = RoErr::RmtErr.new(uncol(err_msg_arr.join)
|
101
|
+
e = RoErr::RmtErr.new(stdout + uncol(err_msg_arr.join))
|
102
|
+
e.set_backtrace(bt.map(&:strip).hits)
|
99
103
|
else
|
100
|
-
e = RoErr::RmtErr.new(uncol(stderr_lines.join("\n"))
|
104
|
+
e = RoErr::RmtErr.new(stdout + uncol(stderr_lines.join("\n")))
|
105
|
+
e.set_backtrace(clr)
|
101
106
|
end
|
102
107
|
|
103
|
-
if ::RoCell::Rmt.ignore_err
|
104
|
-
|
105
|
-
else
|
106
|
-
|
107
|
-
end
|
108
|
+
# if ::RoCell::Rmt.ignore_err
|
109
|
+
# out_ins.warn e
|
110
|
+
# else
|
111
|
+
raise e
|
112
|
+
# end
|
108
113
|
end
|
109
114
|
|
110
|
-
|
115
|
+
stdout
|
111
116
|
end
|
112
117
|
|
113
118
|
def uncol(*args, &blk)
|
@@ -2,8 +2,24 @@ require 'rails_helper'
|
|
2
2
|
require 'ro_thor/ssh'
|
3
3
|
|
4
4
|
describe 'RoThor::Rmt.new' do
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
describe "sh" do
|
6
|
+
it "1" do
|
7
|
+
s = RoThor::SSH.new('root@techprpr')
|
8
|
+
s.sh('ls;ls')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "capture err" do
|
12
|
+
s = RoThor::SSH.new("root@techprpr")
|
13
|
+
begin
|
14
|
+
# raise "err"
|
15
|
+
s.sh("lrekljeklwjl")
|
16
|
+
rescue Exception => e
|
17
|
+
puts "e:#{e} ---- #{File.basename __FILE__}:#{__LINE__}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it "sh with regex" do
|
23
|
+
|
8
24
|
end
|
9
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ro_thor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.5.
|
4
|
+
version: 4.5.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|