]> mj.ucw.cz Git - eval.git/blobdiff - submit/contest
Logfile of submit and check renamed to `check-log' to prevent collisions.
[eval.git] / submit / contest
index 0246cadf680d33b4793d61b08750928d147cb435..3f9e6c39af4936fe5035dbded64bfe43894d0950 100755 (executable)
@@ -8,7 +8,7 @@ use warnings;
 BEGIN {
        defined $ENV{"MO_ROOT"} or die "Please set MO_ROOT to the contest root directory first.\n";
 }
-use lib $ENV{"MO_ROOT"} . "/submit";
+use lib $ENV{"MO_ROOT"} . "/lib/perl5";
 use lib $ENV{"MO_ROOT"} . "/submit/lib/perl5";
 
 use MO::Submit;
@@ -159,7 +159,7 @@ sub start_refresh_timer($) {
        my ($go) = @_;
        stop_refresh_timer();
        refresh() if $go;
-       $refresh_timer_id = Glib::Timeout->add(5000, \&timed_refresh);
+       $refresh_timer_id = Glib::Timeout->add($conn->{"RefreshTimer"}, \&timed_refresh);
 }
 
 sub stop_refresh_timer() {
@@ -308,8 +308,19 @@ sub submit_failed($) {
 }
 
 sub run_submit() {
+       my ($task, $part) = split /\//, $selected_task;
+       defined $part or $part = $task;
+
+       if (defined $conn->{"History"}) {
+               busy("Submitting locally to " . $conn->{"History"});
+               my $err = $conn->local_submit($task, $part, $submit_extension, $submit_filename);
+               if (defined $err) {
+                       submit_failed("Recording to local history failed\n($err)");
+                       return;
+               }
+       }
+
        if ($conn->is_connected) {
-               ### FIXME: Busy cursor should be started earlier
                busy("Checking server status...");
                my $r = new Sherlock::Object("!" => "STATUS");  ### FIXME: use a NOP command
                $r = $conn->request($r);
@@ -319,13 +330,11 @@ sub run_submit() {
                if (!$conn->connect) {
                        ready($conn->{"error"});
                        submit_failed("Unable to connect to the server");       ### FIXME: Mention local submit
+                       return;
                }
        }
        busy("Submitting...");
 
-       my ($task, $part) = split /\//, $selected_task;
-       defined $part or $part = $task;
-
        my $fh = new IO::File($submit_filename);
        if (!$fh) {
                submit_failed("Unable to open $submit_filename\n($!)");
@@ -373,8 +382,15 @@ sub checks_failed($) {
        $text_view->set_editable(0);
        $text_view->set_cursor_visible(0);
 
+       my $text_scroll = Gtk2::ScrolledWindow->new;
+       $text_scroll->set_policy("automatic", "automatic");
+       $text_scroll->add($text_view);
+
+       my $text_frame = Gtk2::Frame->new("Checker log");
+       $text_frame->add($text_scroll);
+
        $submitting_label->destroy;
-       $subwin_vbox->pack_start_defaults($text_view);
+       $subwin_vbox->pack_start_defaults($text_frame);
 
        finish_submit();
 }
@@ -406,9 +422,19 @@ sub run_checks() {
                checks_failed("The filename does not have a valid extension");
                return;
        }
-       sleep 1;
-       #checks_failed("One\nTwo\nThree...\n");
-       checks_ok();
+       if (!$conn->{"Checks"}) {
+               checks_ok();
+               return;
+       }
+       my $root = $conn->{"root"};
+       my ($task, $part) = split /\//, $selected_task;
+       defined $part or $part = "";
+       my $verdict = `$root/bin/check -s "$submit_filename" $task $part 2>&1`;
+       if ($?) {
+               checks_failed($verdict);
+       } else {
+               checks_ok();
+       }
 }
 
 sub do_submit() {