maestro_plugin 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/maestro_plugin/maestro_worker.rb +32 -0
- data/lib/maestro_plugin/version.rb +1 -1
- data/spec/maestro_worker_spec.rb +15 -0
- 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: e719015fbdabceaf74a2229bb76721c822f45346
|
4
|
+
data.tar.gz: c53a224127581e6ad1849888ca3cb4743b08f4f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b218bf2c4cd5055aaaa656531983d3c499e982d87b5f9569eae2775ba5264935a9fb119899345f88c195ddd0f05fd194803699040148faa52893a6a4d719c0a
|
7
|
+
data.tar.gz: 51686641189e11d6ba4209c1f1076c135f2d7ffa92180b3ba972535156ab108a82de59578f0958a431ac2cffe197eb850c4f5c875b1837fc97be54a33f4f7ca7
|
@@ -177,6 +177,38 @@ module Maestro
|
|
177
177
|
#
|
178
178
|
# The 2 second factor is there to allow slowly accumulating data to be sent out more regularly.
|
179
179
|
if !@buffered_output.empty? && (!options[:buffer] || Time.now - @last_write_output > 2)
|
180
|
+
# Ensure the output is json-able.
|
181
|
+
# It seems some code doesn't wholly respect encoding rules. We've found some http responses that
|
182
|
+
# don't have the correct encoding, despite the response headers stating 'utf-8', etc. Same goes
|
183
|
+
# for shell output streams, that don't seem to respect the apps encoding.
|
184
|
+
# What this code does is to try to json encode the @buffered_output. First a direct conversion,
|
185
|
+
# if that fails, try to force-encoding to utf-8, if that fails, try to remove all chars with
|
186
|
+
# code > 127. If that fails - we gave it a good shot, and maybe just insert a 'redacted' string
|
187
|
+
# so at least the task doesn't fail :)
|
188
|
+
begin
|
189
|
+
@buffered_output.to_json
|
190
|
+
rescue Exception
|
191
|
+
begin
|
192
|
+
test = @buffered_output
|
193
|
+
test.force_encoding('UTF-8')
|
194
|
+
test.to_json
|
195
|
+
# If forcing encoding worked, updated buffered_output
|
196
|
+
Maestro.log.warn("Had to force encoding to utf-8 for workitem stream")
|
197
|
+
@buffered_output = test
|
198
|
+
rescue Exception
|
199
|
+
begin
|
200
|
+
test = @buffered_output.gsub(/[^\x00-\x7f]/, '?')
|
201
|
+
test.to_json
|
202
|
+
# If worked, updated buffered_output
|
203
|
+
Maestro.log.warn("Had to strip top-bit-set chars for workitem stream")
|
204
|
+
@buffered_output = test
|
205
|
+
rescue Exception
|
206
|
+
Maestro.log.warn("Had to redact block of output, unable to 'to_json' it for workitem stream")
|
207
|
+
@buffered_output = '?_?'
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
180
212
|
if !MaestroWorker.mock?
|
181
213
|
workitem[OUTPUT_META] = @buffered_output
|
182
214
|
else
|
data/spec/maestro_worker_spec.rb
CHANGED
@@ -62,6 +62,21 @@ describe Maestro::MaestroWorker do
|
|
62
62
|
subject.workitem['__streaming__'].should be_nil
|
63
63
|
end
|
64
64
|
|
65
|
+
it 'should handle non utf-8 strings with funky characters (complete failure)' do
|
66
|
+
text = "\x8f"
|
67
|
+
text.force_encoding("US-ASCII")
|
68
|
+
subject.write_output(text)
|
69
|
+
subject.workitem['__output__'].should eql("?_?")
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should handle non utf-8 strings with funky characters (partial failure)' do
|
73
|
+
text = "missing \xc3\xa9"
|
74
|
+
text = text.force_encoding("ASCII-8BIT")
|
75
|
+
expect { text.to_json}.to raise_exception(Encoding::ConverterNotFoundError)
|
76
|
+
subject.write_output(text)
|
77
|
+
subject.workitem['__output__'].should eql("missing \u00E9")
|
78
|
+
end
|
79
|
+
|
65
80
|
it 'should send a not needed message' do
|
66
81
|
subject.not_needed
|
67
82
|
subject.workitem['__not_needed__'].should be_nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maestro_plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Etienne Pelletier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|