Description:
merge
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r270:cfcb015a0053 - - 4 files changed: 62 inserted, 1 deleted
@@ -0,0 +1,45 | |||
|
1 | + #!/usr/bin/env ruby | |
|
2 | + | |
|
3 | + require 'fileutils' | |
|
4 | + | |
|
5 | + ENVIRONMENT_DIRS = ['ev', 'ev-exam'] | |
|
6 | + | |
|
7 | + def config | |
|
8 | + Grader::Configuration.get_instance | |
|
9 | + end | |
|
10 | + | |
|
11 | + def usage | |
|
12 | + puts <<USAGE | |
|
13 | + Usage: | |
|
14 | + dump_submission prob_id1 prob_id2 prob_id3 ... | |
|
15 | + | |
|
16 | + This will dumps all submission of the given problem ids into <current_dir>/<problem_name>/<user login>/<submission_id> | |
|
17 | + USAGE | |
|
18 | + end | |
|
19 | + | |
|
20 | + if (ARGV.length == 0) | |
|
21 | + usage | |
|
22 | + exit(0) | |
|
23 | + end | |
|
24 | + | |
|
25 | + # load grader environment | |
|
26 | + GRADER_ENV = 'grading' | |
|
27 | + require File.join(File.dirname(__FILE__),'config/environment') | |
|
28 | + | |
|
29 | + # boot rails, to be able to rename the problem | |
|
30 | + RAILS_ENV = config.rails_env | |
|
31 | + require RAILS_ROOT + '/config/environment' | |
|
32 | + | |
|
33 | + prob_ids = ARGV.map{ |x| x.to_i} | |
|
34 | + | |
|
35 | + | |
|
36 | + prob_ids.each do |id| | |
|
37 | + p = Problem.find(id) | |
|
38 | + p.submissions.each do |s| | |
|
39 | + dir = "#{p.name}/#{s.user.login}/#{s.id}.#{s.language.ext}" | |
|
40 | + filename = "#{s.id}.#{s.language.ext}" | |
|
41 | + FileUtils.mkdir_p dir | |
|
42 | + File.write("#{dir}/#{filename}",s.source) | |
|
43 | + puts filename | |
|
44 | + end | |
|
45 | + end |
@@ -32,6 +32,7 | |||
|
32 | 32 | PYTHON_CHECKER = "/usr/bin/pyflakes" |
|
33 | 33 | PHP_INTERPRETER = "/usr/bin/php" |
|
34 | 34 | HASKELL_COMPILER = "/usr/bin/ghc" |
|
35 | + OCTAVE_INTERPRETER = "/usr/bin/octave" | |
|
35 | 36 | |
|
36 | 37 | C_OPTIONS = "-O2 -s -static -std=c99 -DCONTEST -lm -Wall" |
|
37 | 38 | CPLUSPLUS_OPTIONS = "-O2 -s -std=c++11 -static -DCONTEST -lm -Wall" |
@@ -186,6 +187,18 | |||
|
186 | 187 | talk "COMPILE: compiling command [#{command}]" |
|
187 | 188 | system(command, err: params[:message_file]) |
|
188 | 189 | |
|
190 | + when "octave" | |
|
191 | + command = "touch" | |
|
192 | + talk "COMPILE: compiling command [#{command}], log err to #{params[:message_file]}" | |
|
193 | + system(command, err: params[:message_file]) | |
|
194 | + File.open(params[:output_file],"w") do |out_file| | |
|
195 | + out_file.puts "#!#{OCTAVE_INTERPRETER}" | |
|
196 | + File.open(params[:source_file],"r").each do |line| | |
|
197 | + out_file.print line | |
|
198 | + end | |
|
199 | + end | |
|
200 | + File.chmod(0755, params[:output_file]) | |
|
201 | + | |
|
189 | 202 | else |
|
190 | 203 | talk("COMPILE: ERROR: Invalid language specified!") |
|
191 | 204 | open(params[:message_file],"w") do |f| |
@@ -53,7 +53,7 | |||
|
53 | 53 | end |
|
54 | 54 | |
|
55 | 55 | language = ARGV[0] |
|
56 | - if language != "c" && language != "c++" && language != "pas" && language != "java" && language != "ruby" && language != "python" && language != "php" && language != "haskell" | |
|
56 | + if language != "c" && language != "c++" && language != "pas" && language != "java" && language != "ruby" && language != "python" && language != "php" && language != "haskell" && language != "octave" | |
|
57 | 57 | log "JUDGE: You specified a language that is not supported: #{language}." |
|
58 | 58 | exit(127) |
|
59 | 59 | end |
@@ -112,6 +112,7 | |||
|
112 | 112 | JAVA_OPTION = "-s set_robust_list -s futex -s clone -s getppid -s clone -s wait4 -p /usr/bin/ -p ./" |
|
113 | 113 | RUBY_OPTION = "-p /usr/lib64/ -p /usr/local/lib64/ -p /usr/local/lib/ -p /lib64/ -p /dev/urandom -p #{sandbox_dir}/#{program_name} -p #{sandbox_dir}/ -s set_robust_list -s sched_getaffinity -s clock_gettime -s sigaltstack -s pipe2 -s clone -s futex -s openat -s pipe -s getrandom" |
|
114 | 114 | PYTHON_OPTION = "-p /usr/lib64/ -p /usr/local/lib64/ -p /usr/local/lib/ -p /usr/bin/ -p /lib64/ -p /dev/urandom -p /usr/ -p #{sandbox_dir}/#{program_name} -p ./#{program_name} -p #{sandbox_dir}/#{source_name} -p /proc/sys/crypto/fips_enabled -p /proc/self/status -p /proc/mounts -p /var/lib/dpkg/status -s statfs -s set_robust_list -s openat -s sysinfo -s recvmsg -s connect -s socket -s sendto -s futex -s sigaltstack -s getrandom -E PYTHONNOUSERSITE=yes" |
|
115 | + OCTAVE_OPTION = "-p /usr/lib64/ -p /usr/local/lib64/ -p /usr/local/lib/ -p /usr/bin/ -p /lib64/ -p /dev/urandom -p /usr/ -p #{sandbox_dir}/#{program_name} -p ./#{program_name} -p #{sandbox_dir}/#{source_name} -p /proc/sys/crypto/fips_enabled -p /proc/self/status -p /proc/mounts -p /var/lib/dpkg/status -s statfs -s set_robust_list -s openat -s sysinfo -s recvmsg -s connect -s socket -s sendto -s futex -s sigaltstack -s getrandom -s prlimit64 -s execve -E PYTHONNOUSERSITE=yes" | |
|
115 | 116 | PHP_OPTION = "-p /usr/lib64/ -p/lib64/ -p /usr/bin/ -p #{sandbox_dir}/#{program_name} -p ./#{program_name} -p /usr/share/ -s setfsuid -s setfsgid -s openat -s set_robust_list -s futex -s clone -s socket -s connect" |
|
116 | 117 | HASKELL_OPTION = "-s set_robust_list -s clock_gettime -s sysinfo -s timer_create -s timer_settime -s futex -s timer_delete" |
|
117 | 118 | |
@@ -133,6 +134,8 | |||
|
133 | 134 | run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit} -m #{[512 * 1024,mem_limit].max} #{HASKELL_OPTION} -i #{input_file_name} -o output.txt #{program_name} " |
|
134 | 135 | when "php" |
|
135 | 136 | run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit*=2} -m #{[512 * 1024,mem_limit].max} #{PHP_OPTION} -i #{input_file_name} -o output.txt /usr/bin/php -A -d -A memory_limit=#{mem_limit}k -A #{program_name} " |
|
137 | + when "octave" | |
|
138 | + run_command = "#{problem_home}/script/box -T -t #{time_limit*=2} -m #{[512 * 1024,mem_limit].max} #{OCTAVE_OPTION} -i #{input_file_name} -o output.txt /usr/bin/octave -A -W -A --no-gui #{program_name}" | |
|
136 | 139 | else # for c++, pascal, we do the normal checking |
|
137 | 140 | run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit} -m #{mem_limit} -i #{input_file_name} -o output.txt #{program_name} " |
|
138 | 141 | end |
You need to be logged in to leave comments.
Login now