rbbt-rest 1.8.71 → 1.8.72

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8414a3fe54af9c718109a0d9721eeaa9e2ba4a5
4
- data.tar.gz: ddb1b9f145f9609c7334830c933668c3b7ba8833
3
+ metadata.gz: 01b41fc4829f3daa31e56ccab431a410a8e25161
4
+ data.tar.gz: 9f0c0bae34075dadd5aee70f1df6f4392e8511f2
5
5
  SHA512:
6
- metadata.gz: 85b6145e42a9c0a61fc4f28174e187fd86fc087910febabfbd7230e2d5e1815cde612b8f7626458b4f77e3f33aa732069d2d2aade68b281e9297fc2d06f10c94
7
- data.tar.gz: b2c14d4eb9dcf749a11ec1216b1cb33c1e2099358ff7516891501d82cc2fc93ff94921e428e647fcc96db522a3d2cd00c760add2cdff26a83e8a568ce3d72540
6
+ metadata.gz: 680d163eae5da9a05db563a86b4f8ac7d28ac235a61d09112784872d9f1a940d513762e7521e296428e00cbe61781039d048cabdf625ab06351bf68aa9538f80
7
+ data.tar.gz: d66b91da1027832844597f946efcaab93b3b616c325c8bb8b8f14c5f4fea6a1ce788bcf94fdb85c3dcedaec01925e96bd1e5a0fadfd09cdcc8a15d99b557e64f
@@ -15,7 +15,7 @@ module Sinatra
15
15
  target_url = request.env["REQUEST_URI"]
16
16
  Log.warn{ "Unauthorized access to #{target_url}" }
17
17
  session[:target_url] = target_url
18
- redirect '/login'
18
+ redirect to('/login')
19
19
  end
20
20
 
21
21
  def logout!
@@ -59,20 +59,20 @@ module Sinatra
59
59
  session[:user] = user
60
60
  if session[:target_url]
61
61
  url = session.delete :target_url
62
- redirect url
62
+ redirect to(url)
63
63
  else
64
- redirect '/'
64
+ redirect to('/')
65
65
  end
66
66
  else
67
67
  Log.warn{ "Failed login attempt #{[user, pass] * ": "}" }
68
68
  session[:user] = nil
69
- redirect '/login'
69
+ redirect to('/login')
70
70
  end
71
71
  end
72
72
 
73
73
  app.get '/logout' do
74
74
  session[:user] = nil
75
- redirect '/'
75
+ redirect to('/')
76
76
  end
77
77
  end
78
78
  end
@@ -11,7 +11,7 @@ class RbbtGraph
11
11
  def add_associations(associations, type = :edge)
12
12
  @associations[type] ||= []
13
13
  @associations[type].concat associations.collect{|i| i }
14
- @associations[type].uniq
14
+ @associations[type].uniq!
15
15
  if AssociationItem === associations
16
16
  add_entities associations.target, associations.target_entity_type
17
17
  add_entities associations.source, associations.source_entity_type
@@ -46,15 +46,13 @@ module Sinatra
46
46
 
47
47
  get "/#{workflow.to_s}" do
48
48
  case format
49
- when :html
50
- workflow_render('tasks', workflow, nil, @clean_params)
51
49
  when :json
52
50
  content_type "application/json"
53
51
 
54
52
  @can_stream = ENV["RBBT_WORKFLOW_TASK_STREAM"] == 'true'
55
53
  {:stream => workflow.stream_exports, :exec => workflow.exec_exports, :synchronous => workflow.synchronous_exports, :asynchronous => workflow.asynchronous_exports, :can_stream => !!@can_stream}.to_json
56
54
  else
57
- raise "Unsupported format specified: #{ format }"
55
+ workflow_render('tasks', workflow, nil, @clean_params)
58
56
  end
59
57
  end
60
58
 
@@ -62,7 +62,7 @@ class StreamWorkflowTask
62
62
  sout.write last_line
63
63
  last_line = line
64
64
  end
65
- sout.write last_line.strip unless last_line == EOL
65
+ sout.write last_line.strip unless last_line.nil? or last_line == EOL
66
66
  end
67
67
 
68
68
  def get_inputs(content_type, stream)
@@ -103,34 +103,24 @@ class StreamWorkflowTask
103
103
  job.clean if job.aborted?
104
104
 
105
105
  execution_type = type_of_export(workflow, task)
106
- #execution_type = case
107
- # when workflow.exec_exports.include?(task)
108
- # "exec"
109
- # when workflow.synchronous_exports.include?(task)
110
- # "synchronous"
111
- # when workflow.asynchronous_exports.include?(task)
112
- # "asynchronous"
113
- # else
114
- # raise "No known export type for #{ workflow } #{ task }. Accesses denied"
115
- # end
116
106
 
117
107
  execution_type = "exec" if inputs["_cache_type"] == 'exec'
118
108
 
119
109
  begin
120
- case execution_type
110
+ case execution_type.to_s
121
111
  when "exec", nil
122
112
  job.exec(:stream)
123
113
  when "sync", "synchronous", "async", "asynchronous"
124
114
  if job.done? or job.started?
125
115
  done_consumer = Thread.new do
126
- Misc.consume_stream(stream)
116
+ Misc.consume_stream(clean_stream)
127
117
  end
128
118
  job.join unless job.done?
129
119
  else
130
- job.fork(:stream)
120
+ job.run(:stream)
131
121
  end
132
122
  else
133
- raise "Unknown execution_type: #{execution_type}"
123
+ raise "Unknown execution_type: #{Misc.inspect execution_type}"
134
124
  end
135
125
 
136
126
  rescue Aborted, Interrupt
@@ -168,18 +158,18 @@ class StreamWorkflowTask
168
158
  end
169
159
  rescue Aborted
170
160
  raise $!
171
- rescue Exception
161
+ rescue StandardError
172
162
  Log.exception $!
173
163
  raise $!
174
164
  ensure
175
- if sin.respond_to? :close_read
176
- sin.close_read
177
- else
178
- sin.close unless sin.closed?
179
- end
180
- if sin.respond_to? :threads
181
- sin.threads.each do |th| th.raise Aborted end
182
- end
165
+ #if sin.respond_to? :close_read
166
+ # sin.close_read
167
+ #else
168
+ # sin.close unless sin.closed?
169
+ #end
170
+ #if sin.respond_to? :threads
171
+ # sin.threads.each do |th| th.raise Aborted end
172
+ #end
183
173
 
184
174
  end
185
175
  end
@@ -197,7 +187,6 @@ class StreamWorkflowTask
197
187
  rescue Aborted, IOError
198
188
  rescue Exception
199
189
  ensure
200
- sin.close_read
201
190
  s.close
202
191
  end
203
192
  end
@@ -218,7 +207,7 @@ class StreamWorkflowTask
218
207
  return false unless content_type and content_type.include? "Rbbt_Param_Stream"
219
208
 
220
209
  encoding = env["HTTP_TRANSFER_ENCODING"]
221
- return false unless encoding == "chunked"
210
+ return false unless encoding.nil? or encoding == "chunked"
222
211
 
223
212
  true
224
213
  end
@@ -228,14 +217,43 @@ class StreamWorkflowTask
228
217
  if do_stream(env)
229
218
  begin
230
219
 
220
+
231
221
  client = env["rack.hijack"]
232
222
  buffer = client.instance_variable_get('@buffer')
233
223
  tcp_io = client.call
234
- Log.low "Hijacking post data #{tcp_io}"
235
224
 
225
+ Log.low "Hijacking post data #{tcp_io}"
236
226
  content_type = env["CONTENT_TYPE"]
227
+ encoding = env["HTTP_TRANSFER_ENCODING"]
228
+
229
+ if env["rack.input"]
230
+ tcp_merged_io = Misc.open_pipe do |sin|
231
+ rinput = env["rack.input"]
232
+ sin << rinput.instance_variable_get("@rbuf")
233
+ while c = rinput.gets
234
+ sin.puts c
235
+ end
236
+ end
237
+ else
238
+ if encoding == "chunked"
239
+ Log.low "Merging chunks #{tcp_io}"
240
+ tcp_merged_io = Misc.open_pipe do |sin|
241
+ begin
242
+ merge_chunks(tcp_io, sin, buffer);
243
+ rescue StandardError
244
+ ensure
245
+ begin
246
+ tcp_io.close_read;
247
+ rescue
248
+ end
249
+ end
250
+ end
251
+ else
252
+ tcp_merged_io = tcp_io
253
+ end
254
+ end
237
255
 
238
- tcp_merged_io = Misc.open_pipe do |sin| merge_chunks(tcp_io, sin, buffer) end
256
+ #tcp_merged_io = Misc.log_stream(tcp_merged_io)
239
257
 
240
258
  inputs, stream_input, filename, stream, boundary = get_inputs(content_type, tcp_merged_io)
241
259
 
@@ -257,19 +275,27 @@ class StreamWorkflowTask
257
275
  tcp_io.write "RBBT-STREAMING-JOB-URL: #{ job_url }\r\n"
258
276
  tcp_io.write "\r\n"
259
277
  Log.high "Comsuming response #{Misc.fingerprint tcp_io}"
260
- Misc.consume_stream(out_stream, false, tcp_io)
278
+ begin
279
+ while l = out_stream.readpartial(2048)
280
+ tcp_io.write l
281
+ end
282
+ rescue EOFError
283
+ end
261
284
  Log.high "Comsumed response #{Misc.fingerprint tcp_io}"
285
+ out_stream.join if out_stream.respond_to? :join
262
286
  rescue Exception
263
287
  Log.exception $!
288
+ raise $!
264
289
  end if out_stream
265
290
 
266
- tcp_io.close unless tcp_io.closed?
291
+ tcp_io.close_write unless tcp_io.closed?
267
292
  Log.high "Closed io #{tcp_io}"
268
293
 
269
294
  [-1, {}, []]
270
295
  rescue Exception
271
296
  Log.exception $!
272
- tcp_io.write "HTTP/1.1 515\r\n"
297
+ job.exception $! if job
298
+ tcp_io.write "HTTP/1.1 500\r\n"
273
299
  tcp_io.write "Connection: close\r\n"
274
300
  tcp_io.write "\r\n"
275
301
  tcp_io.close_write
@@ -27,7 +27,7 @@ body
27
27
  display: inline-block !important
28
28
 
29
29
  .dropdown.item
30
- height: 100%
30
+ max-height: 100%
31
31
  &:before
32
32
  background: none
33
33
 
@@ -1 +1,7 @@
1
- %a(href="#{@path}?_format=binary") Download
1
+ %a(href="?_format=binary") Download
2
+
3
+ - if job
4
+ - extension = job.path.split(".").last
5
+ - if extension == 'png' or extension == 'jpg'
6
+ .figure
7
+ %img(src="?_format=binary" style="max-width:100%")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.71
4
+ version: 1.8.72
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-28 00:00:00.000000000 Z
11
+ date: 2017-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake