execute 0.1.34 → 0.1.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cmd.rb +11 -2
- 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: 6d65d79f1bc16f9472cc48aa7f5d346800f6c359
|
4
|
+
data.tar.gz: b8f2bc998ec198049ebb11740681bde43e4257d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49cbc3ceb5ab3b33597bfea0a281403d83c8a80d264ec588fce56bd0ad251cc23b9732f25a0545005a50777ef9be2c663353896f506aaad997ea993fe80317a7
|
7
|
+
data.tar.gz: 84cd40d6473bbbcda35c14e4a2e182288b145159ce078a9254c16bc3c9a4e23c5ef7adddfdbc5ecc13ce45c9d8787d32ff28762fcc758292f920a582e28da8b6
|
data/lib/cmd.rb
CHANGED
@@ -48,14 +48,19 @@ class CMD < Hash
|
|
48
48
|
def system
|
49
49
|
begin
|
50
50
|
output = {output: [], error: [] }
|
51
|
+
|
52
|
+
Thread.abort_on_exception = true
|
53
|
+
mutex = Mutex.new
|
51
54
|
Open3.popen3(self[:command]) do |stdin, stdout, stderr, wait_thr|
|
52
55
|
self[:pid] = wait_thr.pid
|
53
56
|
{:output => stdout,:error => stderr}.each do |key, stream|
|
54
57
|
Thread.new do
|
55
58
|
while wait_thr.alive? do
|
56
59
|
if(!(char = stream.getc).nil?)
|
57
|
-
|
58
|
-
|
60
|
+
mutex.synchronize do
|
61
|
+
output[key] << char
|
62
|
+
putc char if(self[:echo_output])
|
63
|
+
end
|
59
64
|
else
|
60
65
|
sleep(0.1)
|
61
66
|
end
|
@@ -69,6 +74,10 @@ class CMD < Hash
|
|
69
74
|
self[:error] = output[:error].join unless(output[:error].empty?)
|
70
75
|
self[:exit_code] = wait_thr.value.to_i
|
71
76
|
end
|
77
|
+
rescue Exception => e
|
78
|
+
self[:error] = "#{self[:error]}\nException: #{e.to_s}"
|
79
|
+
self[:exit_code]=1 unless(self[:exit_code].nil? || (self[:exit_code] == 0))
|
80
|
+
raise e
|
72
81
|
rescue => e
|
73
82
|
self[:error] = "#{self[:error]}\nException: #{e.to_s}"
|
74
83
|
self[:exit_code]=1 unless(self[:exit_code].nil? || (self[:exit_code] == 0))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: execute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Marshall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|