Merge branch 'QingdaoU-master'

This commit is contained in:
Harry-zklcdc 2020-07-08 11:05:14 +08:00
commit d0a5c53ef4
2 changed files with 32 additions and 0 deletions

View File

@ -437,6 +437,33 @@ _py3_lang_config = {
}
}
_go_lang_config = {
"template": """//PREPEND BEGIN
//PREPEND END
//TEMPLATE BEGIN
//TEMPLATE END
//APPEND BEGIN
//APPEND END""",
"compile": {
"src_name": "main.go",
"exe_name": "main",
"max_cpu_time": 3000,
"max_real_time": 5000,
"max_memory": 1024 * 1024 * 1024,
"compile_command": "/usr/bin/go build -o {exe_path} {src_path}",
"env": ["GOCACHE=/tmp"]
},
"run": {
"command": "{exe_path}",
"seccomp_rule": "",
# 降低内存占用
"env": ["GODEBUG=madvdontneed=1"] + default_env,
"memory_limit_check_only": 1
}
}
languages = [
{"config": _c_lang_config, "spj": {"compile": _c_lang_spj_compile, "config": _c_lang_spj_config},
"name": "C", "description": "GCC 9.2.1", "content_type": "text/x-csrc"},
@ -453,4 +480,5 @@ languages = [
{"config": _java_lang_config, "name": "Java", "description": "OpenJDK 1.8", "content_type": "text/x-java"},
{"config": _py2_lang_config, "name": "Python2", "description": "Python 2.7.15+", "content_type": "text/x-python"},
{"config": _py3_lang_config, "name": "Python3", "description": "Python 3.5.2", "content_type": "text/x-python"},
{"config": _go_lang_config, "name": "Golang 1.14", "description": "Golang 1.14", "content_type": "text/x-go"},
]

View File

@ -676,6 +676,10 @@ class FPSProblemImport(CSRFExemptAPIView):
with tempfile.NamedTemporaryFile("wb") as tf:
for chunk in file.chunks(4096):
tf.file.write(chunk)
tf.file.flush()
os.fsync(tf.file)
problems = FPSParser(tf.name).parse()
else:
return self.error("Parse upload file error")