Description:
[grader] raise when log directory does not exist
git-svn-id: http://theory.cpe.ku.ac.th/grader/judge/trunk/scripts@108 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r25:8541b6e657f1 - - 1 file changed: 3 inserted, 0 deleted
@@ -3,48 +3,51 | |||||
|
3 | def stop_grader(id) |
|
3 | def stop_grader(id) |
|
4 | if id==:all |
|
4 | if id==:all |
|
5 | File.open(File.dirname(__FILE__) + "/stop.all",'w').close |
|
5 | File.open(File.dirname(__FILE__) + "/stop.all",'w').close |
|
6 | else |
|
6 | else |
|
7 | File.open(File.dirname(__FILE__) + "/stop.#{id}",'w').close |
|
7 | File.open(File.dirname(__FILE__) + "/stop.#{id}",'w').close |
|
8 | end |
|
8 | end |
|
9 | end |
|
9 | end |
|
10 |
|
10 | ||
|
11 | def check_stopfile |
|
11 | def check_stopfile |
|
12 | FileTest.exist?(File.dirname(__FILE__) + "/stop.all") or |
|
12 | FileTest.exist?(File.dirname(__FILE__) + "/stop.all") or |
|
13 | FileTest.exist?(File.dirname(__FILE__) + "/stop.#{Process.pid}") |
|
13 | FileTest.exist?(File.dirname(__FILE__) + "/stop.#{Process.pid}") |
|
14 | end |
|
14 | end |
|
15 |
|
15 | ||
|
16 | def clear_stopfile |
|
16 | def clear_stopfile |
|
17 | if FileTest.exist?(File.dirname(__FILE__) + "/stop.#{Process.pid}") |
|
17 | if FileTest.exist?(File.dirname(__FILE__) + "/stop.#{Process.pid}") |
|
18 | system("rm " + File.dirname(__FILE__) + "/stop.#{Process.pid}") |
|
18 | system("rm " + File.dirname(__FILE__) + "/stop.#{Process.pid}") |
|
19 | end |
|
19 | end |
|
20 | end |
|
20 | end |
|
21 |
|
21 | ||
|
22 | def config |
|
22 | def config |
|
23 | Grader::Configuration.get_instance |
|
23 | Grader::Configuration.get_instance |
|
24 | end |
|
24 | end |
|
25 |
|
25 | ||
|
26 | def log_file_name |
|
26 | def log_file_name |
|
|
27 | + if !File.exists?(config.log_dir) | ||
|
|
28 | + raise "Log directory does not exist: #{config.log_dir}" | ||
|
|
29 | + end | ||
|
27 | config.log_dir + |
|
30 | config.log_dir + |
|
28 | "/#{GRADER_ENV}_#{config.grader_mode}.#{Process.pid}" |
|
31 | "/#{GRADER_ENV}_#{config.grader_mode}.#{Process.pid}" |
|
29 | end |
|
32 | end |
|
30 |
|
33 | ||
|
31 | def log(str) |
|
34 | def log(str) |
|
32 | if config.talkative |
|
35 | if config.talkative |
|
33 | puts str |
|
36 | puts str |
|
34 | end |
|
37 | end |
|
35 | if config.logging |
|
38 | if config.logging |
|
36 | fp = File.open(log_file_name,"a") |
|
39 | fp = File.open(log_file_name,"a") |
|
37 | fp.puts("GRADER: #{Time.new.strftime("%H:%M")} #{str}") |
|
40 | fp.puts("GRADER: #{Time.new.strftime("%H:%M")} #{str}") |
|
38 | fp.close |
|
41 | fp.close |
|
39 | end |
|
42 | end |
|
40 | end |
|
43 | end |
|
41 |
|
44 | ||
|
42 | def display_manual |
|
45 | def display_manual |
|
43 | puts <<USAGE |
|
46 | puts <<USAGE |
|
44 | Grader. |
|
47 | Grader. |
|
45 | using: (1) grader |
|
48 | using: (1) grader |
|
46 | (2) grader environment [mode] |
|
49 | (2) grader environment [mode] |
|
47 | (3) grader stop [all|pids-list] |
|
50 | (3) grader stop [all|pids-list] |
|
48 | (4) grader --help |
|
51 | (4) grader --help |
|
49 | (1) call grader with environment = 'exam', mode = 'queue' |
|
52 | (1) call grader with environment = 'exam', mode = 'queue' |
|
50 | (2) possible modes are: 'queue', 'prob', 'test_request' |
|
53 | (2) possible modes are: 'queue', 'prob', 'test_request' |
You need to be logged in to leave comments.
Login now