function judge_a_single_submission() { // Clear all caches, otherwise we would use old data! Entity::clear_cache(); // Retrieve a submission global $self; $subm = Submission::get_pending_submission($self->name . micro_nonce()); if (!$subm) { // no submissions right now sleep(DAEMON_SLEEP_TIME); return; } // Some information on this submission if (VERBOSE) { echo "\n"; echo "Submission id: ", $subm->submissionid, "\n"; echo "Submission to: ", $subm->entity_path, "\n"; echo "Submited on: ", format_date($subm->time), "\n"; echo "Submission by: ", User::names_text($subm->users()), "\n"; // this slows things down } // Let's judge it try { $judgement = new SubmissionJudgement($subm); $judgement->judge(); } catch (Exception $e) { Log::error($e, $subm->entity_path, $self->name); echo "Error during judging!\n", $e; } if (VERBOSE) { echo "Result: ", Status::to_text($subm), "\n"; } // free up some memory unset($judgement); unset($subm); if (function_exists('gc_collect_cycles')) { // this doesn't exist in PHP < 5.3.0 :( gc_collect_cycles(); } if (VERBOSE) { echo "Memory usage: ", memory_get_usage(), "\n"; } }
$submissionid = $_SERVER['argv'][1]; } try { // Retrieve the submission $subm = Submission::by_id($submissionid); // Some information on this submission echo "\n"; echo "Submission id: ", $subm->submissionid, "\n"; echo "Submission to: ", $subm->entity_path, "\n"; echo "Submited on: ", format_date($subm->time), "\n"; echo "Submission by: ", User::names_text($subm->users()), "\n"; // this slows things down echo "\n"; // Let's judge it try { $judgement = new SubmissionJudgement($subm); $judgement->judge(false); } catch (Exception $e) { echo "Error during judging!\n", $e; } echo "\n"; echo "Source files: ", implode("\n ", $judgement->get_source_file_names()), "\n"; echo "Exe file: ", $judgement->get_exe_file_name(), "\n"; echo "Tempdir: ", $judgement->get_and_keep_tempdir(), "\n"; echo "\n"; echo "Done. The tempdir contains all files created and used during judging."; // clean up $judgement->__destruct(); } catch (Exception $e) { echo $e->getMessage(), "\n\n"; echo "Stack trace:\n";