rbbt-util 5.17.81 → 5.17.82

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: cbcb3c91e224e6ad020154b1cf11a2a6b4274271
4
- data.tar.gz: 5da8992b0fe6c5477e35f97a6f58984e2c895662
3
+ metadata.gz: 06179bbff3dd8c45a91bd877fe23adef43e2299b
4
+ data.tar.gz: 5bf1cd04f279300d4c4bf2ce91f831f1d675c123
5
5
  SHA512:
6
- metadata.gz: 6d647f7fa974f11ae7084299c3a945effbfda8f37fe197aa3fe4da783cb409a2a06ee9d71fa39727ffdbe517a978a1151dad563537b8b93659721887648d471b
7
- data.tar.gz: a63ea4a95ff076713d745b4350dcb124971eeee3647a9aece335dba388aa37e6ace616d245639f2c48cd5310b82f3b804ff67c118a01796d9758ee8f83807abb
6
+ metadata.gz: 1042bfebbe214dd1a9ef60c704bfc1bdc209e300fe46c759ee766b7a40c71049e545a7b229a490c1207890c16ce73d890f2cef722f8cfa3a6e0c0c1d434bce3a
7
+ data.tar.gz: 51734367f0342e5ba6dc2e3432b0892ec99f01951704d65b2c6a8201413f21e9fb5e853f32233134d69d7123b2bf9b9afe8c711d1418eae0b90dddc2348ba819
@@ -63,7 +63,7 @@ module TSV
63
63
  input_options << parser.options
64
64
  preambles << parser.preamble if preamble and not parser.preamble.empty?
65
65
 
66
- if fix_flat and parser.type == :flat
66
+ if fix_flat and parser.type == :flat and parser.first_line
67
67
  parts = lines[-1].split("\t")
68
68
  lines[-1] = [parts[0], parts[1..-1]*"|"] * "\t"
69
69
  TSV.stream_flat2double(parser.stream).stream
@@ -321,4 +321,31 @@ module Misc
321
321
  def self.memory_use(pid=nil)
322
322
  `ps -o rss -p #{pid || $$}`.strip.split.last.to_i
323
323
  end
324
+
325
+ PUSHBULLET_KEY=begin
326
+ if ENV["PUSHBULLET_KEY"]
327
+ ENV["PUSHBULLET_KEY"]
328
+ else
329
+ config_api = File.join(ENV['HOME'], 'config/apps/pushbullet/apikey')
330
+ if File.exists? config_api
331
+ File.read(config_api).strip
332
+ else
333
+ nil
334
+ end
335
+ end
336
+ end
337
+
338
+ def self.notify(description, event='notification', key = nil)
339
+ if PUSHBULLET_KEY.nil? and key.nil?
340
+ Log.warn "Could not notify, no PUSHBULLET_KEY"
341
+ return
342
+ end
343
+
344
+ Thread.new do
345
+ application = 'rbbt'
346
+ event ||= 'notification'
347
+ key ||= PUSHBULLET_KEY
348
+ `curl -s --header "Authorization: Bearer #{key}" -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"type": "note", "title": "#{event}", "body": "#{description}"}'`
349
+ end
350
+ end
324
351
  end
@@ -56,7 +56,7 @@ module Misc
56
56
  def self.format_definition_list_item(dt, dd, size = 80, indent = 20, color = :yellow)
57
57
  dd = "" if dd.nil?
58
58
  dt = Log.color color, dt if color
59
- dt = dt.to_s + ":" unless dd.empty?
59
+ dt = dt.to_s unless dd.empty?
60
60
  len = Log.uncolor(dt).length
61
61
 
62
62
  if indent < 0
@@ -267,6 +267,7 @@ module Misc
267
267
  lock_options[:lock].unlock
268
268
  end
269
269
  FileUtils.touch path if File.exists? path
270
+ Open.notify_write(path)
270
271
  rescue Aborted
271
272
  Log.medium "Aborted sensiblewrite -- #{ Log.reset << Log.color(:blue, path) }"
272
273
  content.abort if content.respond_to? :abort
@@ -427,6 +427,20 @@ module Open
427
427
  end
428
428
  end
429
429
 
430
+ def self.notify_write(file)
431
+ begin
432
+ notification_file = file + '.notify'
433
+ if File.exists? notification_file
434
+ key = Open.read(notification_file).strip
435
+ key = nil if key.empty?
436
+ Misc.notify("Wrote " << file, nil, key)
437
+ FileUtils.rm notification_file
438
+ end
439
+ rescue
440
+ Log.warn "Error notifying write of #{ file }"
441
+ end
442
+ end
443
+
430
444
  def self.write(file, content = nil, options = {})
431
445
  options = Misc.add_defaults options, :mode => 'w'
432
446
 
@@ -463,5 +477,6 @@ module Open
463
477
  end
464
478
  content.close
465
479
  end
480
+ notify_write(file)
466
481
  end
467
482
  end
@@ -47,7 +47,10 @@ module SOPT
47
47
  def self.input_doc(inputs, input_types = nil, input_descriptions = nil, input_defaults = nil, input_shortcuts = nil)
48
48
  type = description = default = nil
49
49
  shortcut = ""
50
+ seen = []
50
51
  inputs.collect do |name|
52
+ next if seen.include? name
53
+ seen << name
51
54
 
52
55
  type = input_types[name] unless input_types.nil?
53
56
  description = input_descriptions[name] unless input_descriptions.nil?
data/lib/rbbt/workflow.rb CHANGED
@@ -171,17 +171,29 @@ module Workflow
171
171
 
172
172
  #{{{ ATTR DEFAULTS
173
173
 
174
+
175
+ def self.workdir=(path)
176
+ path = Path.setup path.dup unless Path === path
177
+ @@workdir = path
178
+ end
179
+
180
+ def self.workdir
181
+ @@workdir ||= if defined? Rbbt
182
+ Rbbt.var.jobs.find
183
+ else
184
+ Path.setup('var/jobs')
185
+ end
186
+ end
187
+
174
188
  def workdir=(path)
175
189
  path = Path.setup path.dup unless Path === path
176
190
  @workdir = path
177
191
  end
178
192
 
179
193
  def workdir
180
- @workdir ||= if defined? Rbbt
194
+ @workdir ||= begin
181
195
  text = Module === self ? self.to_s : "Misc"
182
- Rbbt.var.jobs[text].find
183
- else
184
- Path.setup('var/jobs')
196
+ Workflow.workdir[text].find
185
197
  end
186
198
  end
187
199
 
@@ -0,0 +1,34 @@
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
+
10
+ Notify on completion of file
11
+
12
+ $ rbbt notify [options] <filename>
13
+
14
+ Creates a <filename>.notify that will trigger a notification when a process creates it
15
+
16
+ -h--help Print this help
17
+ -k--key* Pushbullet apikey (optinal)
18
+
19
+ EOF
20
+ if options[:help]
21
+ if defined? rbbt_usage
22
+ rbbt_usage
23
+ else
24
+ puts SOPT.usage
25
+ end
26
+ exit 0
27
+ end
28
+
29
+ key = options[:key] || ''
30
+ file = ARGV.shift
31
+ notify_file = file + '.notify'
32
+ Open.write(notify_file, key)
33
+
34
+
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.17.81
4
+ version: 5.17.82
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-09 00:00:00.000000000 Z
11
+ date: 2015-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -326,6 +326,7 @@ files:
326
326
  - share/rbbt_commands/tsv/subset
327
327
  - share/rbbt_commands/tsv/unzip
328
328
  - share/rbbt_commands/tsv/values
329
+ - share/rbbt_commands/watch
329
330
  - share/rbbt_commands/workflow/cmd
330
331
  - share/rbbt_commands/workflow/example
331
332
  - share/rbbt_commands/workflow/info