🆕 系统状态,修复题目复制

This commit is contained in:
undefined committed 2020-08-09 21:01:36 +08:00
1 parent 933dc73162
commit 3cb4d2ad49
19 files changed
+67 -30

No files matched your search

+1 -1
View File
@@ -147,7 +147,7 @@ async function readAutoCases(folder, { next }) {
let result = await read0(folder, files, checkFile);
if (!result.count) result = await read1(folder, files, checkFile);
Object.assign(config, result);
next({ judge_text: `识别到${config.count}个测试点` });
next({ message: `识别到${config.count}个测试点` });
} catch (e) {
throw new SystemError('在自动识别测试点的过程中出现了错误。', [e]);
}
+2 -2
View File
@@ -77,7 +77,7 @@ function judgeCase(c) {
score: 0,
time_ms: time_usage_ms,
memory_kb: memory_usage_kb,
judge_text: message,
message,
},
progress: Math.floor((c.id * 100) / ctx.config.count),
}, c.id);
@@ -144,7 +144,7 @@ export const judge = async (ctx) => {
for (const sid in ctx.config.subtasks) tasks.push(judgeSubtask(ctx.config.subtasks[sid])(ctx));
await Promise.all(tasks);
ctx.stat.done = new Date();
ctx.next({ judge_text: JSON.stringify(ctx.stat) });
ctx.next({ message: JSON.stringify(ctx.stat) });
ctx.end({
status: ctx.total_status,
score: ctx.total_score,
+3 -3
View File
@@ -39,7 +39,7 @@ function judgeCase(c) {
status = STATUS.STATUS_RUNTIME_ERROR;
if (code < 32) message = signals[code];
else message = `您的程序返回了 ${code}.`;
} else [status, score, message] = resInteractor.files.stderr.split('\n');
} else[status, score, message] = resInteractor.files.stderr.split('\n');
ctxSubtask.score = Score[ctxSubtask.subtask.type](ctxSubtask.score, score);
ctxSubtask.status = Math.max(ctxSubtask.status, status);
ctx.total_time_usage_ms += time_usage_ms;
@@ -51,7 +51,7 @@ function judgeCase(c) {
score: 0,
time_ms: time_usage_ms,
memory_kb: memory_usage_kb,
judge_text: message,
message,
},
progress: Math.floor((c.id * 100) / ctx.config.count),
});
@@ -110,7 +110,7 @@ export const judge = async (ctx) => {
}
await Promise.all(tasks);
ctx.stat.done = new Date();
ctx.next({ judge_text: JSON.stringify(ctx.stat) });
ctx.next({ message: JSON.stringify(ctx.stat) });
console.log({
status: ctx.total_status,
score: ctx.total_score,
+2 -2
View File
@@ -48,11 +48,11 @@ export const judge = async (ctx) => {
status,
time_ms: time_usage_ms,
memory_kb: memory_usage_kb,
judge_text: message,
message,
},
});
ctx.stat.done = new Date();
ctx.next({ judge_text: JSON.stringify(ctx.stat) });
ctx.next({ message: JSON.stringify(ctx.stat) });
ctx.end({
status,
score: status === STATUS.STATUS_ACCEPTED ? 100 : 0,
@@ -16,7 +16,7 @@ export async function judge({
status,
progress: 100,
case: {
status, score, time_ms: 0, memory_kb: 0, judge_text: message,
status, score, time_ms: 0, memory_kb: 0, message,
},
});
end({
+1
View File
@@ -78,6 +78,7 @@ export async function del(fileId) {
export async function run(execute, params?) {
let result;
global.reqCount++;
// eslint-disable-next-line no-return-await
if (typeof execute === 'object') return await runMultiple(execute);
try {
+18 -7
View File
@@ -38,10 +38,10 @@ int main(){
},
stat: {},
clean: [],
next: () => { },
end: (data) => {
if (data.stdout) output = data.stdout;
next: (data) => {
if (data.case) output = data.case.message;
},
end: () => { },
};
context.tmpdir = path.resolve(tmpdir(), 'hydro', 'tmp', 'sysinfo');
fs.ensureDirSync(context.tmpdir);
@@ -52,7 +52,7 @@ int main(){
tmpfs.umount(context.tmpdir);
fs.removeSync(context.tmpdir);
const a = output.split(' ');
return parseInt(a[a.length - 1], 10);
return parseInt(a[a.length - 2], 10);
}
export async function get() {
@@ -84,11 +84,20 @@ export async function get() {
cache.flags = flags;
cache.mid = mid;
cache.stack = stack;
global.reqCount = 0;
return {
mid, cpu, memory, osinfo, load, flags, CpuTemp, battery, stack,
mid, cpu, memory, osinfo, load, flags, CpuTemp, battery, stack, reqCount: 0,
};
}
declare global {
namespace NodeJS {
interface Global {
reqCount: number,
}
}
}
export async function update() {
const [Memory, CurrentLoad, CpuTemp, Battery] = await Promise.all([
systeminformation.mem(),
@@ -104,13 +113,15 @@ export async function update() {
let battery;
if (!Battery.hasbattery) battery = 'No battery';
else battery = `${Battery.type} ${Battery.model} ${Battery.percent}%${Battery.ischarging ? ' Charging' : ''}`;
const reqCount = global.reqCount;
global.reqCount = 0;
return [
mid,
{
memory, load, battery, CpuTemp,
memory, load, battery, CpuTemp, reqCount,
},
{
mid, cpu, memory, osinfo, load, flags, battery, CpuTemp, stack,
mid, cpu, memory, osinfo, load, flags, battery, CpuTemp, stack, reqCount,
},
];
}