From 3088d578f551523711db63062f11d63d155663dc Mon Sep 17 00:00:00 2001 From: Ward Wouts Date: Fri, 6 Feb 2009 08:50:41 +0000 Subject: [PATCH] it's all in the details --- pbatch/pb.rb | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/pbatch/pb.rb b/pbatch/pb.rb index 70029d6..55d7e59 100755 --- a/pbatch/pb.rb +++ b/pbatch/pb.rb @@ -39,20 +39,22 @@ ENDTXT end def readconfig - File.open("#{@basedir}/#{CONFIG}").each_line {|line| - line.sub!(/#.*/, "") - line.sub!(/^\s*/, "") - line.sub!(/\s*$/, "") - if line.match(/^$/) - next - end - line.match(/([^=]*?)\s*=\s*(.*)/) - case $1 - when "maxproc" then @config["maxproc"] = $2 - when "waittime" then @config["waittime"] = $2 - else puts "unknown option #{$1}" - end - } + if FileTest.exists?("#{@basedir}/#{CONFIG}") + File.open("#{@basedir}/#{CONFIG}").each_line {|line| + line.sub!(/#.*/, "") + line.sub!(/^\s*/, "") + line.sub!(/\s*$/, "") + if line.match(/^$/) + next + end + line.match(/([^=]*?)\s*=\s*(.*)/) + case $1 + when "maxproc" then @config["maxproc"] = $2 + when "waittime" then @config["waittime"] = $2 + else puts "unknown option #{$1}" + end + } + end end def status @@ -111,7 +113,7 @@ def addjob puts "Job #{jobnumber} already scheduled. This should not happen." exit end - File.open("#{@basedir}/#{JOBSDIR}/#{jobnumber}"){|file| + File.open("#{@basedir}/#{JOBSDIR}/#{jobnumber}", "w"){|file| file.puts ARGV.join(" ") } File.chmod(RUNMODE, "#{@basedir}/#{JOBSDIR}/#{jobnumber}") @@ -136,7 +138,7 @@ end def createconfig if ! FileTest.exists?("#{@basedir}/#{CONFIG}") - File.new("#{@basedir}/#{CONFIG}", "w"){|file| + File.open("#{@basedir}/#{CONFIG}", "w"){|file| file.puts <