execute 0.1.35 → 0.1.36
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/cmd.rb +16 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b4d882f012fc41a6d197fe677340d1cd163c251
|
4
|
+
data.tar.gz: 9869de1e75989008ae341953b9f1b06998b82063
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92e498355cf119dd509c03856bbf1c90c30fb94adf02220565a9ee6c5a7c6d7144923e6da5fdee00ae55b1aa605c121cb34c40f14fc5630de34079835cdf9e8e
|
7
|
+
data.tar.gz: ef50e6daaf13a94c8b2bca18893370c97d0d4d50dc21616c204b66101637209078d5784824b1f756e764f3a3298bbe1266dc5059ae86d2af16636a7f603339c3
|
data/lib/cmd.rb
CHANGED
@@ -37,6 +37,7 @@ class CMD < Hash
|
|
37
37
|
puts "exit_code: #{self[:exit_code]}"
|
38
38
|
end
|
39
39
|
|
40
|
+
puts "exit_code: #{self[:exit_code]}"
|
40
41
|
if((self[:exit_code] != 0) && !self[:ignore_exit_code])
|
41
42
|
exception_text = "Exit code: #{self[:exit_code]}"
|
42
43
|
exception_text = "#{exception_text}\nError: '#{self[:error]}'"
|
@@ -47,20 +48,25 @@ class CMD < Hash
|
|
47
48
|
|
48
49
|
def system
|
49
50
|
begin
|
50
|
-
output =
|
51
|
-
|
51
|
+
output = ''
|
52
|
+
error = ''
|
52
53
|
Thread.abort_on_exception = true
|
53
54
|
mutex = Mutex.new
|
55
|
+
|
54
56
|
Open3.popen3(self[:command]) do |stdin, stdout, stderr, wait_thr|
|
55
57
|
self[:pid] = wait_thr.pid
|
56
58
|
{:output => stdout,:error => stderr}.each do |key, stream|
|
57
|
-
Thread.new do
|
58
|
-
|
59
|
+
Thread.new do
|
60
|
+
while wait_thr.alive? do
|
59
61
|
if(!(char = stream.getc).nil?)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
case key
|
63
|
+
when :output
|
64
|
+
output << char
|
65
|
+
when :error
|
66
|
+
error << char
|
67
|
+
end
|
68
|
+
|
69
|
+
mutex.synchronize { putc char if(self[:echo_output]) }
|
64
70
|
else
|
65
71
|
sleep(0.1)
|
66
72
|
end
|
@@ -70,14 +76,13 @@ class CMD < Hash
|
|
70
76
|
|
71
77
|
wait_thr.join
|
72
78
|
|
73
|
-
self[:output] = output
|
74
|
-
self[:error] =
|
79
|
+
self[:output] = output.join unless(output.empty?)
|
80
|
+
self[:error] = error.join unless(error.empty?)
|
75
81
|
self[:exit_code] = wait_thr.value.to_i
|
76
82
|
end
|
77
83
|
rescue Exception => e
|
78
84
|
self[:error] = "#{self[:error]}\nException: #{e.to_s}"
|
79
85
|
self[:exit_code]=1 unless(self[:exit_code].nil? || (self[:exit_code] == 0))
|
80
|
-
raise e
|
81
86
|
rescue => e
|
82
87
|
self[:error] = "#{self[:error]}\nException: #{e.to_s}"
|
83
88
|
self[:exit_code]=1 unless(self[:exit_code].nil? || (self[:exit_code] == 0))
|