Skip to content

Commit

Permalink
feat(languages.py): 与上游配置同步
Browse files Browse the repository at this point in the history
1. 修复 java 运行警告
2. JS 添加检查
3. Python 添加 -BS 参数
  • Loading branch information
Aelita-S committed Mar 17, 2024
1 parent e58840f commit ccfd2c0
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions server/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,9 @@ def __init__(
self.max_memory = -1 # 不限制
self.memory_limit_check_only = 1
self._seccomp_rule = None
self._compile_command = "/usr/bin/javac {src_path} -d {exe_dir} -encoding UTF8"
self._compile_command = "/usr/bin/javac {src_path} -d {exe_dir}"
self._execute_command = (
"/usr/bin/java -cp {exe_dir} -XX:MaxRAM={max_memory}k -Djava.security.manager "
"-Dfile.encoding=UTF-8 -Djava.security.policy==/etc/java_policy "
"-Djava.awt.headless=true Main"
"/usr/bin/java -cp {exe_dir} -XX:MaxRAM={max_memory}k Main"
)


Expand All @@ -213,8 +211,10 @@ def __init__(
self.max_real_time = 10000
self.max_memory = 128 * 1024 * 1024
self._compile_command = "/usr/bin/python3 -m py_compile {src_path}"
self._execute_command = "/usr/bin/python3 {exe_path}"
self._env = default_env + ["PYTHONIOENCODING=utf-8"]
self._execute_command = (
"/usr/bin/python3 -BS {exe_path}" # -B: 不生成 .pyc 文件, -S: 不导入 site 模块
)
self._env = default_env
self.compiled = False


Expand Down Expand Up @@ -244,20 +244,20 @@ def __init__(
self.memory_limit_check_only = 1


class PHPConfig(BaseLanguageConfig):
def __init__(
self,
options: Optional[OptionType] = None,
io_mode: Optional[Literal["stdio", "file"]] = ProblemIOMode.standard,
):
super().__init__(options, io_mode)
self.src_name = "solution.php"
self.exe_name = "solution.php"
self._execute_command = "/usr/bin/php {exe_path}"
self._env = default_env
self.memory_limit_check_only = 1
self.compiled = False
self._seccomp_rule = None # 不使用 seccomp
# class PHPConfig(BaseLanguageConfig):
# def __init__(
# self,
# options: Optional[OptionType] = None,
# io_mode: Optional[Literal["stdio", "file"]] = ProblemIOMode.standard,
# ):
# super().__init__(options, io_mode)
# self.src_name = "solution.php"
# self.exe_name = "solution.php"
# self._execute_command = "/usr/bin/php {exe_path}"
# self._env = default_env
# self.memory_limit_check_only = 1
# self.compiled = False
# self._seccomp_rule = None # 不使用 seccomp


class JSConfig(BaseLanguageConfig):
Expand All @@ -269,11 +269,12 @@ def __init__(
super().__init__(options, io_mode)
self.src_name = "solution.js"
self.exe_name = "solution.js"
self._compile_command = "/usr/bin/node --check {src_path}" # 检查语法错误
self._execute_command = "/usr/bin/node {exe_path}"
self._env = default_env + ["NO_COLOR=true"]
self._seccomp_rule = "node"
self.memory_limit_check_only = 1
self.compiled = False
self.compiled = True


c_lang_spj_compile = {
Expand Down Expand Up @@ -312,7 +313,7 @@ def __init__(
"java": JavaConfig,
"py": Py3Config,
"go": GoConfig,
"php": PHPConfig,
# "php": PHPConfig,
"js": JSConfig,
}
if __name__ == "__main__":
Expand Down

0 comments on commit ccfd2c0

Please sign in to comment.