execute 0.1.66 → 0.1.67
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/execute.rb +28 -16
- 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: f400a72ed951d57586f00ead9719775c1306c0ad
|
4
|
+
data.tar.gz: 4a0b12e141723950038c9b096987ec21bfa3b3a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4bdb4436e67cf1a4129018dd5ded58bd1f6c8580e9e05a3c88d73b056c436db6074dcba294ac501cc9ceffd1770a30f01aa262482f1f18f1d8a01b6cb0549cf
|
7
|
+
data.tar.gz: 5f2bad414bce3ccd732c8144083ea5cd2a9c2b71280915189204d13f1ade0e8bc0d3455060daa8b4de43aca34f7cf864bd6fa4473ec92a52adebb739c85b6a9e
|
data/lib/execute.rb
CHANGED
@@ -74,6 +74,7 @@ class Execute < Hash
|
|
74
74
|
output = ''
|
75
75
|
error = ''
|
76
76
|
|
77
|
+
threads = []
|
77
78
|
mutex = Mutex.new
|
78
79
|
stop_threads = false
|
79
80
|
timeout = nil
|
@@ -84,27 +85,37 @@ class Execute < Hash
|
|
84
85
|
|
85
86
|
unless(timeout.nil?)
|
86
87
|
start_time = Time.now
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
88
|
+
end_loop = stop_threads
|
89
|
+
threads << Thread.new do
|
90
|
+
begin
|
91
|
+
while wait_thr.alive? && !end_loop do
|
92
|
+
if((Time.now - start_time).to_f > timeout)
|
93
|
+
self[:timed_out] = true
|
94
|
+
mutex.synchronize { stop_threads = true }
|
95
|
+
interrupt
|
96
|
+
Thread.exit
|
97
|
+
else
|
98
|
+
sleep(1)
|
99
|
+
Thread.pass
|
100
|
+
end
|
101
|
+
mutex.synchronize { end_loop = stop_threads }
|
94
102
|
end
|
95
|
-
|
103
|
+
rescue Exception => e
|
104
|
+
mutex.synchronize { stop_threads = true }
|
105
|
+
Thread.exit
|
96
106
|
end
|
97
107
|
end
|
98
108
|
end
|
99
109
|
|
100
110
|
{:output => stdout,:error => stderr}.each do |key, stream|
|
101
|
-
Thread.new do
|
111
|
+
threads << Thread.new do
|
102
112
|
begin
|
103
|
-
|
113
|
+
end_loop = stop_threads
|
114
|
+
while wait_thr.alive? && !end_loop do
|
104
115
|
unless(stream.closed?)
|
105
116
|
if((char = stream.getc).nil?)
|
106
117
|
sleep(0.1)
|
107
|
-
|
118
|
+
Thread.pass
|
108
119
|
else
|
109
120
|
case key
|
110
121
|
when :output
|
@@ -115,24 +126,25 @@ class Execute < Hash
|
|
115
126
|
end
|
116
127
|
end
|
117
128
|
end
|
129
|
+
mutex.synchronize { end_loop = stop_threads }
|
118
130
|
end
|
119
131
|
mutex.synchronize { stop_threads = true }
|
120
|
-
rescue
|
132
|
+
rescue Exception
|
121
133
|
mutex.synchronize { stop_threads = true }
|
122
|
-
Thread.
|
134
|
+
Thread.exit
|
123
135
|
end
|
124
136
|
end
|
125
137
|
end
|
126
138
|
|
127
|
-
|
128
|
-
|
139
|
+
threads.each { |thr| thr.join }
|
140
|
+
|
129
141
|
self[:output] = output unless(output.empty?)
|
130
142
|
self[:error] = error unless(error.empty?)
|
131
143
|
self[:exit_code] = wait_thr.value.to_i
|
132
144
|
end
|
133
145
|
rescue Exception => e
|
134
146
|
self[:error] = "#{self[:error]}\nException: #{e.to_s}"
|
135
|
-
|
147
|
+
self[:exit_code]=1 unless(self[:exit_code].nil? || (self[:exit_code] == 0))
|
136
148
|
end
|
137
149
|
end
|
138
150
|
def call_capture
|
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.67
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Marshall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|