rbbt-util 5.44.1 → 6.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rbbt +67 -90
  3. data/etc/app.d/base.rb +2 -2
  4. data/etc/app.d/semaphores.rb +3 -3
  5. data/lib/rbbt/annotations/annotated_array.rb +207 -207
  6. data/lib/rbbt/annotations/refactor.rb +27 -0
  7. data/lib/rbbt/annotations/util.rb +282 -282
  8. data/lib/rbbt/annotations.rb +343 -320
  9. data/lib/rbbt/association/database.rb +200 -225
  10. data/lib/rbbt/association/index.rb +294 -291
  11. data/lib/rbbt/association/item.rb +227 -227
  12. data/lib/rbbt/association/open.rb +35 -34
  13. data/lib/rbbt/association/util.rb +0 -169
  14. data/lib/rbbt/association.rb +2 -4
  15. data/lib/rbbt/entity/identifiers.rb +119 -118
  16. data/lib/rbbt/entity/refactor.rb +12 -0
  17. data/lib/rbbt/entity.rb +319 -315
  18. data/lib/rbbt/hpc/batch.rb +72 -53
  19. data/lib/rbbt/hpc/lsf.rb +2 -2
  20. data/lib/rbbt/hpc/orchestrate/batches.rb +2 -2
  21. data/lib/rbbt/hpc/orchestrate/chains.rb +25 -5
  22. data/lib/rbbt/hpc/orchestrate/rules.rb +2 -2
  23. data/lib/rbbt/hpc/orchestrate.rb +19 -13
  24. data/lib/rbbt/hpc/slurm.rb +18 -18
  25. data/lib/rbbt/knowledge_base/entity.rb +13 -5
  26. data/lib/rbbt/knowledge_base/query.rb +2 -2
  27. data/lib/rbbt/knowledge_base/registry.rb +32 -31
  28. data/lib/rbbt/knowledge_base/traverse.rb +1 -1
  29. data/lib/rbbt/knowledge_base.rb +1 -1
  30. data/lib/rbbt/monitor.rb +36 -25
  31. data/lib/rbbt/persist/refactor.rb +166 -0
  32. data/lib/rbbt/persist/tsv/tokyocabinet.rb +105 -105
  33. data/lib/rbbt/persist/tsv.rb +187 -185
  34. data/lib/rbbt/persist.rb +556 -551
  35. data/lib/rbbt/refactor.rb +20 -0
  36. data/lib/rbbt/resource/path/refactor.rb +178 -0
  37. data/lib/rbbt/resource/path.rb +317 -497
  38. data/lib/rbbt/resource/util.rb +0 -48
  39. data/lib/rbbt/resource.rb +3 -390
  40. data/lib/rbbt/tsv/accessor.rb +2 -838
  41. data/lib/rbbt/tsv/attach.rb +303 -299
  42. data/lib/rbbt/tsv/change_id.rb +244 -245
  43. data/lib/rbbt/tsv/csv.rb +87 -85
  44. data/lib/rbbt/tsv/dumper.rb +2 -100
  45. data/lib/rbbt/tsv/excel.rb +26 -24
  46. data/lib/rbbt/tsv/field_index.rb +4 -1
  47. data/lib/rbbt/tsv/filter.rb +3 -2
  48. data/lib/rbbt/tsv/index.rb +2 -284
  49. data/lib/rbbt/tsv/manipulate.rb +750 -747
  50. data/lib/rbbt/tsv/marshal.rb +3 -3
  51. data/lib/rbbt/tsv/matrix.rb +2 -2
  52. data/lib/rbbt/tsv/parallel/through.rb +2 -1
  53. data/lib/rbbt/tsv/parallel/traverse.rb +783 -781
  54. data/lib/rbbt/tsv/parser.rb +678 -678
  55. data/lib/rbbt/tsv/refactor.rb +195 -0
  56. data/lib/rbbt/tsv/stream.rb +253 -251
  57. data/lib/rbbt/tsv/util.rb +420 -420
  58. data/lib/rbbt/tsv.rb +210 -208
  59. data/lib/rbbt/util/R/eval.rb +4 -4
  60. data/lib/rbbt/util/R/plot.rb +62 -166
  61. data/lib/rbbt/util/R.rb +21 -18
  62. data/lib/rbbt/util/cmd.rb +2 -318
  63. data/lib/rbbt/util/color.rb +269 -269
  64. data/lib/rbbt/util/colorize.rb +89 -89
  65. data/lib/rbbt/util/concurrency/processes/refactor.rb +22 -0
  66. data/lib/rbbt/util/concurrency/processes/worker.rb +2 -2
  67. data/lib/rbbt/util/concurrency/processes.rb +389 -386
  68. data/lib/rbbt/util/config.rb +169 -167
  69. data/lib/rbbt/util/iruby.rb +20 -0
  70. data/lib/rbbt/util/log/progress/report.rb +241 -241
  71. data/lib/rbbt/util/log/progress/util.rb +99 -99
  72. data/lib/rbbt/util/log/progress.rb +102 -102
  73. data/lib/rbbt/util/log/refactor.rb +49 -0
  74. data/lib/rbbt/util/log.rb +486 -532
  75. data/lib/rbbt/util/migrate.rb +1 -1
  76. data/lib/rbbt/util/misc/concurrent_stream.rb +248 -246
  77. data/lib/rbbt/util/misc/development.rb +12 -11
  78. data/lib/rbbt/util/misc/exceptions.rb +117 -112
  79. data/lib/rbbt/util/misc/format.rb +2 -230
  80. data/lib/rbbt/util/misc/indiferent_hash.rb +2 -107
  81. data/lib/rbbt/util/misc/inspect.rb +2 -476
  82. data/lib/rbbt/util/misc/lock.rb +109 -106
  83. data/lib/rbbt/util/misc/omics.rb +9 -1
  84. data/lib/rbbt/util/misc/pipes.rb +765 -793
  85. data/lib/rbbt/util/misc/refactor.rb +20 -0
  86. data/lib/rbbt/util/misc/ssw.rb +27 -17
  87. data/lib/rbbt/util/misc/system.rb +0 -15
  88. data/lib/rbbt/util/misc.rb +39 -20
  89. data/lib/rbbt/util/named_array/refactor.rb +4 -0
  90. data/lib/rbbt/util/named_array.rb +3 -220
  91. data/lib/rbbt/util/open/refactor.rb +7 -0
  92. data/lib/rbbt/util/open.rb +3 -857
  93. data/lib/rbbt/util/procpath.rb +6 -6
  94. data/lib/rbbt/util/python/paths.rb +27 -0
  95. data/lib/rbbt/util/python/run.rb +115 -0
  96. data/lib/rbbt/util/python/script.rb +110 -0
  97. data/lib/rbbt/util/python/util.rb +3 -3
  98. data/lib/rbbt/util/python.rb +22 -81
  99. data/lib/rbbt/util/semaphore.rb +152 -148
  100. data/lib/rbbt/util/simpleopt.rb +9 -8
  101. data/lib/rbbt/util/ssh/refactor.rb +19 -0
  102. data/lib/rbbt/util/ssh.rb +122 -118
  103. data/lib/rbbt/util/tar.rb +117 -115
  104. data/lib/rbbt/util/tmpfile.rb +69 -67
  105. data/lib/rbbt/util/version.rb +2 -0
  106. data/lib/rbbt/workflow/refactor/entity.rb +11 -0
  107. data/lib/rbbt/workflow/refactor/export.rb +66 -0
  108. data/lib/rbbt/workflow/refactor/inputs.rb +24 -0
  109. data/lib/rbbt/workflow/refactor/recursive.rb +64 -0
  110. data/lib/rbbt/workflow/refactor/task_info.rb +65 -0
  111. data/lib/rbbt/workflow/refactor.rb +153 -0
  112. data/lib/rbbt/workflow/remote_workflow/driver/ssh.rb +55 -32
  113. data/lib/rbbt/workflow/remote_workflow/remote_step/rest.rb +3 -1
  114. data/lib/rbbt/workflow/remote_workflow/remote_step/ssh.rb +14 -5
  115. data/lib/rbbt/workflow/remote_workflow/remote_step.rb +19 -7
  116. data/lib/rbbt/workflow/remote_workflow.rb +6 -1
  117. data/lib/rbbt/workflow/step/run.rb +766 -766
  118. data/lib/rbbt/workflow/step/save_load_inputs.rb +254 -254
  119. data/lib/rbbt/workflow/step.rb +2 -362
  120. data/lib/rbbt/workflow/task.rb +118 -118
  121. data/lib/rbbt/workflow/usage.rb +289 -287
  122. data/lib/rbbt/workflow/util/archive.rb +6 -5
  123. data/lib/rbbt/workflow/util/data.rb +1 -1
  124. data/lib/rbbt/workflow/util/orchestrator.rb +249 -246
  125. data/lib/rbbt/workflow/util/trace.rb +79 -44
  126. data/lib/rbbt/workflow.rb +4 -882
  127. data/lib/rbbt-util.rb +21 -13
  128. data/lib/rbbt.rb +16 -3
  129. data/python/rbbt/__init__.py +19 -1
  130. data/share/Rlib/plot.R +37 -37
  131. data/share/Rlib/svg.R +22 -5
  132. data/share/install/software/lib/install_helpers +1 -1
  133. data/share/rbbt_commands/hpc/list +2 -3
  134. data/share/rbbt_commands/hpc/orchestrate +4 -4
  135. data/share/rbbt_commands/hpc/tail +2 -0
  136. data/share/rbbt_commands/hpc/task +10 -7
  137. data/share/rbbt_commands/lsf/list +2 -3
  138. data/share/rbbt_commands/lsf/orchestrate +4 -4
  139. data/share/rbbt_commands/lsf/tail +2 -0
  140. data/share/rbbt_commands/lsf/task +10 -7
  141. data/share/rbbt_commands/migrate +1 -1
  142. data/share/rbbt_commands/pbs/list +2 -3
  143. data/share/rbbt_commands/pbs/orchestrate +4 -4
  144. data/share/rbbt_commands/pbs/tail +2 -0
  145. data/share/rbbt_commands/pbs/task +10 -7
  146. data/share/rbbt_commands/resource/produce +8 -1
  147. data/share/rbbt_commands/slurm/list +2 -3
  148. data/share/rbbt_commands/slurm/orchestrate +4 -4
  149. data/share/rbbt_commands/slurm/tail +2 -0
  150. data/share/rbbt_commands/slurm/task +10 -7
  151. data/share/rbbt_commands/system/clean +5 -5
  152. data/share/rbbt_commands/system/status +5 -5
  153. data/share/rbbt_commands/tsv/get +2 -3
  154. data/share/rbbt_commands/tsv/info +10 -13
  155. data/share/rbbt_commands/tsv/keys +18 -14
  156. data/share/rbbt_commands/tsv/slice +2 -2
  157. data/share/rbbt_commands/tsv/transpose +6 -2
  158. data/share/rbbt_commands/workflow/info +20 -24
  159. data/share/rbbt_commands/workflow/list +1 -1
  160. data/share/rbbt_commands/workflow/prov +20 -13
  161. data/share/rbbt_commands/workflow/server +11 -1
  162. data/share/rbbt_commands/workflow/task +76 -71
  163. data/share/rbbt_commands/workflow/write_info +26 -9
  164. data/share/software/opt/ssw/ssw.c +861 -0
  165. data/share/software/opt/ssw/ssw.h +130 -0
  166. data/share/workflow_config.ru +3 -3
  167. metadata +40 -2
data/lib/rbbt/tsv.rb CHANGED
@@ -1,208 +1,210 @@
1
- require 'rbbt/persist'
2
- require 'rbbt/persist/tsv'
3
-
4
- require 'rbbt/util/log'
5
- require 'rbbt/util/misc'
6
- require 'rbbt/util/named_array'
7
-
8
- require 'rbbt/tsv/util'
9
- require 'rbbt/tsv/serializers'
10
- require 'rbbt/tsv/parser'
11
- require 'rbbt/tsv/accessor'
12
- require 'rbbt/tsv/manipulate'
13
- require 'rbbt/tsv/index'
14
- require 'rbbt/tsv/attach'
15
- require 'rbbt/tsv/filter'
16
- require 'rbbt/tsv/field_index'
17
- require 'rbbt/tsv/parallel'
18
- require 'rbbt/tsv/stream'
19
- require 'rbbt/tsv/melt'
20
- require 'rbbt/tsv/matrix'
21
- require 'rbbt/tsv/marshal'
22
-
23
- module TSV
24
- class << self
25
- attr_accessor :lock_dir, :unnamed
26
-
27
- def lock_dir
28
- @lock_dir ||= Rbbt.tmp.tsv_open_locks.find
29
- end
30
- end
31
-
32
- def self.str2options(str)
33
- field_options,_sep, rest = str.partition("#")
34
- key, fields_str = field_options.split("~")
35
-
36
- fields = fields_str.nil? ? [] : fields_str.split(/,\s*/)
37
-
38
- rest = ":type=" << rest if rest =~ /^:?\w+$/
39
- rest_options = rest.nil? ? {} : Misc.string2hash(rest)
40
-
41
- {:key_field => key, :fields => fields}.merge(rest_options)
42
- end
43
-
44
- def self.setup(hash, type = nil, options = nil)
45
- type, options = nil, type if options.nil? and (Hash === type or (String === type and type.include? "~"))
46
- options = TSV.str2options(options) if String === options and options.include? "~"
47
- options ||= {}
48
- options[:type] ||= type unless type.nil?
49
-
50
- options = Misc.add_defaults options, :default_value => [], :unnamed => TSV.unnamed
51
- default_value = Misc.process_options options, :default_value
52
- hash = Misc.array2hash(hash, default_value) if Array === hash
53
- hash.extend TSV
54
-
55
- IndiferentHash.setup(options)
56
- ENTRIES.each do |entry|
57
- hash.send("#{ entry }=", options[entry.to_s]) if options.include? entry.to_s
58
- hash.send("#{ entry }=", options[entry.to_sym]) if options.include? entry.to_sym
59
- end
60
-
61
- hash.unnamed = options[:unnamed]
62
-
63
- hash
64
- end
65
-
66
- # options shift if type.nil?
67
- def self.open(source, type = nil, options = nil)
68
- type, options = nil, type if options.nil? and (Hash === type or (String === type and type.include? "~"))
69
- options = TSV.str2options(options) if String === options and options.include? "~"
70
- options ||= {}
71
- options[:type] ||= type unless type.nil?
72
- options[:zipped] = true if options[:one2one]
73
-
74
- persist_options = Misc.pull_keys options, :persist
75
-
76
- raise "TSV source is nil" if source.nil?
77
-
78
- filename = get_filename source
79
- serializer = Misc.process_options options, :serializer
80
- unnamed = Misc.process_options options, :unnamed
81
- entity_options = Misc.process_options options, :entity_options
82
-
83
-
84
- Log.debug "TSV open: #{ filename } - #{Misc.fingerprint options }.#{unnamed ? " [unnamed]" : "[not unnamed]"}"
85
-
86
- data = nil
87
-
88
- lock_filename = filename.nil? ? nil : Persist.persistence_path(filename + '.open', {:dir => TSV.lock_dir})
89
- Misc.lock lock_filename do
90
- data = Persist.persist_tsv source, filename, options, persist_options do |data|
91
- if serializer
92
- data.extend TSV unless TSV === data
93
- data.serializer = serializer
94
- end
95
-
96
- tsv_grep = Misc.process_options options, :tsv_grep
97
- tsv_grep ||= Misc.process_options options, :grep
98
- open_options = Misc.pull_keys options, :open
99
-
100
- stream = get_stream source, options.merge(open_options)
101
- parse stream, data, options.merge(:tsv_grep => tsv_grep)
102
-
103
- if ! open_options[:noclose]
104
- stream.close unless stream.closed?
105
- stream.join if stream.respond_to?(:join)
106
- end
107
-
108
- data.filename = filename.to_s unless filename.nil?
109
-
110
- if data.identifiers.nil? and Path === filename and filename.identifier_file_path
111
- data.identifiers = filename.identifier_file_path.find if filename.identifier_file_path.exists?
112
- end
113
-
114
- data
115
- end
116
- end
117
-
118
-
119
- data.unnamed = unnamed unless unnamed.nil?
120
-
121
- data.entity_options = entity_options
122
-
123
- if Path === source && data.identifiers
124
- Path.setup(data.identifiers, source.pkgdir, source.resource)
125
- end
126
-
127
- if data.respond_to? :persistence_path
128
- data.read
129
- data
130
- else
131
- h = data.dup
132
- data.clear
133
- data.annotate h
134
- end
135
- end
136
-
137
- def self.parse_header(stream, options = {})
138
- case
139
- when Path === stream
140
- stream.open do |f|
141
- f.no_fail = true if ConcurrentStream === f
142
- Parser.new f, options
143
- end
144
- when (String === stream and stream.length < 300 and (Open.exists? stream or Open.remote? stream))
145
- Open.open(stream) do |f|
146
- f.no_fail = true if ConcurrentStream === f
147
- Parser.new f, options
148
- end
149
- else
150
- filename = stream.respond_to?(:filename) ? stream.filename : Misc.fingerprint(stream)
151
- Log.debug("Parsing header of open stream: #{filename}")
152
- Parser.new stream, options
153
- end
154
- end
155
-
156
- def self.parse(stream, data, options = {})
157
-
158
- parser = Misc.process_options options, :parser
159
- parser = TSV::Parser.new stream, options if parser.nil?
160
-
161
- # dump with tchmgr
162
- if defined? TokyoCabinet and TokyoCabinet::HDB === data and parser.straight and
163
- data.close
164
- begin
165
- bin = 'tchmgr'
166
- CMD.cmd("#{bin} version", :log => false)
167
- FileUtils.mkdir_p File.dirname(data.persistence_path)
168
- CMD.cmd("#{bin} importtsv '#{data.persistence_path}'", :in => stream, :log => false, :dont_close_in => true)
169
- rescue
170
- Log.debug("tchmgr importtsv failed for: #{data.persistence_path}")
171
- end
172
- data.write
173
- end
174
-
175
- # make TSV
176
- data.extend TSV unless TSV === data
177
- data.unnamed = true
178
-
179
- # choose serializer
180
- if data.serializer == :type
181
- data.serializer = case
182
- when parser.cast.nil?
183
- data.serializer = parser.type
184
- when (parser.cast == :to_i and (parser.type == :list or parser.type == :flat))
185
- data.serializer = :integer_array
186
- when (parser.cast == :to_i and parser.type == :single)
187
- data.serializer = :integer
188
- when (parser.cast == :to_f and parser.type == :single)
189
- data.serializer = :float
190
- when (parser.cast == :to_f and (parser.type == :list or parser.type == :flat))
191
- data.serializer = :float_array
192
- else
193
- data.serializer = :marshal
194
- end
195
- end
196
-
197
- parser.traverse(options) do |key,values|
198
- parser.add_to_data data, key, values
199
- end
200
-
201
- # setup the TSV
202
- parser.setup data
203
-
204
- data.unnamed = false
205
-
206
- data
207
- end
208
- end
1
+ require_relative 'refactor'
2
+ Rbbt.require_instead 'scout/tsv'
3
+ require_relative 'tsv/refactor'
4
+ #require 'rbbt/persist'
5
+ #require 'rbbt/persist/tsv'
6
+ #
7
+ #require 'rbbt/util/log'
8
+ #require 'rbbt/util/misc'
9
+ #require 'rbbt/util/named_array'
10
+ #
11
+ #require 'rbbt/tsv/util'
12
+ #require 'rbbt/tsv/serializers'
13
+ #require 'rbbt/tsv/parser'
14
+ #require 'rbbt/tsv/accessor'
15
+ #require 'rbbt/tsv/manipulate'
16
+ #require 'rbbt/tsv/index'
17
+ #require 'rbbt/tsv/attach'
18
+ #require 'rbbt/tsv/filter'
19
+ #require 'rbbt/tsv/field_index'
20
+ #require 'rbbt/tsv/parallel'
21
+ #require 'rbbt/tsv/stream'
22
+ #require 'rbbt/tsv/melt'
23
+ #require 'rbbt/tsv/matrix'
24
+ #require 'rbbt/tsv/marshal'
25
+ #
26
+ #module TSV
27
+ # class << self
28
+ # attr_accessor :lock_dir, :unnamed
29
+ #
30
+ # def lock_dir
31
+ # @lock_dir ||= Rbbt.tmp.tsv_open_locks.find
32
+ # end
33
+ # end
34
+ #
35
+ # def self.str2options(str)
36
+ # field_options,_sep, rest = str.partition("#")
37
+ # key, fields_str = field_options.split("~")
38
+ #
39
+ # fields = fields_str.nil? ? [] : fields_str.split(/,\s*/)
40
+ #
41
+ # rest = ":type=" << rest if rest =~ /^:?\w+$/
42
+ # rest_options = rest.nil? ? {} : Misc.string2hash(rest)
43
+ #
44
+ # {:key_field => key, :fields => fields}.merge(rest_options)
45
+ # end
46
+ #
47
+ # def self.setup(hash, type = nil, options = nil)
48
+ # type, options = nil, type if options.nil? and (Hash === type or (String === type and type.include? "~"))
49
+ # options = TSV.str2options(options) if String === options and options.include? "~"
50
+ # options ||= {}
51
+ # options[:type] ||= type unless type.nil?
52
+ #
53
+ # options = Misc.add_defaults options, :default_value => [], :unnamed => TSV.unnamed
54
+ # default_value = Misc.process_options options, :default_value
55
+ # hash = Misc.array2hash(hash, default_value) if Array === hash
56
+ # hash.extend TSV
57
+ #
58
+ # IndiferentHash.setup(options)
59
+ # ENTRIES.each do |entry|
60
+ # hash.send("#{ entry }=", options[entry.to_s]) if options.include? entry.to_s
61
+ # hash.send("#{ entry }=", options[entry.to_sym]) if options.include? entry.to_sym
62
+ # end
63
+ #
64
+ # hash.unnamed = options[:unnamed]
65
+ #
66
+ # hash
67
+ # end
68
+ #
69
+ # # options shift if type.nil?
70
+ # def self.open(source, type = nil, options = nil)
71
+ # type, options = nil, type if options.nil? and (Hash === type or (String === type and type.include? "~"))
72
+ # options = TSV.str2options(options) if String === options and options.include? "~"
73
+ # options ||= {}
74
+ # options[:type] ||= type unless type.nil?
75
+ #
76
+ # persist_options = Misc.pull_keys options, :persist
77
+ #
78
+ # raise "TSV source is nil" if source.nil?
79
+ #
80
+ # filename = get_filename source
81
+ # serializer = Misc.process_options options, :serializer
82
+ # unnamed = Misc.process_options options, :unnamed
83
+ # entity_options = Misc.process_options options, :entity_options
84
+ #
85
+ #
86
+ # Log.debug "TSV open: #{ filename } - #{Misc.fingerprint options }.#{unnamed ? " [unnamed]" : "[not unnamed]"}"
87
+ #
88
+ # data = nil
89
+ #
90
+ # lock_filename = filename.nil? ? nil : Persist.persistence_path(filename + '.open', {:dir => TSV.lock_dir})
91
+ # Misc.lock lock_filename do
92
+ # data = Persist.persist_tsv source, filename, options, persist_options do |data|
93
+ # if serializer
94
+ # data.extend TSV unless TSV === data
95
+ # data.serializer = serializer
96
+ # end
97
+ #
98
+ # tsv_grep = Misc.process_options options, :tsv_grep
99
+ # tsv_grep ||= Misc.process_options options, :grep
100
+ # open_options = Misc.pull_keys options, :open
101
+ #
102
+ # stream = get_stream source, options.merge(open_options)
103
+ # parse stream, data, options.merge(:tsv_grep => tsv_grep)
104
+ #
105
+ # if ! open_options[:noclose]
106
+ # stream.close unless stream.closed?
107
+ # stream.join if stream.respond_to?(:join)
108
+ # end
109
+ #
110
+ # data.filename = filename.to_s unless filename.nil?
111
+ #
112
+ # if data.identifiers.nil? and Path === filename and filename.identifier_file_path
113
+ # data.identifiers = filename.identifier_file_path.find if filename.identifier_file_path.exists?
114
+ # end
115
+ #
116
+ # data
117
+ # end
118
+ # end
119
+ #
120
+ #
121
+ # data.unnamed = unnamed unless unnamed.nil?
122
+ #
123
+ # data.entity_options = entity_options
124
+ #
125
+ # if Path === source && data.identifiers
126
+ # Path.setup(data.identifiers, source.pkgdir, source.resource)
127
+ # end
128
+ #
129
+ # if data.respond_to? :persistence_path
130
+ # data.read
131
+ # data
132
+ # else
133
+ # h = data.dup
134
+ # data.clear
135
+ # data.annotate h
136
+ # end
137
+ # end
138
+ #
139
+ # def self.parse_header(stream, options = {})
140
+ # case
141
+ # when Path === stream
142
+ # stream.open do |f|
143
+ # f.no_fail = true if ConcurrentStream === f
144
+ # Parser.new f, options
145
+ # end
146
+ # when (String === stream and stream.length < 300 and (Open.exists? stream or Open.remote? stream))
147
+ # Open.open(stream) do |f|
148
+ # f.no_fail = true if ConcurrentStream === f
149
+ # Parser.new f, options
150
+ # end
151
+ # else
152
+ # filename = stream.respond_to?(:filename) ? stream.filename : Misc.fingerprint(stream)
153
+ # Log.debug("Parsing header of open stream: #{filename}")
154
+ # Parser.new stream, options
155
+ # end
156
+ # end
157
+ #
158
+ # def self.parse(stream, data, options = {})
159
+ #
160
+ # parser = Misc.process_options options, :parser
161
+ # parser = TSV::Parser.new stream, options if parser.nil?
162
+ #
163
+ # # dump with tchmgr
164
+ # if defined? TokyoCabinet and TokyoCabinet::HDB === data and parser.straight and
165
+ # data.close
166
+ # begin
167
+ # bin = 'tchmgr'
168
+ # CMD.cmd("#{bin} version", :log => false)
169
+ # FileUtils.mkdir_p File.dirname(data.persistence_path)
170
+ # CMD.cmd("#{bin} importtsv '#{data.persistence_path}'", :in => stream, :log => false, :dont_close_in => true)
171
+ # rescue
172
+ # Log.debug("tchmgr importtsv failed for: #{data.persistence_path}")
173
+ # end
174
+ # data.write
175
+ # end
176
+ #
177
+ # # make TSV
178
+ # data.extend TSV unless TSV === data
179
+ # data.unnamed = true
180
+ #
181
+ # # choose serializer
182
+ # if data.serializer == :type
183
+ # data.serializer = case
184
+ # when parser.cast.nil?
185
+ # data.serializer = parser.type
186
+ # when (parser.cast == :to_i and (parser.type == :list or parser.type == :flat))
187
+ # data.serializer = :integer_array
188
+ # when (parser.cast == :to_i and parser.type == :single)
189
+ # data.serializer = :integer
190
+ # when (parser.cast == :to_f and parser.type == :single)
191
+ # data.serializer = :float
192
+ # when (parser.cast == :to_f and (parser.type == :list or parser.type == :flat))
193
+ # data.serializer = :float_array
194
+ # else
195
+ # data.serializer = :marshal
196
+ # end
197
+ # end
198
+ #
199
+ # parser.traverse(options) do |key,values|
200
+ # parser.add_to_data data, key, values
201
+ # end
202
+ #
203
+ # # setup the TSV
204
+ # parser.setup data
205
+ #
206
+ # data.unnamed = false
207
+ #
208
+ # data
209
+ # end
210
+ #end
@@ -27,7 +27,7 @@ module R
27
27
  @@semfile
28
28
  else
29
29
  @@semfile = File.basename(socket_file) + '.sem'
30
- RbbtSemaphore.create_semaphore(@@semfile,1)
30
+ ScoutSemaphore.create_semaphore(@@semfile,1)
31
31
  @@semfile
32
32
  end
33
33
  end
@@ -42,7 +42,7 @@ module R
42
42
 
43
43
  def self.clear
44
44
  @@instance = nil
45
- if defined? @@instance_process and @@instance_process and Misc.pid_exists? @@instance_process
45
+ if defined? @@instance_process and @@instance_process and Misc.pid_alive? @@instance_process
46
46
  Log.warn "Clearing Rserver session #{SESSION}, PID #{@@instance_process}"
47
47
  begin
48
48
  Process.kill :INT, @@instance_process
@@ -59,7 +59,7 @@ module R
59
59
  def self.instance
60
60
  @@instance ||= begin
61
61
 
62
- clear if File.exist? pid_file and ! Misc.pid_exists?(Open.read(pid_file).strip.to_i)
62
+ clear if File.exist? pid_file and ! Misc.pid_alive?(Open.read(pid_file).strip.to_i)
63
63
 
64
64
  FileUtils.mkdir_p File.dirname(socket_file) unless File.directory?(File.dirname(socket_file))
65
65
  FileUtils.mkdir_p workdir unless File.directory? workdir
@@ -120,7 +120,7 @@ module R
120
120
  end
121
121
 
122
122
  def self._eval(cmd)
123
- RbbtSemaphore.synchronize(semfile) do
123
+ ScoutSemaphore.synchronize(semfile) do
124
124
  times = 1
125
125
  begin
126
126
  instance.eval(cmd)