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:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r25:8541b6e657f1 - - 1 file changed: 3 inserted, 0 deleted

@@ -3,48 +3,51
3 3 def stop_grader(id)
4 4 if id==:all
5 5 File.open(File.dirname(__FILE__) + "/stop.all",'w').close
6 6 else
7 7 File.open(File.dirname(__FILE__) + "/stop.#{id}",'w').close
8 8 end
9 9 end
10 10
11 11 def check_stopfile
12 12 FileTest.exist?(File.dirname(__FILE__) + "/stop.all") or
13 13 FileTest.exist?(File.dirname(__FILE__) + "/stop.#{Process.pid}")
14 14 end
15 15
16 16 def clear_stopfile
17 17 if FileTest.exist?(File.dirname(__FILE__) + "/stop.#{Process.pid}")
18 18 system("rm " + File.dirname(__FILE__) + "/stop.#{Process.pid}")
19 19 end
20 20 end
21 21
22 22 def config
23 23 Grader::Configuration.get_instance
24 24 end
25 25
26 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 30 config.log_dir +
28 31 "/#{GRADER_ENV}_#{config.grader_mode}.#{Process.pid}"
29 32 end
30 33
31 34 def log(str)
32 35 if config.talkative
33 36 puts str
34 37 end
35 38 if config.logging
36 39 fp = File.open(log_file_name,"a")
37 40 fp.puts("GRADER: #{Time.new.strftime("%H:%M")} #{str}")
38 41 fp.close
39 42 end
40 43 end
41 44
42 45 def display_manual
43 46 puts <<USAGE
44 47 Grader.
45 48 using: (1) grader
46 49 (2) grader environment [mode]
47 50 (3) grader stop [all|pids-list]
48 51 (4) grader --help
49 52 (1) call grader with environment = 'exam', mode = 'queue'
50 53 (2) possible modes are: 'queue', 'prob', 'test_request'
You need to be logged in to leave comments. Login now