From: Martin Mares Date: Sat, 16 Apr 2005 12:53:32 +0000 (+0000) Subject: ... X-Git-Tag: python-dummy-working~434 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=de15df375f37669bf6db86fd46ec98fe03c16167;p=moe.git ... --- diff --git a/bin/mo-backup b/bin/mo-backup index 01d53c0..dbdac2d 100755 --- a/bin/mo-backup +++ b/bin/mo-backup @@ -1,7 +1,11 @@ #!/bin/sh -D=back/`date '+%H%M'` +if [ -z "$1" ] ; then + D=back/`date '+%H%M'` +else + D=$1 +fi mkdir -p $D -for m in mo1{01,02,03,04,05} mo2{01,02,03,04,05,06,07,08,09,10,11,12,13,14} mo3{01,02,03,04,05,06,07,08} mo4{01,02,03,04,05,06} ; do +for m in mo0{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15} mo1{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,99} ; do echo -n "$m: " mkdir $p $D/$m pushd $D/$m >/dev/null diff --git a/bin/mo-cycle b/bin/mo-cycle new file mode 100755 index 0000000..14c7a01 --- /dev/null +++ b/bin/mo-cycle @@ -0,0 +1,27 @@ +#!/bin/sh + +rm -rf solutions/mo* testing/mo* + +for m in mo0{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15} mo1{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,99} ; do + u=`echo $m | sed 's/^mo099/00/;s/^mo199/39/;s/^mo0//;s/^mo10/2/;s/^mo11/3/;s/^/mo/'` + echo -n "$m ($u): " + rm -rf tmp/grab + mkdir tmp/grab + pushd tmp/grab >/dev/null + ssh root@$m 'cd /aux/mo/users/mo39/mo39 ; tar czf - .' | tar xzf - + popd >/dev/null + if [ -d tmp/grab/.submit ] ; then + if [ -d solutions/$u ] ; then + echo -n "" + else + cp -a tmp/grab/.submit solutions/$u + ( cd solutions/$u && ls ) + fi + fi + echo +done +bin/mo-ev-all fact power +bin/mo-score-hack --detail --html power fact >cycle.results.html +lynx -width 100 -dump cycle.results.html | sed '1,3d' >cycle.results.new +cat cycle.results.new | ssh root@mo101 'cat >/tmp/cycle.results.new && mv /tmp/cycle.results.new /tmp/cycle.results' +mv cycle.results.new cycle.results diff --git a/bin/mo-score2005 b/bin/mo-score2005 new file mode 100755 index 0000000..381bc50 --- /dev/null +++ b/bin/mo-score2005 @@ -0,0 +1,138 @@ +#!/usr/bin/perl + +$tex = 0; +$usage = "Usage: mo-score2004 [--tex] theoretical_tasks_nr praxis_tasks_nr task1 task2 ..."; +while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) { + shift @ARGV; + $var = "\$$1"; + if (!eval "defined $var") { die $usage; } + eval "$var = 1;"; +} +@ARGV >=2 || die $usage; +$theory=shift @ARGV; +$praxis=shift @ARGV; +@ARGV >= $praxis || die $usage; +$pos_delim=$tex ? '--' : '-'; + +print STDERR "Scanning contestants... "; +open (CT, "bin/mo-get-users --full |") || die "Cannot get list of contestants"; +while () { + chomp; + ($u,$f) = split /\t/; + ($u eq "somebody") && next; + $users{$u}=$f; +} +close CT; +print STDERR 0+keys %users, "\n"; + +print STDERR "Scanning teoretical results... "; +if (open (EX, "teorie.txt")) { + while () { + chomp; + (/^$/ || /^#/) && next; + @a = split /\ *\t\ */; + $u = shift @a; + defined $users{$u} || die "Unknown user $u"; + $names{$u} = shift @a; + $forms{$u} = shift @a; + $addresses{$u} = "{". (shift @a) ."}"; + $i=0; + while (@a) { $tasks{$u}{$i} = shift @a;$i++; } + } + close EX; + print STDERR "OK\n"; +} else {die "none\n";} + +print STDERR "Scanning task results... "; +$need_tasks = join("|", @ARGV); +foreach $u (keys %users) { + opendir (D, "testing/$u") or next; + foreach $t (readdir(D)) { + $t =~ /^\./ && next; + $t =~ /$need_tasks/ || next; + + $t_num=$praxis; + for (my $t_num2=0;$t_num2<@ARGV;$t_num2++) {if ($t eq $ARGV[$t_num2]) {$t_num=$t_num2;}} + $t_num+=$theory; + + $tt = "testing/$u/$t/points"; + -f $tt || next; + print STDERR "$u/$t "; + open (X, $tt) || die "Unable to open $tt"; + while () { + chomp; + /^\S+ (-?\d+)/ || die "Parse error: $_"; + $tasks{$u}{$t_num} += $1; + } + close X; + } + closedir D; +} +print STDERR "OK\n"; + +print STDERR "Creating table template... "; +@body = ('','$names{$u}','$forms{$u}','$addresses{$u}'); +for ($a=0;$a<$theory+$praxis;$a++) {push @body,"\$tasks{\$u}{$a}";} +print STDERR "OK\n"; + +print STDERR "Filling in results... "; +@table = (); +foreach $u (keys %users) { + $row = []; + $row_index=0; + $row_sum=0; + foreach my $c (@body) { + $c =~ s/\$(\d+)/\$\$row[$1]/g; + $x = eval $c; + push @$row, (defined $x ? $x : '-'); + if ($row_index>3) { + if ((defined $x) && ($x>0)) {$row_sum+=$x;} + } + $row_index++; + } + push @$row, $row_sum; + push @table, $row; +} +print STDERR "OK\n"; + +print STDERR "Sorting... "; +$sortcol = @{$table[0]} - 1; +$namecol = 1; +@table = sort { + my $p, $an, $bn; + $p = $$b[$sortcol] <=> $$a[$sortcol]; + ($an = $$a[$namecol]) =~ s/(\S+)\s+(\S+)/$2 $1/; + ($bn = $$b[$namecol]) =~ s/(\S+)\s+(\S+)/$2 $1/; + $p ? $p : ($an cmp $bn); +} @table; +$i=0; +while ($i < @table) { + $j = $i; + while ($i < @table && ${$table[$i]}[$sortcol] == ${$table[$j]}[$sortcol]) { + $i++; + } + if ($i == $j+1) { + ${table[$j]}[0] = "$i."; + } else { + ${table[$j]}[0] = $j+1 . '.' . $pos_delim . $i . "."; + $j_old=$j; + $j++; + while ($j < $i) { ${table[$j++]}[0] = $j_old+1 . '.' . $pos_delim . $i . "."; }; + } +} +print STDERR "OK\n"; + +if ($tex) { + open HDR,"teorie.hdr" or die "Cannot open file teorie.hdr with TeX template!"; + while () {print; } + close HDR; + + foreach $r (@table) { print join('&',@$r), "\\cr\n";} + +print '}}} + +\bye +'; +} else { + foreach $r (@table) { print join("\t",@$r), "\n"; } +}