rbbt-util 5.9.4 → 5.9.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cf8e981590ec75d716c3b173786a1d9d49751af
4
- data.tar.gz: c48d0c459d08b67b68a5caf94d31bef4ea10e4c4
3
+ metadata.gz: 485bac99517b86329c91a69142f4b38c8405cc8f
4
+ data.tar.gz: f8f7fee0f9f2ceccc294431d31d1f9e14983b903
5
5
  SHA512:
6
- metadata.gz: 7687ee59c28372845dfb2d9d3606c2aa3409fcc299566530dcec737b48ef764bfadb49504d5dd0256fac2f85d8ddf10a5780642034ed6f05ccfa2a73e5b187c1
7
- data.tar.gz: f47bb2989be8fa6f39e15551caf8cd35d4506ba07092b61716e6b7a14efff001b5e12509e34266fd572f0f22cef07f4d138cd3e518c4243e6e493792027ab6b6
6
+ metadata.gz: 2b3897bc88326b032537c45579f6d6236da05b47683fd4d802cd61032c4d12c7cf35ee35898d05e19bb8a63d505c495a282206ab55a0740461b630c4cc303f92
7
+ data.tar.gz: 15680565e5cf2e61dc0770ae9b8949d890a5c13dd27a93e60eabad2c4ad3a18754056f145edc72763630d573119f9b64b6773a8bb9de9397c565bc5f4e7acc6b
@@ -180,8 +180,8 @@ class Step
180
180
  def fork(semaphore = nil)
181
181
  raise "Can not fork: Step is waiting for proces #{@pid} to finish" if not @pid.nil?
182
182
  @pid = Process.fork do
183
- trap(:INT) { raise Aborted.new "INT signal recieved" }
184
183
  begin
184
+ #trap(:INT) { raise Aborted.new "INT signal recieved" }
185
185
  RbbtSemaphore.wait_semaphore(semaphore) if semaphore
186
186
  FileUtils.mkdir_p File.dirname(path) unless Open.exists? File.dirname(path)
187
187
  begin
@@ -219,19 +219,22 @@ class Step
219
219
  RbbtSemaphore.post_semaphore(semaphore) if semaphore
220
220
  end
221
221
  end
222
+ set_info :forked, true
222
223
  Process.detach(@pid)
223
224
  self
224
225
  end
225
226
 
226
227
  def abort
227
228
  @pid ||= info[:pid]
228
- if @pid.nil?
229
+ if @pid.nil? and info[:forked]
229
230
  Log.medium "Could not abort #{path}: no pid"
230
231
  false
231
232
  else
232
233
  Log.medium "Aborting #{path}: #{ @pid }"
233
234
  begin
234
- Process.kill("INT", @pid)
235
+ Process.kill("TERM", @pid)
236
+ sleep 1
237
+ Process.kill("KILL", @pid)
235
238
  Process.waitpid @pid
236
239
  rescue Exception
237
240
  Log.debug("Aborted job #{@pid} was not killed: #{$!.message}")
@@ -3,6 +3,7 @@
3
3
  require 'rbbt/util/simpleopt'
4
4
  require 'rbbt/workflow'
5
5
  require 'rbbt/workflow/usage'
6
+ require 'time'
6
7
 
7
8
  def report_options(options)
8
9
  if options.nil? or options.empty?
@@ -265,34 +266,58 @@ begin
265
266
  end
266
267
 
267
268
  if do_fork
268
- job.fork
269
269
  if detach
270
- Process.detach job.pid
271
- puts Log.color(:magenta, "Issued: ") + Log.color(:magenta, job.pid.to_s) + ' -- ' + job.path
270
+ job.fork
271
+ Process.detach job.pid if job.pid
272
+ puts Log.color(:magenta, "Issued: ") + Log.color(:magenta, job.pid ? job.pid.to_s : 'no pid') + ' -- ' + job.path
273
+ exit 0
274
+ end
275
+
276
+ Signal.trap(:INT) do
277
+ begin
278
+ job.abort if job.info[:pid] == job.pid
279
+ rescue
280
+ end
272
281
  exit 0
273
282
  end
283
+
284
+ job.fork
285
+
274
286
  puts
275
287
  puts
288
+ size = Log.tty_size
289
+ size = 100 if size.nil?
290
+
276
291
  while not job.done?
277
292
  message = (job.messages and job.messages.any?) ? job.messages.last.strip : "no message"
278
293
  status = job.status || "no status"
279
- time = Time.now - job.info[:issued] if job.info and job.info.include? :issued
280
- size = Log.tty_size
281
- size = 100 if size.nil?
294
+ if job.info and job.info.include? :issued
295
+ issued = job.info[:issued]
296
+ issued = Time.parse(issued) unless Time === issued
297
+ time = Time.now - issued
298
+ end
282
299
  puts Log.return_line << " " * size << Log.return_line
283
300
  puts Log.return_line << " " * size << Log.return_line
284
301
  puts "#{Log.color :blue, job.path}"
285
- puts "Waiting on #{Log.color :blue, job.info[:pid] || job.pid} (+#{time.to_i if time}) " << [Log.color(:cyan, status.to_s),message.strip].compact*" "
302
+ puts "Waiting on #{Log.color :blue, job.info[:pid] || job.pid} (#{time ? time.to_i : '?'} sec. ago) " << [Log.color(:cyan, status.to_s),message.strip].compact*" "
286
303
  sleep 2
287
304
  end
288
- #Signal.trap(:INT){ job.abort }
289
305
  raise job.messages.last if job.error?
290
- res = job.load
306
+
307
+ if job.info and job.info.include? :issued
308
+ issued = job.info[:issued]
309
+ issued = Time.parse(issued) unless Time === issued
310
+ time = Time.now - issued
311
+ end
312
+ puts Log.return_line << " " * size << Log.return_line
313
+ puts Log.return_line << " " * size << Log.return_line
314
+ puts job.path
315
+ exit 0
291
316
  else
292
- res = job.run(true)
317
+ job.run(true)
318
+ res = job
293
319
  end
294
320
 
295
- puts res
296
321
 
297
322
  if options.delete(:provenance)
298
323
  pp job.provenance
@@ -332,12 +357,14 @@ if job_file = options.delete(:job_file)
332
357
  out.puts Path === file ? file.read : file
333
358
  exit 0
334
359
  end
335
- ddd 1
336
360
 
337
- if Step === res and not res.exec
361
+ case res
362
+ when (defined?(WorkflowRESTClient) and WorkflowRESTClient::RemoteStep)
363
+ out.puts res.load
364
+ when Step
338
365
  out.puts Open.read(res.path) if File.exists? res.path
339
366
  else
340
- out.puts res
367
+ out.puts res.to_s
341
368
  end
342
369
 
343
370
  exit 0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.9.4
4
+ version: 5.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez