ro_thor 4.5.6 → 4.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ro_thor.rb +22 -14
- data/lib/ro_thor/array.rb +1 -0
- data/lib/ro_thor/helper.rb +3 -2
- data/lib/ro_thor/http.rb +5 -0
- data/lib/ro_thor/ro_file.rb +3 -1
- data/lib/ro_thor/ssh.rb +15 -10
- data/lib/ro_thor/string.rb +7 -0
- data/spec/lib/ro_thor/ssh_spec.rb +19 -3
- data/spec/lib/ro_thor_spec.rb +15 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbeb5aef6502717a385722f30e59461061ac1d95d436ccf65c688310d7e244ed
|
4
|
+
data.tar.gz: 65414774e137c2b63f8e9c2784fe8f5820b6b0187b54fcd9d7b2dca45743eb4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83e55c0ded31663342d322067dd74311b61a9d7e21d7950af71970e61ee4641e93ea05f3791b5bb5d94c245a1f7437a44ff23d0dc9a14c1edaa98225d487985d
|
7
|
+
data.tar.gz: 0764d49c5abf5e442ebe7be280dd116609d525d861c6c1bd61e61fb549386b97afe0d5627a238c445e55b93b60d17b75ae562e7ce13e53cfde36b1b4b810be95
|
data/lib/ro_thor.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
$LOAD_PATH.unshift(Pathname.new(__FILE__).parent.to_s)
|
3
|
+
require 'shellwords'
|
3
4
|
require 'thor'
|
4
5
|
require 'open3'
|
5
6
|
require 'ro_thor/base'
|
6
7
|
require 'ro_thor/sh'
|
7
8
|
require 'ro_thor/ro_file'
|
8
9
|
require 'ro_thor/array'
|
10
|
+
require 'ro_thor/string'
|
9
11
|
require 'ro_thor/helper'
|
10
12
|
require 'ro_thor/ro_err'
|
11
13
|
require 'ro_thor/http'
|
@@ -38,6 +40,14 @@ class RoThor < Thor
|
|
38
40
|
desc(str, "")
|
39
41
|
end
|
40
42
|
|
43
|
+
def st(*args)
|
44
|
+
start(*args)
|
45
|
+
end
|
46
|
+
|
47
|
+
def start(*args)
|
48
|
+
super(args)
|
49
|
+
end
|
50
|
+
|
41
51
|
def create_command(*args, &blk)
|
42
52
|
if @usage.nil?
|
43
53
|
return
|
@@ -45,16 +55,12 @@ class RoThor < Thor
|
|
45
55
|
super
|
46
56
|
end
|
47
57
|
|
48
|
-
def st(*args, &blk)
|
49
|
-
start(args)
|
50
|
-
end
|
51
|
-
|
52
58
|
def lamb(*args, &blk)
|
53
59
|
lambda(*args, &blk)
|
54
60
|
end
|
55
61
|
end
|
56
62
|
|
57
|
-
def open_url(url, user_data_dir=nil, *args, &blk)
|
63
|
+
def open_url(url, user_data_dir = nil, *args, &blk)
|
58
64
|
user_data_dir ||= "#{ENV['HOME']}/.config/google-chrome"
|
59
65
|
sys %Q(google-chrome --user-data-dir=#{user_data_dir.strip} "#{url}")
|
60
66
|
end
|
@@ -63,6 +69,10 @@ class RoThor < Thor
|
|
63
69
|
RoFile.basename(Dir.pwd)
|
64
70
|
end
|
65
71
|
|
72
|
+
def sh_esc(str)
|
73
|
+
Shellwords.escape(str)
|
74
|
+
end
|
75
|
+
|
66
76
|
def cur_pj_name2(*args, &blk)
|
67
77
|
cur_pj_name.gsub(%r{^ro_}, "")
|
68
78
|
end
|
@@ -76,7 +86,6 @@ class RoThor < Thor
|
|
76
86
|
end
|
77
87
|
|
78
88
|
|
79
|
-
|
80
89
|
def down_d(*args, &blk)
|
81
90
|
RoFile.join("/media/roroco/disk750/Downloads", *args, &blk)
|
82
91
|
end
|
@@ -136,17 +145,16 @@ class RoThor < Thor
|
|
136
145
|
|
137
146
|
def toggle_win(win_name)
|
138
147
|
wins = begin
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
148
|
+
shsu("xdotool search --onlyvisible #{win_name}").split("\n")
|
149
|
+
rescue RoThor::Sh::Err => e
|
150
|
+
out(e)
|
151
|
+
out(e.backtrace.join("\n"))
|
152
|
+
sleep(0.5)
|
153
|
+
retry
|
154
|
+
end
|
146
155
|
if wins.size > 0
|
147
156
|
sh "xdotool windowactivate #{wins.first.strip}"
|
148
157
|
end
|
149
158
|
end
|
150
|
-
|
151
159
|
end
|
152
160
|
|
data/lib/ro_thor/array.rb
CHANGED
data/lib/ro_thor/helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative 'base'
|
2
|
+
require_relative 'string'
|
2
3
|
|
3
4
|
class RoThor
|
4
5
|
module Helper
|
@@ -11,8 +12,8 @@ class RoThor
|
|
11
12
|
shsu("xclip -sel clip -o")
|
12
13
|
end
|
13
14
|
|
14
|
-
def to_md5(
|
15
|
-
|
15
|
+
def to_md5(str)
|
16
|
+
str.md5
|
16
17
|
end
|
17
18
|
|
18
19
|
def in_pj(pj_name, *args, &blk)
|
data/lib/ro_thor/http.rb
CHANGED
data/lib/ro_thor/ro_file.rb
CHANGED
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.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -110,10 +110,12 @@ files:
|
|
110
110
|
- lib/ro_thor/ro_file.rb
|
111
111
|
- lib/ro_thor/sh.rb
|
112
112
|
- lib/ro_thor/ssh.rb
|
113
|
+
- lib/ro_thor/string.rb
|
113
114
|
- spec/lib/core_ext/array_spec.rb
|
114
115
|
- spec/lib/ro_cmd/thor/dp_spec.rb
|
115
116
|
- spec/lib/ro_thor/ro_err_spec.rb
|
116
117
|
- spec/lib/ro_thor/ssh_spec.rb
|
118
|
+
- spec/lib/ro_thor_spec.rb
|
117
119
|
- spec/mysql/my.cnf
|
118
120
|
- spec/rails_helper.rb
|
119
121
|
- spec/spec_helper.rb
|
@@ -140,10 +142,11 @@ signing_key:
|
|
140
142
|
specification_version: 4
|
141
143
|
summary: ''
|
142
144
|
test_files:
|
143
|
-
- spec/
|
145
|
+
- spec/lib/ro_thor_spec.rb
|
144
146
|
- spec/lib/ro_cmd/thor/dp_spec.rb
|
145
|
-
- spec/lib/core_ext/array_spec.rb
|
146
147
|
- spec/lib/ro_thor/ssh_spec.rb
|
147
148
|
- spec/lib/ro_thor/ro_err_spec.rb
|
149
|
+
- spec/lib/core_ext/array_spec.rb
|
148
150
|
- spec/rails_helper.rb
|
151
|
+
- spec/spec_helper.rb
|
149
152
|
- spec/mysql/my.cnf
|