Class: SGE::QStat::Job
- Inherits:
-
Object
- Object
- SGE::QStat::Job
- Includes:
- JobHelpers
- Defined in:
- lib/sge/qstat/job.rb
Class Method Summary collapse
Methods included from JobHelpers
Class Method Details
.command(opts) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/sge/qstat/job.rb', line 45 def self.command(opts) if opts[:cmd] stat = File.stat(opts[:fifo]) [opts[:cmd],">", opts[:fifo], stat.pipe? ? "&" : nil].join(' ') else file = opts[:sample] || File.('../../../../spec/data/qstat.sge',__FILE__) "cat #{file} > #{opts[:fifo]} &" end end |
.load_documents(opts, &block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sge/qstat/job.rb', line 15 def self.load_documents(opts,&block) documents = [] # Make a fifo to dump file fifo = opts[:file] || SGE::Utils.mkfifo(opts[:tmp_dir]) # Compute command cmd = command(opts.merge(:fifo => fifo)) # Execute this command SGE::Utils.execute(cmd) # We need a XML parser # Read file from fifo and instantiate jobs SGE::Utils.read_file(fifo, true) do |file| # Parse the file doc = SGE::QStat::Parser.parse(file) # Loop through the jobs found doc.jobs.each do |j| if block_given? documents << yield(self.from_document(j)) else documents << self.from_document(j) end end end documents end |