Show More
Commit Description:
Merged new-arch-branch changes 61:73 into the trunk...
Commit Description:
Merged new-arch-branch changes 61:73 into the trunk git-svn-id: http://theory.cpe.ku.ac.th/grader/judge/trunk/scripts@74 6386c4cd-e34a-4fa8-8920-d93eb39b512e
File last commit:
Show/Diff file:
Action:
grader | 106 lines | 1.9 KiB | text/plain | TextLexer |
jittat
import original files...
r0 #!/usr/bin/ruby
jittat
add grader stop, fix ARGV bug...
r6 def stop_grader
jittat
git-svn-id: http://theory.cpe.ku.ac.th/grader/cli/trunk/scripts@20 6386c4cd-e34a-4fa8-8920-d93eb39b512e
r7 File.open(File.dirname(__FILE__) + '/stop','w').close
jittat
add grader stop, fix ARGV bug...
r6 end
def check_stopfile
FileTest.exist?(File.dirname(__FILE__) + '/stop')
end
def clear_stopfile
system("rm " + File.dirname(__FILE__) + '/stop')
jittat
import original files...
r0 end
jittat
add grader stop, fix ARGV bug...
r6
jittat
Merged new-arch-branch changes 61:73 into the trunk...
r22 def config
Grader::Configuration.get_instance
end
def talk(str)
if config.talkative
puts str
end
end
jittat
add: grader copies std script...
r11 #########################################
# main program
#########################################
jittat
add grader stop, fix ARGV bug...
r6 # reading environment and options
if (ARGV.length >= 1) and (ARGV[0]=='stop')
stop_grader
puts "stop file created"
exit(0)
end
if check_stopfile
puts "stop file exists"
clear_stopfile
exit(0)
end
jittat
add warning for check...
r9 grader_mode = 'queue'
jittat
add grader stop, fix ARGV bug...
r6 if ARGV.length >= 1
GRADER_ENV = ARGV[0]
jittat
add warning for check...
r9 if ARGV.length >=2
grader_mode = ARGV[1]
end
jittat
add grader stop, fix ARGV bug...
r6 else
GRADER_ENV = 'exam'
end
puts "environment: #{GRADER_ENV}"
jittat
Merged new-arch-branch changes 61:73 into the trunk...
r22 require File.join(File.dirname(__FILE__),'config/environment')
jittat
import original files...
r0
jittat
add task queue access control, grader status...
r20 #reading rails environment
jittat
import original files...
r0 talk 'Reading rails environment'
jittat
Merged new-arch-branch changes 61:73 into the trunk...
r22 RAILS_ENV = config.rails_env
require RAILS_ROOT + '/config/environment'
jittat
import original files...
r0
jittat
add task queue access control, grader status...
r20 #register grader process
jittat
Merged new-arch-branch changes 61:73 into the trunk...
r22 if config.report_grader
grader_proc = GraderProcess.register(config.grader_hostname,
jittat
add task queue access control, grader status...
r20 Process.pid,
grader_mode)
else
grader_proc = nil
end
jittat
Merged new-arch-branch changes 61:73 into the trunk...
r22 # create judge engine
engine = Grader::Engine.new(grader_proc)
jittat
add warning for check...
r9 case grader_mode
when "queue"
talk 'Grader queue'
while true
jittat
add task queue access control, grader status...
r20
jittat
add warning for check...
r9 if check_stopfile # created by calling grader stop
clear_stopfile
puts "stopped"
jittat
Merged new-arch-branch changes 61:73 into the trunk...
r22 break
jittat
add warning for check...
r9 end
jittat
add task queue access control, grader status...
r20
jittat
Merged new-arch-branch changes 61:73 into the trunk...
r22 task = engine.grade_oldest_task
if task==nil
jittat
add task queue access control, grader status...
r20 sleep(5)
jittat
add warning for check...
r9 end
end
when "prob"
jittat
add task queue access control, grader status...
r20
grader_proc.report_active if grader_proc!=nil
jittat
add warning for check...
r9 prob = Problem.find_by_name(ARGV[2])
if prob==nil
puts "cannot find problem: #{ARGV[2]}"
jittat
Merged new-arch-branch changes 61:73 into the trunk...
r22 else
engine.grade_problem(prob)
jittat
add grader stop, fix ARGV bug...
r6 end
jittat
Merged new-arch-branch changes 61:73 into the trunk...
r22
jittat
import original files...
r0 end
jittat
add task queue access control, grader status...
r20 # report inactive
grader_proc.report_inactive if grader_proc!=nil
jittat
add warning for check...
r9