Description:
add grader stop, fix ARGV bug git-svn-id: http://theory.cpe.ku.ac.th/grader/cli/trunk/scripts@19 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r6:f3b2d1128766 - - 1 file changed: 37 inserted, 5 deleted

@@ -81,15 +81,41
81 81 save_result(sub,read_result("#{problem_out_dir}/test-result"))
82 82 end
83 83
84 - # reading environment
85 - GRADER_ENV = 'exam'
86 - if ARGV.length > 1
87 - GRADER_ENV = ARGV[1]
84 + def stop_grader
85 + File.open(File.dirname(__FILE__) + '/stop','w')
86 + end
87 +
88 + def check_stopfile
89 + FileTest.exist?(File.dirname(__FILE__) + '/stop')
90 + end
91 +
92 + def clear_stopfile
93 + system("rm " + File.dirname(__FILE__) + '/stop')
88 94 end
95 +
96 + # reading environment and options
97 + if (ARGV.length >= 1) and (ARGV[0]=='stop')
98 + stop_grader
99 + puts "stop file created"
100 + exit(0)
101 + end
102 +
103 + if check_stopfile
104 + puts "stop file exists"
105 + clear_stopfile
106 + exit(0)
107 + end
108 +
109 + if ARGV.length >= 1
110 + GRADER_ENV = ARGV[0]
111 + else
112 + GRADER_ENV = 'exam'
113 + end
114 +
115 + puts "environment: #{GRADER_ENV}"
89 116 require File.dirname(__FILE__) + "/environment.rb"
90 117
91 118 #main program
92 -
93 119 talk 'Reading rails environment'
94 120
95 121 RAILS_ENV = 'development'
@@ -99,6 +125,12
99 125
100 126 talk 'Grader queue'
101 127 while true
128 + if check_stopfile # created by calling grader stop
129 + clear_stopfile
130 + puts "stopped"
131 + exit(0)
132 + end
133 +
102 134 task = Task.find(:first, :order => 'created_at')
103 135 if task!=nil
104 136 grade(task.submission_id)
You need to be logged in to leave comments. Login now