rbbt-util 5.34.7 → 5.34.10

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
  SHA256:
3
- metadata.gz: ec5860171e51e2e53a8383ae8ea1156b79c7f75194d384c5aa2c43efd759e129
4
- data.tar.gz: a6ab8a782b3169eae1e475a2029e8a4f0ac2d12f375475ec70de9d97f513f21a
3
+ metadata.gz: c8d689458bf34dc4d6f87f0541579a39ce1820470028db527ea366ad9ebb5c60
4
+ data.tar.gz: 4adc7dfec047abdeff9783386c2d0c017b37e4459b51d928179dc9199a779b5c
5
5
  SHA512:
6
- metadata.gz: 2fb6a8ac5abee267891f6bb0736b659f202019de75fa0ecef80e955838a54013eaeabb495c44daff45196a8706821b706bfae75b095ce3ca8b82e8351436d4ef
7
- data.tar.gz: ab24e4ab588e75f94adfcd9a02e178511bd4471edadef18c6c49537974353b8b4d83c61438d8fe638acbc26101556637a92d5da325ebc135736da44558971334
6
+ metadata.gz: ec17b39479ed23fabae816d724281a9228ca0fcced777cb3d22c23a3a04e136e132b67cb7e0b5c82aec1e754253983f8912f5d7af4ab52d80cb3d3e0464f8fd2
7
+ data.tar.gz: a61457b87e1ce1243c903e46bf06f88242fbb6e939eb44f9fb23a8531c24e023471cbb2d42ecd7f3886eb7efa52d333ac94df348a0f8e29be0eecacc4d5d0ae8
@@ -514,7 +514,7 @@ env > #{batch_options[:fenv]}
514
514
 
515
515
  %w(std.out std.err job.id job.status dependencies.list canfail_dependencies.list exit.status sync.log inputs_dir).each do |filename|
516
516
  path = File.join(batch_dir, filename)
517
- Open.rm_rf path if File.exists? path
517
+ Open.rm_rf path if File.exist? path
518
518
  end if clean_batch_job
519
519
 
520
520
  batch_dependencies = [] if batch_dependencies.nil?
@@ -584,14 +584,14 @@ env > #{batch_options[:fenv]}
584
584
 
585
585
  job = Open.read(fjob).strip if Open.exists?(fjob)
586
586
 
587
- if job && ! File.exists?(fexit)
587
+ if job && ! File.exist?(fexit)
588
588
  begin
589
589
  status_txt = job_status(job)
590
590
  STDERR.puts Log.color(:magenta, "Status [#{job.to_i}]:")
591
591
  STDERR.puts status_txt
592
592
  lines = status_txt.split("\n").length
593
593
  rescue
594
- if ! File.exists?(fexit)
594
+ if ! File.exist?(fexit)
595
595
  STDERR.puts Log.color(:magenta, "Job #{job.to_i} not done and not running. STDERR:")
596
596
  STDERR.puts Open.read(ferr)
597
597
  end
@@ -599,7 +599,7 @@ env > #{batch_options[:fenv]}
599
599
  end
600
600
  end
601
601
 
602
- if File.exists?(fexit)
602
+ if File.exist?(fexit)
603
603
  exit_status = Open.read(fexit)
604
604
  if exit_status.to_i == 0
605
605
  STDERR.puts Log.color(:magenta, "Job #{job} done with exit_status 0. STDOUT:")
@@ -613,7 +613,7 @@ env > #{batch_options[:fenv]}
613
613
 
614
614
  if tail
615
615
  Log.severity = 10
616
- while ! File.exists? fout
616
+ while ! File.exist? fout
617
617
  if job
618
618
  STDERR.puts
619
619
  Log.clear_line(STDERR)
@@ -638,8 +638,8 @@ env > #{batch_options[:fenv]}
638
638
  begin
639
639
  status_txt = job_status(job)
640
640
  Open.write(fstatus, status_txt) unless status_txt.nil? || status_txt.empty?
641
- out = CMD.cmd("tail -f '#{fout}'", :pipe => true) if File.exists?(fout) and not tail == :STDERR
642
- err = CMD.cmd("tail -f '#{ferr}'", :pipe => true) if File.exists?(ferr)
641
+ out = CMD.cmd("tail -f '#{fout}'", :pipe => true) if File.exist?(fout) and not tail == :STDERR
642
+ err = CMD.cmd("tail -f '#{ferr}'", :pipe => true) if File.exist?(ferr)
643
643
 
644
644
  terr = Misc.consume_stream(err, true, STDERR) if err
645
645
  tout = Misc.consume_stream(out, true, STDOUT) if out
data/lib/rbbt/hpc/lsf.rb CHANGED
@@ -70,12 +70,12 @@ export BATCH_SYSTEM=LSF
70
70
  STDERR.puts Log.color(:magenta, "Issuing LSF file: #{fcmd}")
71
71
  STDERR.puts Open.read(fcmd)
72
72
 
73
- if File.exists?(fjob)
73
+ if File.exist?(fjob)
74
74
  job = Open.read(fjob).to_i
75
75
  else
76
76
 
77
- dependencies = Open.read(fdep).split("\n") if File.exists? fdep
78
- canfail_dependencies = Open.read(fcfdep).split("\n") if File.exists? fcfdep
77
+ dependencies = Open.read(fdep).split("\n") if File.exist? fdep
78
+ canfail_dependencies = Open.read(fcfdep).split("\n") if File.exist? fcfdep
79
79
 
80
80
  normal_dep_list = dependencies && dependencies.any? ? dependencies.collect{|d| "post_done(#{d})"} : []
81
81
  canfail_dep_list = canfail_dependencies && canfail_dependencies.any? ? canfail_dependencies.collect{|d| "done(#{d})"} : []
@@ -90,7 +90,7 @@ export BATCH_SYSTEM=LSF
90
90
 
91
91
  cmd = "bsub #{dep_str} < '#{fcmd}'"
92
92
 
93
- if File.exists?(fout)
93
+ if File.exist?(fout)
94
94
  return
95
95
  elsif dry_run
96
96
  STDERR.puts Log.color(:magenta, "To execute run: ") + Log.color(:blue, cmd)
@@ -101,12 +101,12 @@ export BATCH_SYSTEM=SLURM
101
101
  Log.info "Issuing SLURM file: #{fcmd}"
102
102
  Log.debug Open.read(fcmd)
103
103
 
104
- if File.exists?(fjob)
104
+ if File.exist?(fjob)
105
105
  job = Open.read(fjob).to_i
106
106
  else
107
107
 
108
- dependencies = Open.read(fdep).split("\n") if File.exists? fdep
109
- canfail_dependencies = Open.read(fcfdep).split("\n") if File.exists? fcfdep
108
+ dependencies = Open.read(fdep).split("\n") if File.exist? fdep
109
+ canfail_dependencies = Open.read(fcfdep).split("\n") if File.exist? fcfdep
110
110
 
111
111
  normal_dep_str = dependencies && dependencies.any? ? "afterok:" + dependencies * ":" : nil
112
112
  canfail_dep_str = canfail_dependencies && canfail_dependencies.any? ? "afterany:" + canfail_dependencies * ":" : nil
@@ -119,7 +119,7 @@ export BATCH_SYSTEM=SLURM
119
119
 
120
120
  cmd = "sbatch #{dep_str} '#{fcmd}'"
121
121
 
122
- if File.exists?(fout)
122
+ if File.exist?(fout)
123
123
  return
124
124
  elsif dry_run
125
125
  STDERR.puts Log.color(:magenta, "To execute run: ") + Log.color(:blue, "sbatch '#{fcmd}'")
@@ -16,7 +16,7 @@ module Persist
16
16
  end
17
17
 
18
18
  dir = File.dirname(File.expand_path(path))
19
- File.mkdir(dir) unless File.exists?(dir)
19
+ File.mkdir(dir) unless File.exist?(dir)
20
20
 
21
21
  tokyocabinet_class = TokyoCabinet::HDB if tokyocabinet_class == "HDB" or tokyocabinet_class.nil?
22
22
  tokyocabinet_class = TokyoCabinet::BDB if tokyocabinet_class == "BDB"
data/lib/rbbt/persist.rb CHANGED
@@ -31,8 +31,8 @@ module Persist
31
31
  path = path.find if Path === path
32
32
  file = file.find if Path === file
33
33
  if by_link
34
- patht = File.exists?(path) ? File.lstat(path).mtime : nil
35
- filet = File.exists?(file) ? File.lstat(file).mtime : nil
34
+ patht = File.exist?(path) ? File.lstat(path).mtime : nil
35
+ filet = File.exist?(file) ? File.lstat(file).mtime : nil
36
36
  else
37
37
  patht = Open.mtime(path)
38
38
  filet = Open.mtime(file)
data/lib/rbbt/resource.rb CHANGED
@@ -233,7 +233,7 @@ module Resource
233
233
  when :install
234
234
  Log.debug "Installing software: #{path}"
235
235
 
236
- $set_software_env = false unless File.exists? path
236
+ $set_software_env = false unless File.exist? path
237
237
 
238
238
  software_dir = path.resource.root.software.find :user
239
239
  helper_file = File.expand_path(Rbbt.share.install.software.lib.install_helpers.find(:lib, caller_lib_dir(__FILE__)))
@@ -527,13 +527,21 @@ module TSV
527
527
  self.unnamed = old_unnamed
528
528
 
529
529
  when String === method
530
- with_unnamed do
531
- through :key, key do |key, values|
532
- values = [values] if type == :single
533
- new[key] = self[key] if invert ^ (values.flatten.select{|v| v == method}.length > 0)
530
+ if method =~ /^([<>]=?)(.*)/
531
+ with_unnamed do
532
+ through :key, key do |key, values|
533
+ value = Array === values ? values.flatten.first : values
534
+ new[key] = self[key] if value.to_f.send($1, $2.to_f)
535
+ end
536
+ end
537
+ else
538
+ with_unnamed do
539
+ through :key, key do |key, values|
540
+ values = [values] if type == :single
541
+ new[key] = self[key] if invert ^ (values.flatten.select{|v| v == method}.length > 0)
542
+ end
534
543
  end
535
544
  end
536
-
537
545
  when Numeric === method
538
546
  with_unnamed do
539
547
  through :key, key do |key, values|
@@ -145,7 +145,7 @@ module Rbbt::Config
145
145
  end
146
146
 
147
147
  def self.process_config(config)
148
- if Misc.is_filename?(config) && File.exists?(config)
148
+ if Misc.is_filename?(config) && File.exist?(config)
149
149
  Rbbt::Config.load_file(config)
150
150
  elsif Rbbt.etc.config_profile[config].exists?
151
151
  Rbbt::Config.load_file(Rbbt.etc.config_profile[config].find)
@@ -49,6 +49,9 @@ module Log
49
49
  end
50
50
 
51
51
  def init
52
+ @ticks, @bytes = 0
53
+ @last_time = @last_count = @last_percent = nil
54
+ @history, @mean_max, @max_history = nil
52
55
  @start = @last_time = Time.now
53
56
  @last_count = 0
54
57
  report
@@ -17,7 +17,7 @@ puts path.glob_all.collect{|p| File.directory?(p) ? p + "/" : p } * "\n"
17
17
 
18
18
  [path, paths.collect{|p| [source, p] * ":"}, lpath]
19
19
  else
20
- if File.exists?(path)
20
+ if File.exist?(path)
21
21
  path = resource.identify(path)
22
22
  else
23
23
  path = Path.setup(path)
@@ -266,7 +266,7 @@ module Misc
266
266
 
267
267
  def self.mtime_str(path)
268
268
  path = path.find if Path === path
269
- if File.exists? path
269
+ if File.exist? path
270
270
  "mtime: " << File.mtime(path).to_s
271
271
  else
272
272
  "mtime: not present"
@@ -416,7 +416,7 @@ module Misc
416
416
  end
417
417
 
418
418
  def self.file2md5(file)
419
- if File.exists?(file + '.md5')
419
+ if File.exist?(file + '.md5')
420
420
  Open.read(file + '.md5')
421
421
  else
422
422
  md5 = CMD.cmd("md5sum '#{file}'").read.strip.split(" ").first
@@ -39,11 +39,11 @@ module Misc
39
39
  begin
40
40
  erase = path.nil?
41
41
  path = TmpFile.tmp_file if path.nil?
42
- File.rm path if clean && File.exists?(path)
42
+ File.rm path if clean && File.exist?(path)
43
43
  File.mkfifo path
44
44
  yield path
45
45
  ensure
46
- FileUtils.rm path if erase && File.exists?(path)
46
+ FileUtils.rm path if erase && File.exist?(path)
47
47
  end
48
48
  end
49
49
 
@@ -340,11 +340,11 @@ module Misc
340
340
  Log.medium "Consume stream aborted #{Misc.fingerprint io}"
341
341
  io.abort if io.respond_to? :abort
342
342
  #io.close unless io.closed?
343
- FileUtils.rm into_path if into_path and File.exists? into_path
343
+ FileUtils.rm into_path if into_path and File.exist? into_path
344
344
  rescue Exception
345
345
  Log.medium "Exception consuming stream: #{Misc.fingerprint io}: #{$!.message}"
346
346
  io.abort $! if io.respond_to? :abort
347
- FileUtils.rm into_path if into_path and File.exists? into_path
347
+ FileUtils.rm into_path if into_path and File.exist? into_path
348
348
  raise $!
349
349
  end
350
350
  end
@@ -389,8 +389,8 @@ module Open
389
389
  # source = source.find if Path === source
390
390
  # target = target.find if Path === target
391
391
 
392
- # FileUtils.mkdir_p File.dirname(target) unless File.exists?(File.dirname(target))
393
- # FileUtils.rm target if File.exists?(target)
392
+ # FileUtils.mkdir_p File.dirname(target) unless File.exist?(File.dirname(target))
393
+ # FileUtils.rm target if File.exist?(target)
394
394
  # FileUtils.cp source, target
395
395
  #end
396
396
 
data/lib/rbbt/util/tar.rb CHANGED
@@ -93,7 +93,7 @@ module Misc
93
93
  # directory
94
94
  def self.untar(io, destination)
95
95
  io = io.find if Path === io
96
- if String === io and File.exists?(io)
96
+ if String === io and File.exist?(io)
97
97
  Open.open(io) do |f|
98
98
  untar(f, destination)
99
99
  end
@@ -13,7 +13,7 @@ module Workflow
13
13
  nextflow_includes(file).inject(params) do |params,info|
14
14
  name_str, included_file = info
15
15
  included_file = File.join(dir, included_file)
16
- included_file += '.nf' unless File.exists?(included_file) || ! File.exists?(included_file + '.nf')
16
+ included_file += '.nf' unless File.exist?(included_file) || ! File.exist?(included_file + '.nf')
17
17
  name_str.split(";").each do |name|
18
18
  name = name.strip
19
19
  include_params = nextflow_recursive_params(included_file).collect{|p| [p,name] * "-"}
@@ -32,7 +32,7 @@ module Workflow
32
32
  result = :text
33
33
  end
34
34
 
35
- file = file + '.nf' unless File.exists?(file) || ! File.exists?(file + '.nf')
35
+ file = file + '.nf' unless File.exist?(file) || ! File.exist?(file + '.nf')
36
36
  file = File.expand_path(file)
37
37
  name ||= File.basename(file).sub(/\.nf$/,'').gsub(/\s/,'_')
38
38
  params = Workflow.nextflow_recursive_params(file)
@@ -92,7 +92,7 @@ class Step
92
92
  (!(job.noinfo? || job.done? || job.error? || job.aborted? || job.running?))
93
93
 
94
94
  if ! (job.resumable? && (job.updated? && ! job.dirty?))
95
- Log.high "About to clean -- status: #{status}, present #{File.exists?(job.path)}, " +
95
+ Log.high "About to clean -- status: #{status}, present #{File.exist?(job.path)}, " +
96
96
  %w(done? error? recoverable_error? noinfo? updated? dirty? aborted? running? resumable?).
97
97
  collect{|v| [v, job.send(v)]*": "} * ", " if RBBT_DEBUG_CLEAN
98
98
 
@@ -421,7 +421,7 @@ class Step
421
421
  config_keys = Rbbt::Config::GOT_KEYS[config_keys_pre.length..-1]
422
422
  set_info :config_keys, config_keys.uniq
423
423
 
424
- if result.nil? && File.exists?(self.tmp_path) && ! File.exists?(self.path)
424
+ if result.nil? && File.exist?(self.tmp_path) && ! File.exist?(self.path)
425
425
  Open.mv self.tmp_path, self.path
426
426
  end
427
427
  result
@@ -2,12 +2,12 @@ module Workflow
2
2
 
3
3
  def self.load_inputs(dir, input_names, input_types)
4
4
  inputs = {}
5
- if File.exists?(dir) && ! File.directory?(dir)
5
+ if File.exist?(dir) && ! File.directory?(dir)
6
6
  Log.debug "Loading inputs from #{dir}, not a directory trying as tar.gz"
7
7
  tarfile = dir
8
8
  digest = CMD.cmd("md5sum '#{tarfile}'").read.split(" ").first
9
9
  tmpdir = Rbbt.tmp.input_bundle[digest].find
10
- Misc.untar(tarfile, tmpdir) unless File.exists? tmpdir
10
+ Misc.untar(tarfile, tmpdir) unless File.exist? tmpdir
11
11
  files = tmpdir.glob("*")
12
12
  if files.length == 1 && File.directory?(files.first)
13
13
  tmpdir = files.first
@@ -256,7 +256,7 @@ class Step
256
256
  # when Step === value
257
257
  # Open.ln_s(value.path, path)
258
258
  # when type.to_s == "binary"
259
- # if String === value && File.exists?(value)
259
+ # if String === value && File.exist?(value)
260
260
  # value = File.expand_path(value)
261
261
  # Open.ln_s(value, path)
262
262
  # elsif String === value && Misc.is_filename?(value, false)
@@ -269,7 +269,7 @@ class Step
269
269
  # when Array === value
270
270
  # Open.write(path, value.collect{|v| Step === v ? v.path : v.to_s} * "\n")
271
271
  # when %w(file tsv array).include?(type.to_s)
272
- # if String === value && File.exists?(value)
272
+ # if String === value && File.exist?(value)
273
273
  # value = File.expand_path(value)
274
274
  # Open.ln_s(value, path)
275
275
  # elsif String === value && Misc.is_filename?(value, false)
@@ -280,7 +280,7 @@ class Step
280
280
  # Open.write(path + '.yaml', value.to_yaml)
281
281
  # end
282
282
  # when IO === value
283
- # if value.filename && String === value.filename && File.exists?(value.filename)
283
+ # if value.filename && String === value.filename && File.exist?(value.filename)
284
284
  # Open.ln_s(value.filename, path)
285
285
  # else
286
286
  # Open.write(path, value)
@@ -13,9 +13,9 @@ class Step
13
13
  return if target_dir[workflow][task][name].exists? || File.symlink?(target_dir[workflow][task][name].find)
14
14
  Log.debug "Linking #{ path }"
15
15
  FileUtils.mkdir_p target_dir[workflow][task] unless target_dir[workflow][task].exists?
16
- FileUtils.ln_s path, target_dir[workflow][task][name].find if File.exists?(path)
17
- FileUtils.ln_s path + '.files', target_dir[workflow][task][name].find + '.files' if File.exists?(path + '.files')
18
- FileUtils.ln_s path + '.info', target_dir[workflow][task][name].find + '.info' if File.exists?(path + '.info')
16
+ FileUtils.ln_s path, target_dir[workflow][task][name].find if File.exist?(path)
17
+ FileUtils.ln_s path + '.files', target_dir[workflow][task][name].find + '.files' if File.exist?(path + '.files')
18
+ FileUtils.ln_s path + '.info', target_dir[workflow][task][name].find + '.info' if File.exist?(path + '.info')
19
19
  end
20
20
 
21
21
  def archive(target = nil)
@@ -65,15 +65,15 @@ class Step
65
65
  end.uniq
66
66
 
67
67
  jobs.each do |step|
68
- next unless File.exists?(step.path)
68
+ next unless File.exist?(step.path)
69
69
  next if skip_overriden && step.overriden
70
70
 
71
71
  job_files << step.path
72
- job_files << step.info_file if File.exists?(step.info_file)
73
- job_files << Step.md5_file(step.path) if File.exists?(Step.md5_file step.path)
72
+ job_files << step.info_file if File.exist?(step.info_file)
73
+ job_files << Step.md5_file(step.path) if File.exist?(Step.md5_file step.path)
74
74
  job_file_dir_content = Dir.glob(step.files_dir + '/**/*')
75
75
  job_files += job_file_dir_content
76
- job_files << step.files_dir if File.exists?(step.files_dir)
76
+ job_files << step.files_dir if File.exist?(step.files_dir)
77
77
  rec_dependencies = Set.new
78
78
 
79
79
  next unless recursive
@@ -99,7 +99,7 @@ class Step
99
99
  dep = Workflow.load_step path
100
100
  job_files << dep.path
101
101
  job_files << dep.files_dir if Dir.glob(dep.files_dir + '/*').any?
102
- job_files << dep.info_file if File.exists?(dep.info_file)
102
+ job_files << dep.info_file if File.exist?(dep.info_file)
103
103
  end
104
104
  end
105
105
 
data/lib/rbbt/workflow.rb CHANGED
@@ -543,13 +543,13 @@ module Workflow
543
543
  persist = input_values.nil? ? false : true
544
544
  persist = false
545
545
 
546
- if ! (Path === step_path ? step_path.find : File.exists?(step_path)) && step_path.split("/").length == 3 && File.exists?(new_path = Rbbt.var.jobs[step_path].find)
546
+ if ! (Path === step_path ? step_path.find : File.exist?(step_path)) && step_path.split("/").length == 3 && File.exist?(new_path = Rbbt.var.jobs[step_path].find)
547
547
  step_path = new_path
548
548
  end
549
549
 
550
550
  key = Path === step_path ? step_path.find : step_path
551
551
 
552
- if ! File.exists?(step_path) && step_path.split("/").length == 3 && File.exists?(new_path = Rbbt.var.jobs[step_path].find)
552
+ if ! File.exist?(step_path) && step_path.split("/").length == 3 && File.exist?(new_path = Rbbt.var.jobs[step_path].find)
553
553
  step_path = new_path
554
554
  end
555
555
 
@@ -602,7 +602,7 @@ module Workflow
602
602
  pother = other.split(/\/+/)
603
603
  end_part = pother[-3..-1] * "/"
604
604
  new_path = prefix + "/" << end_part
605
- if File.exists? new_path
605
+ if File.exist? new_path
606
606
  new_path
607
607
  else
608
608
  Rbbt.var.jobs[end_part].find
@@ -615,7 +615,7 @@ module Workflow
615
615
  pother = other.split(/\/+/)
616
616
  end_part = pother[-3..-1] * "/"
617
617
  new_path = preal[0..-4] * "/" << "/" << end_part
618
- return new_path if File.exists?(new_path) || File.exists?(new_path + '.info')
618
+ return new_path if File.exist?(new_path) || File.exist?(new_path + '.info')
619
619
  Rbbt.var.jobs[end_part].find
620
620
  end
621
621
 
@@ -713,7 +713,7 @@ module Workflow
713
713
  def self.load_step(path)
714
714
  path = Path.setup(path.dup) unless Path === path
715
715
 
716
- if ! (Path === path ? path.exists? : File.exists?(path)) && path.split("/").length == 3
716
+ if ! (Path === path ? path.exists? : File.exist?(path)) && path.split("/").length == 3
717
717
  new_path = Rbbt.var.jobs[path]
718
718
  if new_path.exists? || new_path.set_extension('info').exists?
719
719
  path = new_path
@@ -97,19 +97,19 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
97
97
 
98
98
  different_system = job_batch_system != batch_system
99
99
 
100
- if File.exists?(fid = File.join(dir, 'job.id'))
100
+ if File.exist?(fid = File.join(dir, 'job.id'))
101
101
  id = Open.read(fid).chomp
102
102
  else
103
103
  id = nil
104
104
  end
105
105
 
106
- if File.exists?(fstatus = File.join(dir, 'exit.status'))
106
+ if File.exist?(fstatus = File.join(dir, 'exit.status'))
107
107
  exit_status = Open.read(fstatus).to_i
108
108
  else
109
109
  exit_status = nil
110
110
  end
111
111
 
112
- if File.exists?(fstatus = File.join(dir, 'job.status'))
112
+ if File.exist?(fstatus = File.join(dir, 'job.status'))
113
113
  fstatus_txt = Open.read(fstatus)
114
114
  begin
115
115
  if job_batch_system == "lsf"
@@ -126,17 +126,17 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
126
126
  nodes = []
127
127
  end
128
128
 
129
- if File.exists?(File.join(dir, 'std.out'))
129
+ if File.exist?(File.join(dir, 'std.out'))
130
130
  outt = File.mtime File.join(dir, 'std.out')
131
131
  errt = File.mtime File.join(dir, 'std.err')
132
132
  time_diff = Time.now - [outt, errt].max
133
133
  end
134
134
 
135
135
  fdep = File.join(dir, 'dependencies.list')
136
- deps = Open.read(fdep).split("\n") if File.exists?(fdep)
136
+ deps = Open.read(fdep).split("\n") if File.exist?(fdep)
137
137
 
138
138
  fcadep = File.join(dir, 'canfail_dependencies.list')
139
- cadeps = Open.read(fcadep).split("\n") if File.exists?(fcadep)
139
+ cadeps = Open.read(fcadep).split("\n") if File.exist?(fcadep)
140
140
 
141
141
  aborted = error = true if aborted.nil? && error.nil?
142
142
  #if done || error || aborted || running || queued || jobid || search
@@ -177,7 +177,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
177
177
  puts Log.color(:magenta, "Dependencies: ") << deps * ", " if deps
178
178
  puts Log.color(:magenta, "Dependencies (can fail): ") << cadeps * ", " if cadeps
179
179
  puts Log.color(:magenta, "Nodes: ") << nodes * ", "
180
- puts Log.color(:magenta, "Output: ") << File.exists?(File.join(dir, 'std.out')).to_s << (id.nil? ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)")
180
+ puts Log.color(:magenta, "Output: ") << File.exist?(File.join(dir, 'std.out')).to_s << (id.nil? ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)")
181
181
 
182
182
  if options[:batch_parameters]
183
183
  puts Log.color(:magenta, "BATCH parameters: ")
@@ -189,7 +189,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
189
189
  end
190
190
  end
191
191
 
192
- if tail && File.exists?(File.join(dir, 'std.err'))
192
+ if tail && File.exist?(File.join(dir, 'std.err'))
193
193
  if exit_status && exit_status != 0
194
194
  puts Log.color(:magenta, "First error or exception found: ")
195
195
  puts CMD.cmd("grep -i -w 'error\\|[a-z]*exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read
@@ -118,19 +118,19 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
118
118
  container_home = nil
119
119
  end
120
120
 
121
- if File.exists?(fid = File.join(dir, 'job.id'))
121
+ if File.exist?(fid = File.join(dir, 'job.id'))
122
122
  id = Open.read(fid).chomp
123
123
  else
124
124
  id = nil
125
125
  end
126
126
 
127
- if File.exists?(fstatus = File.join(dir, 'exit.status'))
127
+ if File.exist?(fstatus = File.join(dir, 'exit.status'))
128
128
  exit_status = Open.read(fstatus).to_i
129
129
  else
130
130
  exit_status = nil
131
131
  end
132
132
 
133
- if File.exists?(fstatus = File.join(dir, 'job.status'))
133
+ if File.exist?(fstatus = File.join(dir, 'job.status'))
134
134
  fstatus_txt = Open.read(fstatus)
135
135
  begin
136
136
  if job_batch_system == "lsf"
@@ -147,13 +147,13 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
147
147
  nodes = []
148
148
  end
149
149
 
150
- if File.exists?(File.join(dir, 'exit.status'))
150
+ if File.exist?(File.join(dir, 'exit.status'))
151
151
  now = File.ctime(File.join(dir, 'exit.status'))
152
152
  else
153
153
  now = Time.now
154
154
  end
155
155
 
156
- if File.exists?(File.join(dir, 'std.out'))
156
+ if File.exist?(File.join(dir, 'std.out'))
157
157
  cerrt = File.ctime File.join(dir, 'std.err')
158
158
  coutt = File.ctime File.join(dir, 'std.out')
159
159
  outt = File.mtime File.join(dir, 'std.out')
@@ -163,10 +163,10 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
163
163
  end
164
164
 
165
165
  fdep = File.join(dir, 'dependencies.list')
166
- deps = Open.read(fdep).split("\n") if File.exists?(fdep)
166
+ deps = Open.read(fdep).split("\n") if File.exist?(fdep)
167
167
 
168
168
  fcadep = File.join(dir, 'canfail_dependencies.list')
169
- cadeps = Open.read(fcadep).split("\n") if File.exists?(fcadep)
169
+ cadeps = Open.read(fcadep).split("\n") if File.exist?(fcadep)
170
170
 
171
171
  if done || error || aborted || running || queued || jobid
172
172
  select = false
@@ -244,7 +244,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
244
244
  puts Log.color(:magenta, "Dependencies (can fail): ") << cadeps * ", " if cadeps
245
245
  puts Log.color(:magenta, "Nodes: ") << nodes * ", " if long
246
246
  puts Log.color(:magenta, "Time elapsed: ") << Misc.format_seconds(time_elapsed) if time_elapsed
247
- puts Log.color(:magenta, "Output: ") << File.exists?(File.join(dir, 'std.out')).to_s << (id.nil? || File.exists?(File.join(dir, 'exit.status')) ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)") if long
247
+ puts Log.color(:magenta, "Output: ") << File.exist?(File.join(dir, 'std.out')).to_s << (id.nil? || File.exist?(File.join(dir, 'exit.status')) ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)") if long
248
248
 
249
249
  if options[:batch_parameters]
250
250
  puts Log.color(:magenta, "BATCH parameters: ")
@@ -316,7 +316,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
316
316
  end
317
317
 
318
318
 
319
- if tail && File.exists?(File.join(dir, 'std.err'))
319
+ if tail && File.exist?(File.join(dir, 'std.err'))
320
320
  if exit_status && exit_status != 0
321
321
  puts Log.color(:magenta, "First error or exception found: ")
322
322
  puts CMD.cmd("grep -i -w 'error\\|[a-z]*exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read
@@ -46,7 +46,7 @@ if directory =~ /^[0-9]*$/
46
46
  end
47
47
  end
48
48
 
49
- raise ParameterException, "Could not identify job #{directory}" unless File.exists?(directory)
49
+ raise ParameterException, "Could not identify job #{directory}" unless File.exist?(directory)
50
50
 
51
51
  require 'rbbt/hpc/slurm'
52
52
 
@@ -97,19 +97,19 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
97
97
 
98
98
  different_system = job_batch_system != batch_system
99
99
 
100
- if File.exists?(fid = File.join(dir, 'job.id'))
100
+ if File.exist?(fid = File.join(dir, 'job.id'))
101
101
  id = Open.read(fid).chomp
102
102
  else
103
103
  id = nil
104
104
  end
105
105
 
106
- if File.exists?(fstatus = File.join(dir, 'exit.status'))
106
+ if File.exist?(fstatus = File.join(dir, 'exit.status'))
107
107
  exit_status = Open.read(fstatus).to_i
108
108
  else
109
109
  exit_status = nil
110
110
  end
111
111
 
112
- if File.exists?(fstatus = File.join(dir, 'job.status'))
112
+ if File.exist?(fstatus = File.join(dir, 'job.status'))
113
113
  fstatus_txt = Open.read(fstatus)
114
114
  begin
115
115
  if job_batch_system == "lsf"
@@ -126,17 +126,17 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
126
126
  nodes = []
127
127
  end
128
128
 
129
- if File.exists?(File.join(dir, 'std.out'))
129
+ if File.exist?(File.join(dir, 'std.out'))
130
130
  outt = File.mtime File.join(dir, 'std.out')
131
131
  errt = File.mtime File.join(dir, 'std.err')
132
132
  time_diff = Time.now - [outt, errt].max
133
133
  end
134
134
 
135
135
  fdep = File.join(dir, 'dependencies.list')
136
- deps = Open.read(fdep).split("\n") if File.exists?(fdep)
136
+ deps = Open.read(fdep).split("\n") if File.exist?(fdep)
137
137
 
138
138
  fcadep = File.join(dir, 'canfail_dependencies.list')
139
- cadeps = Open.read(fcadep).split("\n") if File.exists?(fcadep)
139
+ cadeps = Open.read(fcadep).split("\n") if File.exist?(fcadep)
140
140
 
141
141
  aborted = error = true if aborted.nil? && error.nil?
142
142
  #if done || error || aborted || running || queued || jobid || search
@@ -177,7 +177,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
177
177
  puts Log.color(:magenta, "Dependencies: ") << deps * ", " if deps
178
178
  puts Log.color(:magenta, "Dependencies (can fail): ") << cadeps * ", " if cadeps
179
179
  puts Log.color(:magenta, "Nodes: ") << nodes * ", "
180
- puts Log.color(:magenta, "Output: ") << File.exists?(File.join(dir, 'std.out')).to_s << (id.nil? ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)")
180
+ puts Log.color(:magenta, "Output: ") << File.exist?(File.join(dir, 'std.out')).to_s << (id.nil? ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)")
181
181
 
182
182
  if options[:batch_parameters]
183
183
  puts Log.color(:magenta, "BATCH parameters: ")
@@ -189,7 +189,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
189
189
  end
190
190
  end
191
191
 
192
- if tail && File.exists?(File.join(dir, 'std.err'))
192
+ if tail && File.exist?(File.join(dir, 'std.err'))
193
193
  if exit_status && exit_status != 0
194
194
  puts Log.color(:magenta, "First error or exception found: ")
195
195
  puts CMD.cmd("grep -i -w 'error\\|[a-z]*exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read
@@ -118,19 +118,19 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
118
118
  container_home = nil
119
119
  end
120
120
 
121
- if File.exists?(fid = File.join(dir, 'job.id'))
121
+ if File.exist?(fid = File.join(dir, 'job.id'))
122
122
  id = Open.read(fid).chomp
123
123
  else
124
124
  id = nil
125
125
  end
126
126
 
127
- if File.exists?(fstatus = File.join(dir, 'exit.status'))
127
+ if File.exist?(fstatus = File.join(dir, 'exit.status'))
128
128
  exit_status = Open.read(fstatus).to_i
129
129
  else
130
130
  exit_status = nil
131
131
  end
132
132
 
133
- if File.exists?(fstatus = File.join(dir, 'job.status'))
133
+ if File.exist?(fstatus = File.join(dir, 'job.status'))
134
134
  fstatus_txt = Open.read(fstatus)
135
135
  begin
136
136
  if job_batch_system == "lsf"
@@ -147,13 +147,13 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
147
147
  nodes = []
148
148
  end
149
149
 
150
- if File.exists?(File.join(dir, 'exit.status'))
150
+ if File.exist?(File.join(dir, 'exit.status'))
151
151
  now = File.ctime(File.join(dir, 'exit.status'))
152
152
  else
153
153
  now = Time.now
154
154
  end
155
155
 
156
- if File.exists?(File.join(dir, 'std.out'))
156
+ if File.exist?(File.join(dir, 'std.out'))
157
157
  cerrt = File.ctime File.join(dir, 'std.err')
158
158
  coutt = File.ctime File.join(dir, 'std.out')
159
159
  outt = File.mtime File.join(dir, 'std.out')
@@ -163,10 +163,10 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
163
163
  end
164
164
 
165
165
  fdep = File.join(dir, 'dependencies.list')
166
- deps = Open.read(fdep).split("\n") if File.exists?(fdep)
166
+ deps = Open.read(fdep).split("\n") if File.exist?(fdep)
167
167
 
168
168
  fcadep = File.join(dir, 'canfail_dependencies.list')
169
- cadeps = Open.read(fcadep).split("\n") if File.exists?(fcadep)
169
+ cadeps = Open.read(fcadep).split("\n") if File.exist?(fcadep)
170
170
 
171
171
  if done || error || aborted || running || queued || jobid
172
172
  select = false
@@ -244,7 +244,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
244
244
  puts Log.color(:magenta, "Dependencies (can fail): ") << cadeps * ", " if cadeps
245
245
  puts Log.color(:magenta, "Nodes: ") << nodes * ", " if long
246
246
  puts Log.color(:magenta, "Time elapsed: ") << Misc.format_seconds(time_elapsed) if time_elapsed
247
- puts Log.color(:magenta, "Output: ") << File.exists?(File.join(dir, 'std.out')).to_s << (id.nil? || File.exists?(File.join(dir, 'exit.status')) ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)") if long
247
+ puts Log.color(:magenta, "Output: ") << File.exist?(File.join(dir, 'std.out')).to_s << (id.nil? || File.exist?(File.join(dir, 'exit.status')) ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)") if long
248
248
 
249
249
  if options[:batch_parameters]
250
250
  puts Log.color(:magenta, "BATCH parameters: ")
@@ -316,7 +316,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
316
316
  end
317
317
 
318
318
 
319
- if tail && File.exists?(File.join(dir, 'std.err'))
319
+ if tail && File.exist?(File.join(dir, 'std.err'))
320
320
  if exit_status && exit_status != 0
321
321
  puts Log.color(:magenta, "First error or exception found: ")
322
322
  puts CMD.cmd("grep -i -w 'error\\|[a-z]*exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read
@@ -46,7 +46,7 @@ if directory =~ /^[0-9]*$/
46
46
  end
47
47
  end
48
48
 
49
- raise ParameterException, "Could not identify job #{directory}" unless File.exists?(directory)
49
+ raise ParameterException, "Could not identify job #{directory}" unless File.exist?(directory)
50
50
 
51
51
  require 'rbbt/hpc/slurm'
52
52
 
@@ -97,19 +97,19 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
97
97
 
98
98
  different_system = job_batch_system != batch_system
99
99
 
100
- if File.exists?(fid = File.join(dir, 'job.id'))
100
+ if File.exist?(fid = File.join(dir, 'job.id'))
101
101
  id = Open.read(fid).chomp
102
102
  else
103
103
  id = nil
104
104
  end
105
105
 
106
- if File.exists?(fstatus = File.join(dir, 'exit.status'))
106
+ if File.exist?(fstatus = File.join(dir, 'exit.status'))
107
107
  exit_status = Open.read(fstatus).to_i
108
108
  else
109
109
  exit_status = nil
110
110
  end
111
111
 
112
- if File.exists?(fstatus = File.join(dir, 'job.status'))
112
+ if File.exist?(fstatus = File.join(dir, 'job.status'))
113
113
  fstatus_txt = Open.read(fstatus)
114
114
  begin
115
115
  if job_batch_system == "lsf"
@@ -126,17 +126,17 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
126
126
  nodes = []
127
127
  end
128
128
 
129
- if File.exists?(File.join(dir, 'std.out'))
129
+ if File.exist?(File.join(dir, 'std.out'))
130
130
  outt = File.mtime File.join(dir, 'std.out')
131
131
  errt = File.mtime File.join(dir, 'std.err')
132
132
  time_diff = Time.now - [outt, errt].max
133
133
  end
134
134
 
135
135
  fdep = File.join(dir, 'dependencies.list')
136
- deps = Open.read(fdep).split("\n") if File.exists?(fdep)
136
+ deps = Open.read(fdep).split("\n") if File.exist?(fdep)
137
137
 
138
138
  fcadep = File.join(dir, 'canfail_dependencies.list')
139
- cadeps = Open.read(fcadep).split("\n") if File.exists?(fcadep)
139
+ cadeps = Open.read(fcadep).split("\n") if File.exist?(fcadep)
140
140
 
141
141
  aborted = error = true if aborted.nil? && error.nil?
142
142
  #if done || error || aborted || running || queued || jobid || search
@@ -177,7 +177,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
177
177
  puts Log.color(:magenta, "Dependencies: ") << deps * ", " if deps
178
178
  puts Log.color(:magenta, "Dependencies (can fail): ") << cadeps * ", " if cadeps
179
179
  puts Log.color(:magenta, "Nodes: ") << nodes * ", "
180
- puts Log.color(:magenta, "Output: ") << File.exists?(File.join(dir, 'std.out')).to_s << (id.nil? ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)")
180
+ puts Log.color(:magenta, "Output: ") << File.exist?(File.join(dir, 'std.out')).to_s << (id.nil? ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)")
181
181
 
182
182
  if options[:batch_parameters]
183
183
  puts Log.color(:magenta, "BATCH parameters: ")
@@ -189,7 +189,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
189
189
  end
190
190
  end
191
191
 
192
- if tail && File.exists?(File.join(dir, 'std.err'))
192
+ if tail && File.exist?(File.join(dir, 'std.err'))
193
193
  if exit_status && exit_status != 0
194
194
  puts Log.color(:magenta, "First error or exception found: ")
195
195
  puts CMD.cmd("grep -i -w 'error\\|[a-z]*exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read
@@ -118,19 +118,19 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
118
118
  container_home = nil
119
119
  end
120
120
 
121
- if File.exists?(fid = File.join(dir, 'job.id'))
121
+ if File.exist?(fid = File.join(dir, 'job.id'))
122
122
  id = Open.read(fid).chomp
123
123
  else
124
124
  id = nil
125
125
  end
126
126
 
127
- if File.exists?(fstatus = File.join(dir, 'exit.status'))
127
+ if File.exist?(fstatus = File.join(dir, 'exit.status'))
128
128
  exit_status = Open.read(fstatus).to_i
129
129
  else
130
130
  exit_status = nil
131
131
  end
132
132
 
133
- if File.exists?(fstatus = File.join(dir, 'job.status'))
133
+ if File.exist?(fstatus = File.join(dir, 'job.status'))
134
134
  fstatus_txt = Open.read(fstatus)
135
135
  begin
136
136
  if job_batch_system == "lsf"
@@ -147,13 +147,13 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
147
147
  nodes = []
148
148
  end
149
149
 
150
- if File.exists?(File.join(dir, 'exit.status'))
150
+ if File.exist?(File.join(dir, 'exit.status'))
151
151
  now = File.ctime(File.join(dir, 'exit.status'))
152
152
  else
153
153
  now = Time.now
154
154
  end
155
155
 
156
- if File.exists?(File.join(dir, 'std.out'))
156
+ if File.exist?(File.join(dir, 'std.out'))
157
157
  cerrt = File.ctime File.join(dir, 'std.err')
158
158
  coutt = File.ctime File.join(dir, 'std.out')
159
159
  outt = File.mtime File.join(dir, 'std.out')
@@ -163,10 +163,10 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
163
163
  end
164
164
 
165
165
  fdep = File.join(dir, 'dependencies.list')
166
- deps = Open.read(fdep).split("\n") if File.exists?(fdep)
166
+ deps = Open.read(fdep).split("\n") if File.exist?(fdep)
167
167
 
168
168
  fcadep = File.join(dir, 'canfail_dependencies.list')
169
- cadeps = Open.read(fcadep).split("\n") if File.exists?(fcadep)
169
+ cadeps = Open.read(fcadep).split("\n") if File.exist?(fcadep)
170
170
 
171
171
  if done || error || aborted || running || queued || jobid
172
172
  select = false
@@ -244,7 +244,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
244
244
  puts Log.color(:magenta, "Dependencies (can fail): ") << cadeps * ", " if cadeps
245
245
  puts Log.color(:magenta, "Nodes: ") << nodes * ", " if long
246
246
  puts Log.color(:magenta, "Time elapsed: ") << Misc.format_seconds(time_elapsed) if time_elapsed
247
- puts Log.color(:magenta, "Output: ") << File.exists?(File.join(dir, 'std.out')).to_s << (id.nil? || File.exists?(File.join(dir, 'exit.status')) ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)") if long
247
+ puts Log.color(:magenta, "Output: ") << File.exist?(File.join(dir, 'std.out')).to_s << (id.nil? || File.exist?(File.join(dir, 'exit.status')) ? "" : " (last update " + Misc.format_seconds(time_diff) + " ago)") if long
248
248
 
249
249
  if options[:batch_parameters]
250
250
  puts Log.color(:magenta, "BATCH parameters: ")
@@ -316,7 +316,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
316
316
  end
317
317
 
318
318
 
319
- if tail && File.exists?(File.join(dir, 'std.err'))
319
+ if tail && File.exist?(File.join(dir, 'std.err'))
320
320
  if exit_status && exit_status != 0
321
321
  puts Log.color(:magenta, "First error or exception found: ")
322
322
  puts CMD.cmd("grep -i -w 'error\\|[a-z]*exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read
@@ -46,7 +46,7 @@ if directory =~ /^[0-9]*$/
46
46
  end
47
47
  end
48
48
 
49
- raise ParameterException, "Could not identify job #{directory}" unless File.exists?(directory)
49
+ raise ParameterException, "Could not identify job #{directory}" unless File.exist?(directory)
50
50
 
51
51
  require 'rbbt/hpc/slurm'
52
52
 
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rbbt-util'
4
+ require 'rbbt/util/simpleopt'
5
+
6
+ $0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands
7
+
8
+ options = SOPT.setup <<EOF
9
+ Select entries in a tsv based on some criteria
10
+
11
+ $ rbbt tsv subset [options] file.tsv <key> <criteria>
12
+
13
+ Subsets entries from a TSV file from a given list. Works with Tokyocabinet HDB and BDB as well.
14
+
15
+ -tch--tokyocabinet File is a TC HDB
16
+ -tcb--tokyocabinet_bd File is a TC BDB
17
+ -hh--header_hash* Change the character used to mark the header line (defaults to #)
18
+ -s--subset* Subset of keys (Comma-separated or file)
19
+ -m--merge Merge TSV rows
20
+ -h--help Help
21
+ EOF
22
+
23
+ SOPT.usage if options[:help]
24
+
25
+ file, key, criteria = ARGV
26
+
27
+ key, criteria, file = [file, key, nil] if criteria.nil?
28
+
29
+ file = STDIN if file == '-' || file.nil?
30
+
31
+ raise ParameterException, "Please specify the tsv file as argument" if file.nil?
32
+
33
+ options[:fields] = options[:fields].split(/,\|/) if options[:fields]
34
+ options[:header_hash] = options["header_hash"]
35
+
36
+ case
37
+ when options[:tokyocabinet]
38
+ tsv = Persist.open_tokyocabinet(file, false)
39
+ puts tsv.summary
40
+ when options[:tokyocabinet_bd]
41
+ tsv = Persist.open_tokyocabinet(file, false, nil, TokyoCabinet::BDB)
42
+ puts tsv.summary
43
+ else
44
+ tsv = TSV.open(file, options)
45
+ end
46
+
47
+ criteria = criteria.to_regexp.to_regexp if criteria =~ /\/.*\/.*/
48
+ puts tsv.select(key => criteria)
@@ -28,7 +28,7 @@ end
28
28
 
29
29
  file = ARGV.shift
30
30
 
31
- file = STDIN if file == '-'
31
+ file = STDIN if file == '-' || file.nil?
32
32
 
33
33
  case
34
34
  when options[:tokyocabinet]
@@ -38,12 +38,12 @@ when options[:tokyocabinet_bd]
38
38
  else
39
39
  if String === file
40
40
  file = file.dup
41
- Path.setup(File.expand_path(file))
41
+ file = Path.setup(File.expand_path(file))
42
42
  end
43
43
  tsv = file
44
44
  end
45
45
 
46
- tsv = TSV.open(tsv) if IO === tsv
46
+ tsv = TSV.open(tsv) if IO === tsv || Path === tsv
47
47
 
48
48
 
49
49
  begin
@@ -28,5 +28,5 @@ SOPT.usage if options[:help]
28
28
 
29
29
  target, *files = ARGV
30
30
 
31
- raise "Target already exists: #{ target }" if File.exists?(target) and not File.directory?(target)
31
+ raise "Target already exists: #{ target }" if File.exist?(target) and not File.directory?(target)
32
32
  Step.archive(files, target)
@@ -36,14 +36,14 @@ file = ARGV.shift
36
36
 
37
37
  $seen = []
38
38
  def get_step(file)
39
- file = File.expand_path(file) if File.exists?(file)
39
+ file = File.expand_path(file) if File.exist?(file)
40
40
  file = file.sub(/\.(info|files)$/,'')
41
41
  $seen << file
42
42
  Workflow.load_step file
43
43
  end
44
44
 
45
45
  def touch(step)
46
- return unless File.exists?(step.path)
46
+ return unless File.exist?(step.path)
47
47
  step.dependencies.each do |dep|
48
48
  next unless Open.exists?(dep.path)
49
49
  if Open.mtime(dep.path) > Open.mtime(step.path) + 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.34.7
4
+ version: 5.34.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-26 00:00:00.000000000 Z
11
+ date: 2022-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -452,6 +452,7 @@ files:
452
452
  - share/rbbt_commands/tsv/query
453
453
  - share/rbbt_commands/tsv/read
454
454
  - share/rbbt_commands/tsv/read_excel
455
+ - share/rbbt_commands/tsv/select
455
456
  - share/rbbt_commands/tsv/slice
456
457
  - share/rbbt_commands/tsv/sort
457
458
  - share/rbbt_commands/tsv/subset