(self.exe_status, self.exe_time, self.exe_mem, info_len) = \ struct.unpack("IIII", f.read(16)) if info_len: self.exe_extra_info = f.read(info_len) else: self.exe_extra_info = '' os.close(ftmp[0]) os.remove(ftmp[1]) except Exception as e: log.error( "[limiter {0!r}] failed to retrieve data through file: {1}" .format(self._name, e)) raise SysError("limiter file error") if self._type == _LIMITER_SOCKET: try: conn.close() except Exception as e: log.warning("failed to close socket connection: {0}".format(e)) def _ch_add_limiter(args): if len(args) == 1: raise UserError( "Option {0} must be specified in the configuration file.".format( args[0])) _Limiter(args) conf.register_handler("AddLimiter", _ch_add_limiter)
core.lang_dict[lang].judge(conn, pcode, pconf, src, input, output) except snc.Error as e: log.error("failed to communicate with orzoj-server because of network error") control.set_termination_flag() raise Error except core.Error: control.set_termination_flag() raise Error def _set_datacache(arg): os.chdir(arg[1]) def _set_id(arg): global _judge_id _judge_id = arg[1] def _ch_set_info(arg): if len(arg) == 1: return if len(arg) < 3: raise conf.UserError("Option {0} takes at least two arguments" . format(arg[0])) global _info_dict _info_dict[arg[1]] = "\n".join(arg[2:]) conf.simple_conf_handler("DataCache", _set_datacache) conf.simple_conf_handler("JudgeId", _set_id) conf.register_handler("SetInfo", _ch_set_info)
if len(args) == 1: raise conf.UserError( "Option {0} must be specified in the configuration file.".format( args[0])) _Executor(args) def _ch_add_lang(args): if len(args) == 1: raise conf.UserError( "Option {0} must be specified in the configuration file.".format( args[0])) _Lang(args) conf.register_handler("AddExecutor", _ch_add_executor) conf.register_handler("AddLang", _ch_add_lang) def _set_chroot_dir(arg): if len(arg) == 2: global _cmd_vars, _dir_temp if _dir_temp: raise conf.UserError( "Option {0} must be set before TempDir".format(arg[0])) if not os.path.isabs(arg[1]): raise conf.UserError( "Option {0} takes an absolute path as argument".format(arg[0])) _cmd_vars["CHROOT_DIR"] = arg[1]
daemon.pid_end() try: work.connect(s) except work.Error: log.error("error occurred, terminating program") daemon.pid_end() def _ch_server_addr(arg): if len(arg) == 1: raise conf.UserError( "Option {0} must be specified in the configuration file".format( arg[0])) if len(arg) != 3: raise conf.UserError("Option {0} takes two arguments".format(arg[0])) global _server_addr, _server_port _server_addr = arg[1] _server_port = int(arg[2]) if _server_port <= 0 or _server_port > 65535: raise conf.UserError("port must be between 0 and 65536") def _set_umask(arg): os.umask(int(arg[1], 8)) conf.register_handler("ServerAddr", _ch_server_addr) conf.simple_conf_handler("SetUmask", _set_umask, required=False)
def _set_cert_file(arg): global _cert_file _cert_file = arg[1] def _set_key_file(arg): global _key_file _key_file = arg[1] def _set_ca_file(arg): global _ca_file _ca_file = arg[1] conf.register_handler("UseIPv6", _ch_set_ipv6) conf.simple_conf_handler("NetworkTimeout", _set_timeout, default="30") conf.simple_conf_handler("CertificateFile", _set_cert_file) conf.simple_conf_handler("PrivateKeyFile", _set_key_file) conf.simple_conf_handler("CAFile", _set_ca_file) def _init(): if struct.calcsize("i") != 4 or struct.calcsize("I") != 4: sys.exit("standard size of integer or unsigned integer is not 4-byte!") conf.register_init_func(_init)