rbbt-util 5.25.32 → 5.25.33

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: '090b2d7cbaff9c7bbfa64bf7cae5fcb70e542187'
4
- data.tar.gz: ff563a4afe38bdadbae449268576cf23ba41b011
3
+ metadata.gz: 5224ee57ce9c9356d168864d1457989ab094b579
4
+ data.tar.gz: ee950dc591700be501b2d1f84e23bae4492cea1d
5
5
  SHA512:
6
- metadata.gz: ea1e035a6b3389913f1215ef0d804d72ddb4c95320d63f9fe66bf4f596499479a324c505fea962941771808426180cc7a655c9f2c84764c315ab85987df517a1
7
- data.tar.gz: b06b23ff0dae842f397983f1a9bf6c46112814c34a6804789f4949dd18ebc3a361ca46aae7a734a6518efd8fc628da6b4f42e8d49b0eb97b6c4173ca41bec939
6
+ metadata.gz: 64f17229abeefc9faecec3519b347c069f2fd387205f59513fd5d2cf1b38d71eb8352dabefa9fc08c968cf76f0c6e544b061a8841d17ef9a7825930c7553b214
7
+ data.tar.gz: 76975c93b0151e609959817f158130d0db5e57235cc4f5a6850f3d879912b09d7a3996b6fde0da1f1435ea769ebcd921050d1a54d40c08d99118576218063e6f
@@ -91,13 +91,17 @@ module Resource
91
91
 
92
92
  if File.exist?(File.join(opt_dir, '.post_install')) and File.directory?(File.join(opt_dir, '.post_install'))
93
93
  Dir.glob(File.join(opt_dir, '.post_install','*')).each do |file|
94
- begin
95
- begin
96
- File.chmod file
97
- CMD.cmd(file)
98
- rescue
99
- Log.warn("Could not execute #{ file }")
100
- end
94
+
95
+ # Load exports
96
+ Open.read(file).split("\n").each do |line|
97
+ next unless line =~ /^\s*export\s+([^=]+)=(.*)/
98
+ var = $1.strip
99
+ value = $2.strip
100
+ value.sub!(/^['"]/,'')
101
+ value.sub!(/['"]$/,'')
102
+ value.gsub!(/\$[a-z_0-9]+/i){|var| ENV[var[1..-1]] }
103
+ Log.debug "Set variable export from .post_install: #{Misc.fingerprint [var,value]*"="}"
104
+ ENV[var] = value
101
105
  end
102
106
  end
103
107
  end
data/lib/rbbt/tsv/util.rb CHANGED
@@ -32,8 +32,9 @@ module TSV
32
32
  TmpFile.with_file(values.uniq * "\n", false) do |value_file|
33
33
  cmd = "cat '#{ path }' | sed 's/\\t/\\tHEADERNOMATCH/' | grep -w -F -f '#{ value_file }' | sed 's/HEADERNOMATCH//' |sort -u|cut -f 2 |sort|uniq -c|sed 's/^ *//;s/ /\t/'"
34
34
  begin
35
- TSV.open(CMD.cmd(cmd), :key_field => 1, :type => :single, :cast => :to_i)
35
+ TSV.open(CMD.cmd(cmd), :key_field => 1, :fields => [0], :type => :single, :cast => :to_i)
36
36
  rescue
37
+ Log.exception $!
37
38
  TSV.setup({}, :type => :single, :cast => :to_i)
38
39
  end
39
40
  end
data/lib/rbbt/tsv.rb CHANGED
@@ -29,7 +29,7 @@ module TSV
29
29
  end
30
30
 
31
31
  def self.str2options(str)
32
- field_options, rest = str.split("#")
32
+ field_options,_sep, rest = str.partition("#")
33
33
  key, fields_str = field_options.split("~")
34
34
 
35
35
  fields = fields_str.nil? ? [] : fields_str.split(/,\s*/)
@@ -364,6 +364,7 @@ module Open
364
364
  rescue
365
365
  Open.ln_s(source, target, options)
366
366
  end
367
+ nil
367
368
  end
368
369
 
369
370
  #def self.cp(source, target, options = {})
@@ -0,0 +1,22 @@
1
+ require 'rbbt-util'
2
+
3
+ require 'pycall/import'
4
+
5
+ module RbbtPython
6
+ extend PyCall::Import
7
+ def self.run(mod = nil, &block)
8
+ begin
9
+ pyimport mod unless mod.nil?
10
+ case block.arity
11
+ when 0
12
+ yield
13
+ when 1
14
+ yield self.send(mod)
15
+ else
16
+ raise "Unknown arity on block of code #{block.arity}"
17
+ end
18
+ rescue
19
+ Log.exception $!
20
+ end
21
+ end
22
+ end
data/share/Rlib/util.R CHANGED
@@ -526,7 +526,7 @@ rbbt.png_plot <- function(filename, p, width=500, height=500, ...){
526
526
  rbbt.pheatmap <- function(filename, data, width=800, height=800, take_log=FALSE, stdize=FALSE, positive=FALSE, ...){
527
527
  rbbt.require('pheatmap')
528
528
 
529
- opar = par()
529
+ #opar = par()
530
530
  png(filename=filename, width=width, height=height);
531
531
 
532
532
  data = as.matrix(data)
@@ -556,8 +556,8 @@ rbbt.pheatmap <- function(filename, data, width=800, height=800, take_log=FALSE,
556
556
  pheatmap(data, ...)
557
557
  }
558
558
 
559
+ #par(opar)
559
560
  dev.off();
560
- par(opar)
561
561
  }
562
562
 
563
563
  rbbt.heatmap <- function(filename, data, width=800, height=800, take_log=FALSE, stdize=FALSE, ...){
@@ -725,18 +725,22 @@ rbbt.plot.text_scatter <- function(formula, data) {
725
725
  }
726
726
 
727
727
  rbbt.install.CRAN <- function(pkg){
728
+ cat("Try CRAN install:", pkg, "\n")
728
729
  res = FALSE
729
- tryCatch({ install.packages(pkg); library(pkg); res = TRUE }, error = function(e){ warning(paste("Could not install CRAN ", pkg)); res = FALSE })
730
+ tryCatch({ install.packages(pkg); res = TRUE; }, error = function(e){ str(e); warning(paste("Could not install CRAN ", pkg)); res = FALSE })
731
+ cat("CRAN", res)
730
732
  return(res)
731
733
  }
732
734
 
733
735
  rbbt.install.bioc <-function(pkg){
736
+ cat("Try BIOC install:", pkg, "\n")
734
737
  res = FALSE
735
738
  tryCatch({ source("http://bioconductor.org/biocLite.R"); biocLite(pkg, ask=FALSE, suppressUpdates = TRUE); res = TRUE }, error = function(e){ warning(paste("Could not install Bioconductor ", pkg)); res = FALSE })
736
739
  return(res)
737
740
  }
738
741
 
739
742
  rbbt.install.github <- function(pkg, ...){
743
+ cat("Try GITHUB install:", pkg, "\n")
740
744
  res = FALSE
741
745
  tryCatch({ library(devtools); install_github(pkg, ...); res = TRUE }, error = function(e){ warning(paste("Could not install GITHUB ", pkg)); res = FALSE })
742
746
  return(res)
@@ -10,10 +10,38 @@ OPT_BUILD_DIR="$SOFTWARE_DIR/.build"; [ -d $OPT_BUILD_DIR ] || mkdir -p $OPT_BUI
10
10
 
11
11
  mkdir -p "$OPT_BUILD_DIR"
12
12
 
13
+ if command -v realpath > /dev/null; then
14
+ function relative_path(){
15
+ local basedir=$1
16
+ local path=$2
17
+ echo $(realpath --relative-to="$basedir" "$path")
18
+ }
19
+ else
20
+ realpath(){
21
+ OURPWD=$PWD
22
+ echo "REALPATH $@" >&2
23
+ cd "$(dirname "$1")"
24
+ LINK=$(readlink "$(basename "$1")")
25
+ while [ "$LINK" ]; do
26
+ cd "$(dirname "$LINK")"
27
+ LINK=$(readlink "$(basename "$1")")
28
+ done
29
+ REALPATH="$PWD/$(basename "$1")"
30
+ cd "$OURPWD"
31
+ echo "$REALPATH"
32
+ }
33
+
34
+ function relative_path(){
35
+ local basedir="$(realpath $1)"
36
+ local path="$(realpath "$2")"
37
+ echo ${path/$basedir\/}
38
+ }
39
+ fi
40
+
13
41
  function link(){
14
42
  local source="$1"
15
43
  local target="$2"
16
- local rel_source=$(realpath --relative-to="$(dirname $target)" "$source")
44
+ local rel_source=$(relative_path "$(dirname $target)" "$source")
17
45
 
18
46
  [ -h "$target" ] && rm "$target"
19
47
  echo ln -s "$rel_source" "$target" 1>&2
@@ -31,7 +59,7 @@ function add2file(){
31
59
  file=$1
32
60
  line=$2
33
61
 
34
- rel="$(realpath -s --relative-to="$OPT_DIR" "$line")"
62
+ local rel=$(relative_path "$OPT_DIR" "$line")
35
63
  grep "$rel" "$file" || echo "$rel" >> "$file"
36
64
  }
37
65
 
@@ -168,22 +196,15 @@ compile(){
168
196
  fi
169
197
  }
170
198
 
171
- build(){
199
+ prepare_make(){
172
200
  local name=$1; shift
173
201
  local extra="$@"
174
202
 
175
- echo "Building $name"
176
- if [ "x$extra" != "x" ]; then
177
- echo "Extra params: $extra"
178
- fi
179
-
180
203
  local old_pwd="`expand_path $(pwd)`"
181
204
  cd "`build_dir`"
182
205
 
183
206
  [ -d src -a ! -e CMakeLists.txt -a ! -e Makefile -a ! -e configure ] && cd src
184
207
 
185
- echo PWD: `pwd`
186
- ls
187
208
 
188
209
  if [ -f config/m4 ]; then
189
210
  libtoolize --force
@@ -192,7 +213,7 @@ build(){
192
213
  fi
193
214
 
194
215
  if [ -f Makefile.am -a ! -f configure ]; then
195
- autoreconf
216
+ autoreconf
196
217
  fi
197
218
 
198
219
  if [ -f aclocal.m4 ]; then
@@ -216,55 +237,117 @@ build(){
216
237
  ln -s config configure
217
238
  fi
218
239
 
219
- if [ -f CMakeLists.txt ]; then
220
- [ -d build ] || mkdir build
221
- cd build
222
- cmake -DCMAKE_INSTALL_PREFIX=/install_dir ..
240
+ cd "$old_pwd"
241
+ }
223
242
 
224
- if [ -f ../configure ]; then
225
- ../configure --prefix="$(opt_dir "$name")" $extra
226
- make -j4
227
- make install || (cd .. ; mv build "$(opt_dir "$name")")
228
- else
229
- make DESTDIR="$(opt_dir "$name")" -j4
230
- make DESTDIR="$(opt_dir "$name")" install || (cd .. ; mv build "$(opt_dir "$name")")
243
+ build_make(){
244
+ local name=$1; shift
245
+ local extra="$@"
231
246
 
232
- if [ -d "$(opt_dir "$name")/install_dir" ]; then
233
- mv "$(opt_dir "$name")/install_dir"/** "$(opt_dir "$name")"
234
- rmdir "$(opt_dir "$name")/install_dir"
235
- fi
236
- fi
247
+ local old_pwd="`expand_path $(pwd)`"
248
+ cd "`build_dir`"
249
+ echo PWD: `pwd`
250
+ ls
237
251
 
238
- setup "$name"
239
- clean_build
240
- else
241
- if [ -f configure ]; then
252
+
253
+ [ -d src -a ! -e CMakeLists.txt -a ! -e Makefile -a ! -e configure ] && cd src
254
+
255
+ echo "Building with configure $name"
256
+ if [ "x$extra" != "x" ]; then
257
+ echo "Extra params: $extra"
258
+ fi
259
+
260
+ prepare_make $name
261
+
262
+ if [ -f configure ]; then
242
263
  ./configure --prefix="$(opt_dir "$name")" $extra
243
264
  compile "$name" $extra
244
265
  [ -d "$(opt_dir "$name")" ] || move_opt "$name"
245
266
  setup "$name"
246
267
  clean_build
247
- else
268
+ else
248
269
  compile "$name" $extra
249
270
  move_opt "$name"
250
271
  setup "$name"
251
272
  clean_build
252
- fi
253
273
  fi
254
-
274
+
275
+ cd "$old_pwd"
276
+ }
277
+
278
+ buid_cmake(){
279
+ local name=$1; shift
280
+ local extra="$@"
281
+
282
+ local old_pwd="`expand_path $(pwd)`"
283
+ cd "`build_dir`"
284
+ echo PWD: `pwd`
285
+ ls
286
+
287
+
288
+ [ -d src -a ! -e CMakeLists.txt -a ! -e Makefile -a ! -e configure ] && cd src
289
+
290
+ echo "Building with cmake $name"
291
+ if [ "x$extra" != "x" ]; then
292
+ echo "Extra params: $extra"
293
+ fi
294
+
295
+ echo "Using cmake"
296
+ [ -d build ] || mkdir build
297
+
298
+ cd build
299
+ cmake -DMAKE_INSTALL_PREFIX=/ $extra ..
300
+ if [ ! -f Makefile -a -f ../configure ]; then
301
+ ../configure --prefix="$(opt_dir "$name")" $extra
302
+ make -j4
303
+ make install || (cd .. ; mv build "$(opt_dir "$name")")
304
+ else
305
+ make DESTDIR="$(opt_dir "$name")" -j4 && make DESTDIR="$(opt_dir "$name")" install
306
+ fi
307
+ cd ..
308
+
309
+ if [ ! -d "$(opt_dir "$name")" ]; then
310
+ mkdir -p "$(opt_dir "$name")"
311
+ for subd in bin lib lib64 include pkgdir; do
312
+ [ -d $subd ] && mv $subd "$(opt_dir "$name")"/$subd
313
+ done
314
+ fi
315
+
316
+ setup "$name"
317
+ clean_build
318
+
255
319
  cd "$old_pwd"
256
320
  }
257
321
 
322
+ build(){
323
+ local name=$1; shift
324
+ local extra="$@"
325
+
326
+ echo "Building $name"
327
+ if [ "x$extra" != "x" ]; then
328
+ echo "Extra params: $extra"
329
+ fi
330
+
331
+ [ -d src -a ! -e CMakeLists.txt -a ! -e Makefile -a ! -e configure ] && cd src
332
+
333
+ if [ -f CMakeLists.txt ]; then
334
+ buid_cmake "$name" $extra
335
+ else
336
+ build_make "$name" $extra
337
+ fi
338
+
339
+ }
340
+
258
341
  #{{{ SETUP
259
342
 
260
- versioned?(){
343
+ is_versioned(){
261
344
  local name="$1"
262
345
  [[ $name =~ : ]]
263
346
  }
264
347
 
265
348
  opt_dir(){
266
349
  local name="$1"
267
- if versioned? "$name"; then
350
+ if is_versioned "$name"; then
268
351
  local real_name=`echo $1 | sed 's/:.*//'`
269
352
  local version=`echo $1 | sed 's/.*://'`
270
353
  echo "$OPT_DIR/$real_name/$version"
@@ -292,7 +375,7 @@ setup(){
292
375
  local name="$1"
293
376
  local pkg_dir="`opt_dir \"$name\"`"
294
377
 
295
- if versioned? "$name"; then
378
+ if is_versioned "$name"; then
296
379
  rm -f "$(dirname $pkg_dir)/current"
297
380
  link "$pkg_dir" "$(dirname $pkg_dir)/current"
298
381
  pkg_dir="$(dirname $pkg_dir)/current"
@@ -326,14 +409,22 @@ setup(){
326
409
 
327
410
  #{{{ HELPERS
328
411
 
329
- install_src(){
412
+ prepare_src_pkg(){
330
413
  local name="$1"
331
414
  local url="$2"
332
415
  shift;shift;
333
- local extra="$@"
334
-
416
+
335
417
  get_pkg "$name" "$url"
336
418
  uncompress_pkg "$name"
419
+ }
420
+
421
+ install_src(){
422
+ local name="$1"
423
+ local url="$2"
424
+ shift;shift;
425
+ local extra="$@"
426
+
427
+ prepare_src_pkg "$name" "$url"
337
428
  build "$name" "$extra"
338
429
  }
339
430
 
@@ -342,7 +433,7 @@ install_svn(){
342
433
  local url="$2"
343
434
  shift;shift;
344
435
  local extra="$@"
345
-
436
+
346
437
  get_svn "$name" "$url"
347
438
  build "$name" $extra
348
439
  }
@@ -384,6 +475,7 @@ install_jar(){
384
475
 
385
476
  [ -d "$OPT_DIR/$name/" ] || mkdir -p "$OPT_DIR/$name/"
386
477
  wget "$url" -O "$OPT_DIR/jars/$name.jar" | wget "$url" -O "$OPT_DIR/jars/$name.jar" --no-check-certificate
478
+ link "$OPT_DIR/$name/$name.jar" "$OPT_JAR_DIR/$name.jar"
387
479
  }
388
480
 
389
481
  jar2bin(){
@@ -56,7 +56,7 @@ else
56
56
  end
57
57
  end
58
58
 
59
- if String === file and not Open.remote? file and File.exist? file
59
+ if String === file and not Open.remote? file and File.exist? file and not Open.gzip? file
60
60
  rows = `wc -l '#{ file }' 2> /dev/null|cut -f 1 -d' '`.strip
61
61
  header_rows = `(head '#{ file }' |grep "#" | wc -l) 2> /dev/null|cut -f 1 -d' '`
62
62
  if header_rows.to_i <= 2 and header_rows.to_i >= 1
@@ -65,7 +65,7 @@ else
65
65
  rows << ' (possibly including header)'
66
66
  end
67
67
  else
68
- rows = "Could not get rows of #{Misc.fingerprint file}"
68
+ rows = "Could not get number of rows for #{Misc.fingerprint file}"
69
69
  end
70
70
 
71
71
  puts "Rows: #{Log.color :blue, rows}"
@@ -146,15 +146,14 @@ if all
146
146
  end
147
147
 
148
148
  if recursive
149
- inputs = step.info[:inputs]
150
- inputs = {}
151
- deps = (step.info[:dependencies] || []).collect{|v| get_step v.last }
149
+ inputs = step.info[:inputs] || {}
150
+ deps = step.dependencies
152
151
 
153
152
  while deps.any? do
154
153
  dep = deps.shift
155
154
  inputs = {} if inputs.nil?
156
155
  inputs = inputs.merge(dep.info[:inputs] || {})
157
- deps.concat (dep.info[:dependencies] || []).collect{|v| get_step v.last }
156
+ deps = deps.concat dep.dependencies
158
157
  end
159
158
 
160
159
  if inputs.any?
@@ -51,11 +51,11 @@ end
51
51
  #{{{ BASE
52
52
  app_eval app, etc_dir['app.d/base.rb'].find
53
53
 
54
- app.add_workflow wf, :priority
55
-
56
54
  #{{{ WORKFLOWS
57
55
  app_eval app, etc_dir['app.d/workflows.rb'].find_all
58
56
 
57
+ app.add_workflow wf, :priority
58
+
59
59
  #{{{ RESOURCES
60
60
  load_file etc_dir['app.d/resources.rb'].find
61
61
 
@@ -123,13 +123,22 @@ app.get '/reload_workflow' do
123
123
  halt 500, "Not allowed in production"
124
124
  end
125
125
 
126
- workflow = params[:workflow] if params[:workflow]
127
- wf_file = Workflow.local_workflow_filename(workflow)
128
- wf_dir = File.dirname(wf_file)
129
- $LOADED_FEATURES.delete_if do |path|
130
- Misc.path_relative_to(wf_dir, path)
126
+ begin
127
+ workflow = params[:workflow] if params[:workflow]
128
+ wf_file = Workflow.local_workflow_filename(workflow)
129
+ wf_dir = File.dirname(wf_file)
130
+ $LOADED_FEATURES.delete_if do |path|
131
+ Misc.path_relative_to(wf_dir, path)
132
+ end
133
+ load wf_file
134
+ rescue Exception
135
+ if File.exists?(Rbbt.etc['target_workflow'].read.strip)
136
+ load Rbbt.etc['target_workflow'].read.strip
137
+ else
138
+ raise $!
139
+ end
131
140
  end
132
- load wf_file
141
+
133
142
  halt 200, "Workflow #{ workflow } reloaded"
134
143
  end
135
144
 
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.25.32
4
+ version: 5.25.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-05 00:00:00.000000000 Z
11
+ date: 2019-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -302,6 +302,7 @@ files:
302
302
  - lib/rbbt/util/misc/system.rb
303
303
  - lib/rbbt/util/named_array.rb
304
304
  - lib/rbbt/util/open.rb
305
+ - lib/rbbt/util/python.rb
305
306
  - lib/rbbt/util/semaphore.rb
306
307
  - lib/rbbt/util/simpleDSL.rb
307
308
  - lib/rbbt/util/simpleopt.rb