| In: |
lib/rq-3.0.0/ioviewer.rb
|
| Parent: | MainHelper |
the IOViewer class spawns an external editor command to view the stdin/stdout/stderr of a jid(s)
# File lib/rq-3.0.0/ioviewer.rb, line 15
15: def ioview
16: #--{{{
17: @infile = @options['infile']
18: debug{ "infile <#{ @infile }>" }
19:
20: jobs = []
21: if @infile
22: open(@infile) do |f|
23: debug{ "reading jobs from <#{ @infile }>" }
24: loadio f, @infile, jobs
25: end
26: end
27: if stdin?
28: debug{ "reading jobs from <stdin>" }
29: loadio stdin, 'stdin', jobs
30: end
31: jobs.each{|job| @argv << Integer(job['jid'])}
32:
33: editor = @options['editor'] || ENV['RQ_EDITOR'] || ENV['RQ_IOVIEW'] || 'vim -R -o'
34: @argv.each do |jid|
35: jid = Integer jid
36: ios = %( stdin stdout stderr ).map{|d| File.join @qpath, d, jid.to_s}
37: command = "#{ editor } #{ ios.join ' ' }"
38: system(command) #or error{ "command <#{ command }> failed with <#{ $? }>" }
39: end
40: self
41: #--}}}
42: end