diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index 2b37b9837..4a4241ade 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -1,7 +1,7 @@ { "name": "@hydrooj/hydrojudge", "bin": "bin/hydrojudge.js", - "version": "2.11.4", + "version": "2.11.5", "main": "package.json", "author": "undefined ", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/hydrojudge/src/checkers.ts b/packages/hydrojudge/src/checkers.ts index e7b418664..ac9e41423 100644 --- a/packages/hydrojudge/src/checkers.ts +++ b/packages/hydrojudge/src/checkers.ts @@ -1,7 +1,7 @@ /* eslint-disable no-template-curly-in-string */ +import { STATUS } from '@hydrooj/utils/lib/status'; import { SystemError } from './error'; import { run } from './sandbox'; -import * as STATUS from './status'; import { parse } from './testlib'; interface CheckResult { diff --git a/packages/hydrojudge/src/compile.ts b/packages/hydrojudge/src/compile.ts index 8deb8939b..dd61edc03 100644 --- a/packages/hydrojudge/src/compile.ts +++ b/packages/hydrojudge/src/compile.ts @@ -1,8 +1,8 @@ import { LangConfig } from '@hydrooj/utils/lib/lang'; +import { STATUS } from '@hydrooj/utils/lib/status'; import { CompileError } from './error'; import { Execute } from './interface'; import { del, run } from './sandbox'; -import * as STATUS from './status'; import { compilerText } from './utils'; export = async function compile( diff --git a/packages/hydrojudge/src/hosts/hydro.ts b/packages/hydrojudge/src/hosts/hydro.ts index 8c1a94204..c173cb64e 100644 --- a/packages/hydrojudge/src/hosts/hydro.ts +++ b/packages/hydrojudge/src/hosts/hydro.ts @@ -8,12 +8,12 @@ import { ObjectID } from 'mongodb'; import PQueue from 'p-queue'; import WebSocket from 'ws'; import { LangConfig } from '@hydrooj/utils/lib/lang'; +import { STATUS } from '@hydrooj/utils/lib/status'; import readCases from '../cases'; import { getConfig } from '../config'; import { CompileError, FormatError, SystemError } from '../error'; import judge from '../judge'; import log from '../log'; -import { STATUS_COMPILE_ERROR, STATUS_SYSTEM_ERROR } from '../status'; import * as sysinfo from '../sysinfo'; import * as tmpfs from '../tmpfs'; import { @@ -78,19 +78,19 @@ class JudgeTask { if (e instanceof CompileError) { this.next({ compiler_text: compilerText(e.stdout, e.stderr) }); this.end({ - status: STATUS_COMPILE_ERROR, score: 0, time_ms: 0, memory_kb: 0, + status: STATUS.STATUS_COMPILE_ERROR, score: 0, time_ms: 0, memory_kb: 0, }); } else if (e instanceof FormatError) { this.next({ judge_text: 'Testdata configuration incorrect.' }); this.next({ judge_text: { message: e.message, params: e.params } }); this.end({ - status: STATUS_SYSTEM_ERROR, score: 0, time_ms: 0, memory_kb: 0, + status: STATUS.STATUS_FORMAT_ERROR, score: 0, time_ms: 0, memory_kb: 0, }); } else { log.error(e); this.next({ message: { message: e.message, params: e.params || [], ...argv.options.debug ? { stack: e.stack } : {} } }); this.end({ - status: STATUS_SYSTEM_ERROR, score: 0, time_ms: 0, memory_kb: 0, + status: STATUS.STATUS_SYSTEM_ERROR, score: 0, time_ms: 0, memory_kb: 0, }); } } finally { diff --git a/packages/hydrojudge/src/judge/default.ts b/packages/hydrojudge/src/judge/default.ts index 3a3bc9ce2..1d5f69429 100644 --- a/packages/hydrojudge/src/judge/default.ts +++ b/packages/hydrojudge/src/judge/default.ts @@ -1,13 +1,13 @@ import path from 'path'; import fs from 'fs-extra'; import Queue from 'p-queue'; +import { STATUS } from '@hydrooj/utils/lib/status'; import { check, compileChecker } from '../check'; import compile from '../compile'; import { getConfig } from '../config'; import { CompileError, SystemError } from '../error'; import { run } from '../sandbox'; import signals from '../signals'; -import * as STATUS from '../status'; import { parseFilename } from '../utils'; const Score = { diff --git a/packages/hydrojudge/src/judge/hack.ts b/packages/hydrojudge/src/judge/hack.ts index 5291623d1..cc39baacd 100644 --- a/packages/hydrojudge/src/judge/hack.ts +++ b/packages/hydrojudge/src/judge/hack.ts @@ -1,12 +1,12 @@ // Not implemented import path from 'path'; import fs from 'fs-extra'; +import { STATUS } from '@hydrooj/utils/lib/status'; import { check, compileChecker } from '../check'; import compile from '../compile'; import { CompileError } from '../error'; import { run } from '../sandbox'; import signals from '../signals'; -import * as STATUS from '../status'; import { copyInDir, parseFilename } from '../utils'; export const judge = async (ctx) => { diff --git a/packages/hydrojudge/src/judge/interactive.ts b/packages/hydrojudge/src/judge/interactive.ts index d35516dba..42d335475 100644 --- a/packages/hydrojudge/src/judge/interactive.ts +++ b/packages/hydrojudge/src/judge/interactive.ts @@ -1,10 +1,10 @@ import fs from 'fs-extra'; import Queue from 'p-queue'; +import { STATUS } from '@hydrooj/utils/lib/status'; import compile from '../compile'; import { getConfig } from '../config'; import { run } from '../sandbox'; import signals from '../signals'; -import * as STATUS from '../status'; import { parse } from '../testlib'; import { findFileSync, parseFilename } from '../utils'; diff --git a/packages/hydrojudge/src/judge/run.ts b/packages/hydrojudge/src/judge/run.ts index 15171a020..164ff1f16 100644 --- a/packages/hydrojudge/src/judge/run.ts +++ b/packages/hydrojudge/src/judge/run.ts @@ -1,10 +1,10 @@ import path from 'path'; import fs from 'fs-extra'; +import { STATUS } from '@hydrooj/utils/lib/status'; import compile from '../compile'; import { CompileError } from '../error'; import { run } from '../sandbox'; import signals from '../signals'; -import * as STATUS from '../status'; import { compilerText, parseMemoryMB, parseTimeMS } from '../utils'; export const judge = async (ctx) => { diff --git a/packages/hydrojudge/src/judge/submit_answer.ts b/packages/hydrojudge/src/judge/submit_answer.ts index 7162c6b17..7a724fbec 100644 --- a/packages/hydrojudge/src/judge/submit_answer.ts +++ b/packages/hydrojudge/src/judge/submit_answer.ts @@ -1,4 +1,4 @@ -import * as STATUS from '../status'; +import { STATUS } from '@hydrooj/utils/lib/status'; export async function judge({ next, end, config, code, diff --git a/packages/hydrojudge/src/sandbox.ts b/packages/hydrojudge/src/sandbox.ts index 7055ae508..69e851c07 100644 --- a/packages/hydrojudge/src/sandbox.ts +++ b/packages/hydrojudge/src/sandbox.ts @@ -1,10 +1,10 @@ import Axios from 'axios'; import cac from 'cac'; import fs from 'fs-extra'; +import { STATUS } from '@hydrooj/utils/lib/status'; import { getConfig } from './config'; import { FormatError, SystemError } from './error'; import { Logger } from './log'; -import * as STATUS from './status'; import { cmd, parseMemoryMB } from './utils'; const argv = cac().parse(); @@ -111,7 +111,7 @@ export async function runMultiple(execute) { if (argv.options.showSandbox) logger.debug('%d %s', id, JSON.stringify(res.data)); } catch (e) { if (e instanceof FormatError) throw e; - throw new SystemError('Sandbox Error'); + throw new SystemError('Sandbox Error', [e]); } return await Promise.all(res.data.map((i) => adaptResult(i, {}))); } diff --git a/packages/hydrojudge/src/service.ts b/packages/hydrojudge/src/service.ts index d152c970f..e760e5108 100644 --- a/packages/hydrojudge/src/service.ts +++ b/packages/hydrojudge/src/service.ts @@ -6,12 +6,12 @@ import path from 'path'; import fs from 'fs-extra'; import { noop } from 'lodash'; import { ObjectID } from 'mongodb'; +import { STATUS } from '@hydrooj/utils/lib/status'; import { Logger } from 'hydrooj/src/logger'; import * as monitor from 'hydrooj/src/service/monitor'; import readCases from './cases'; import { getConfig } from './config'; import { CompileError, FormatError, SystemError } from './error'; -import { STATUS_COMPILE_ERROR, STATUS_SYSTEM_ERROR } from './status'; import * as sysinfo from './sysinfo'; import * as tmpfs from './tmpfs'; import { compilerText, md5 } from './utils'; @@ -207,18 +207,18 @@ async function postInit() { if (e instanceof CompileError) { this.next({ compiler_text: compilerText(e.stdout, e.stderr) }); this.end({ - status: STATUS_COMPILE_ERROR, score: 0, time_ms: 0, memory_kb: 0, + status: STATUS.STATUS_COMPILE_ERROR, score: 0, time_ms: 0, memory_kb: 0, }); } else if (e instanceof FormatError) { this.next({ message: { message: e.message, params: e.params } }); this.end({ - status: STATUS_SYSTEM_ERROR, score: 0, time_ms: 0, memory_kb: 0, + status: STATUS.STATUS_FORMAT_ERROR, score: 0, time_ms: 0, memory_kb: 0, }); } else { logger.error(e); this.next({ message: { message: e.message, params: e.params, ...process.env.DEV ? { stack: e.stack } : {} } }); this.end({ - status: STATUS_SYSTEM_ERROR, score: 0, time_ms: 0, memory_kb: 0, + status: STATUS.STATUS_SYSTEM_ERROR, score: 0, time_ms: 0, memory_kb: 0, }); } } diff --git a/packages/hydrojudge/src/status.ts b/packages/hydrojudge/src/status.ts deleted file mode 100644 index 56a955aa5..000000000 --- a/packages/hydrojudge/src/status.ts +++ /dev/null @@ -1,33 +0,0 @@ -export const STATUS_WAITING = 0; -export const STATUS_ACCEPTED = 1; -export const STATUS_WRONG_ANSWER = 2; -export const STATUS_TIME_LIMIT_EXCEEDED = 3; -export const STATUS_MEMORY_LIMIT_EXCEEDED = 4; -export const STATUS_OUTPUT_LIMIT_EXCEEDED = 5; -export const STATUS_RUNTIME_ERROR = 6; -export const STATUS_COMPILE_ERROR = 7; -export const STATUS_SYSTEM_ERROR = 8; -export const STATUS_CANCELED = 9; -export const STATUS_ETC = 10; -export const STATUS_JUDGING = 20; -export const STATUS_COMPILING = 21; -export const STATUS_FETCHED = 22; -export const STATUS_IGNORED = 30; - -export const STATUS_TEXTS = { - [STATUS_WAITING]: 'Waiting', - [STATUS_ACCEPTED]: 'Accepted', - [STATUS_WRONG_ANSWER]: 'Wrong Answer', - [STATUS_TIME_LIMIT_EXCEEDED]: 'Time Exceeded', - [STATUS_MEMORY_LIMIT_EXCEEDED]: 'Memory Exceeded', - [STATUS_OUTPUT_LIMIT_EXCEEDED]: 'Output Exceeded', - [STATUS_RUNTIME_ERROR]: 'Runtime Error', - [STATUS_COMPILE_ERROR]: 'Compile Error', - [STATUS_SYSTEM_ERROR]: 'System Error', - [STATUS_CANCELED]: 'Cancelled', - [STATUS_ETC]: 'Unknown Error', - [STATUS_JUDGING]: 'Running', - [STATUS_COMPILING]: 'Compiling', - [STATUS_FETCHED]: 'Fetched', - [STATUS_IGNORED]: 'Ignored', -}; diff --git a/packages/hydrojudge/src/testlib.ts b/packages/hydrojudge/src/testlib.ts index 410260fbb..ee6d3a281 100644 --- a/packages/hydrojudge/src/testlib.ts +++ b/packages/hydrojudge/src/testlib.ts @@ -1,9 +1,9 @@ -import * as STATUS from './status'; +import { STATUS } from '@hydrooj/utils/lib/status'; export function parse(output: string, fullscore: number) { let status = STATUS.STATUS_WRONG_ANSWER; let score = 0; - let message = output; + let message = output.substr(0, 1024); if (output.startsWith('ok ')) { status = STATUS.STATUS_ACCEPTED; score = fullscore; @@ -13,19 +13,18 @@ export function parse(output: string, fullscore: number) { message = `PE ${output.split('wrong output format ')[1] || ''}`; } else if (output.startsWith('partially correct ')) { message = `PC ${output.split('partially correct ')[1] || ''}`; - const p = +output.split('partially correct (')[1].split(')')[0]; - score = Math.floor(fullscore * (p / 200)); + let p = +output.split('partially correct (')[1].split(')')[0] || 0; + if (p > 1) p /= 100; + score = Math.floor(fullscore * p); } else if (output.startsWith('points ')) { - const p = +output.split('points ')[1].split(' ')[0]; - if (p === 100) { + let p = +output.split('points ')[1].split(' ')[0] || 0; + if (p > 1) p /= 100; + if (p === 1) { status = STATUS.STATUS_ACCEPTED; score = fullscore; const base = output.split('points ')[1] || ''; message = base.substr(base.indexOf(' '), 1024); - } else { - message = `partially correct ${output.split('points ')[1] || ''}`; - score = Math.floor(fullscore * (p / 100)); - } + } else score = Math.floor(fullscore * p); } return { status, score, message }; } diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index 5bd83edfc..54cffb4d7 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -89,7 +89,7 @@ "tether": "^1.4.7", "tether-drop": "^1.4.2", "through2": "^4.0.2", - "timeago-react": "^3.0.3", + "timeago-react": "^3.0.4", "timeago.js": "^4.0.2", "vditor": "^3.8.7", "vinyl-buffer": "^1.0.1", @@ -101,7 +101,7 @@ "webpackbar": "^5.0.0-3" }, "dependencies": { - "esbuild": "^0.12.28", + "esbuild": "^0.12.29", "js-yaml": "^4.1.0", "jsesc": "^3.0.2", "katex": "^0.13.18", diff --git a/packages/utils/package.json b/packages/utils/package.json index 8e3fd5928..64f7535a4 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -15,7 +15,7 @@ "systeminformation": "^5.9.3" }, "devDependencies": { - "@types/fs-extra": "^9.0.12", + "@types/fs-extra": "^9.0.13", "moment-timezone": "^0.5.33" } } diff --git a/packages/vjudge/package.json b/packages/vjudge/package.json index 84fdb03a5..7c77023c9 100644 --- a/packages/vjudge/package.json +++ b/packages/vjudge/package.json @@ -16,8 +16,8 @@ }, "devDependencies": { "@types/jsdom": "^16.2.13", - "@types/lodash": "^4.14.172", - "@types/superagent": "^4.1.12", + "@types/lodash": "^4.14.173", + "@types/superagent": "^4.1.13", "@types/superagent-proxy": "^2.0.1" } }