From a1e0e62b9cff5aa233cce0215bacf759bf670eac Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sat, 28 Sep 2013 11:15:31 +0200 Subject: [PATCH 001/137] Check IP in gl-pre-git hook --- hooks/gl-pre-git | 38 ++++++++++++++++++ hooks/submissions.pl | 96 ++++++++++++++++++-------------------------- 2 files changed, 76 insertions(+), 58 deletions(-) create mode 100755 hooks/gl-pre-git diff --git a/hooks/gl-pre-git b/hooks/gl-pre-git new file mode 100755 index 0000000..97946b3 --- /dev/null +++ b/hooks/gl-pre-git @@ -0,0 +1,38 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use v5.10; +use File::Basename; +use Net::IP; + +use ACU::Log; +$ACU::Log::log_file = "/var/log/hooks/" . basename($0) . ".log"; + +# First, check if the repository is in the YYYY/ directory +exit 0 if ($ENV{GL_REPO} !~ /^2[0-9]{3}\/.+\/.+/); + + +my $ip = $1 if ($ENV{'SSH_CLIENT'} =~ m/([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*/); +say "Votre IP est : $ip."; + +$ip = Net::IP->new($ip) or die ("IP invalide"); + +my $schoolnetwork = Net::IP->new('192.168.0.0/16'); + +if ($ip->overlaps($schoolnetwork) != $IP_A_IN_B_OVERLAP) +{ + log ERROR, "Vous n'êtes pas autorisé à envoyer vos modifications depuis cette IP."; + exit 1; +} + +my $sshnetwork = Net::IP->new('10.41.253.0/24'); + +if ($ip->overlaps($sshnetwork) == $IP_A_IN_B_OVERLAP) +{ + log ERROR, "Vous n'êtes pas autorisé à envoyer vos modifications depuis cette IP."; + exit 1; +} + + +exit 0; diff --git a/hooks/submissions.pl b/hooks/submissions.pl index b51e278..3032555 100755 --- a/hooks/submissions.pl +++ b/hooks/submissions.pl @@ -3,8 +3,10 @@ use strict; use warnings; use v5.10; -use Date::Manip; +use DateTime::Format::ISO8601; use File::Basename; +use Net::IP; +use POSIX qw(strftime); use Socket; use ACU::API::Projects; @@ -28,29 +30,6 @@ if ($ref =~ m<^refs/tags/(.+)$>) my $tag = $1; log DEBUG, "Pushed tag for repository $ENV{GL_REPO}: $tag with IP $ENV{'SSH_CLIENT'}"; - my $ip = $1 if ($ENV{'SSH_CLIENT'} =~ m/([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*/); - say "[ACU] Your IP is: $ip."; - - $ip = ip2long($ip); - - my $net = ip2long("10.41.0.0"); - my $mask = ip2long("255.255.0.0"); - - if (($ip & $mask) != ($net & $mask)) - { - log ERROR, "[ACU] You are not authorized to push from this IP. This will be reported."; - exit 1; - } - - $net = ip2long("10.41.253.0"); - $mask = ip2long("255.255.255.0"); - - if (($ip & $mask) == ($net & $mask)) - { - log ERROR, "[ACU] You are not authorized to push from this IP. This will be reported."; - exit 1; - } - # Get project informations my $project; eval { @@ -71,64 +50,65 @@ if ($ref =~ m<^refs/tags/(.+)$>) exists $_->{vcs} and $_->{vcs}{tag} eq $tag; } @{ $project->{submissions} }; - my $date = $ENV{'GL_TS'}; - $date =~ s/\./ /; - my $glts = ParseDate($date); + my $glts = DateTime::Format::ISO8601->parse_datetime( + do { + my $t = $ENV{'GL_TS'}; + $t =~ tr/./T/; + $t + }); chomp (my $tokengiven = `git cat-file tag $newsha 2> /dev/null | sed -e '1,/^\$/d'`); for my $rendu (@rendus) { - my $open = ParseDate($rendu->{period}{begin}); - my $close = ParseDate($rendu->{period}{end}); + my $open = DateTime::Format::ISO8601->parse_datetime($rendu->{period}{begin}); + my $close = DateTime::Format::ISO8601->parse_datetime($rendu->{period}{end}); # TODO: check exceptions by login/group - say "[ACU] Date courante: ", $glts; - say "[ACU] Date fermeture: ", $close; + say "Date courante : ", $glts->strftime("%d/%m/%Y %H:%M:%S"); - if ((Date_Cmp($glts, $open) == -1)) + if (DateTime->compare($glts, $open) == -1) { - say "[ACU] Tag not allowed: upload not yet opened!"; + say "Date d'ouverture : ", $open->strftime("%d/%m/%Y %H:%M:%S"); + log ERROR, "Tag rejeté : le rendu n'est pas encore ouvert."; exit(4); } - if ((Date_Cmp($glts, $close) == 1)) + say "Date de fermeture : ", $close->strftime("%d/%m/%Y %H:%M:%S"); + + if (DateTime->compare($glts, $close) == 1) { - say "[ACU] Tag not allowed: upload closed!"; + log ERROR, "Tag rejeté : le rendu est clos."; exit(5); } my $token = $rendu->{vcs}{token}; - if ($token ne "" and $token ne $tokengiven) + if ($token ne "" and $token ne $tokengiven and $newsha ne '0' x 40) { - say "[ACU] Error 0x65cd58: Bad token."; + log ERROR, "Tag rejeté : mauvais token."; exit(6); } } - # Send data to API - my $last_commit = `git log -1 --name-status`; - eval { - API::Submission::add($promo, $id_project, $tag, $repo_login, $last_commit); - }; - if ($@) { - my $err = $@; - log DEBUG, "ERROR: ".$err; - log DONE, "[ACU] Upload successful"; + if ($newsha eq '0' x 40) { + log USAGE, "Mais pour quelle raison voudriez-vous supprimer un tag ?!"; } - else { - log DONE, "[ACU] Upload successful, please check this information on the intranet"; + else + { + # Send data to API + my $last_commit = `git log $newsha -1 --decorate --tags`; + eval { + API::Submission::add($promo, $id_project, $tag, $repo_login, $last_commit); + }; + if ($@) { + my $err = $@; + log DEBUG, "ERROR: ".$err; + log DONE, "Tag '$tag' effectué avec succès !"; + } + else { + log DONE, "Tag '$tag' effectué avec succès ! Vérifiez-le sur l'intranet."; + } } } exit 0; - -sub ip2long -{ - return unpack("l*", pack("l*", unpack("N*", inet_aton(shift)))); -} - -sub long2ip -{ - return inet_ntoa(pack("N*", shift)); -} From 7a192c47323c7dc6910cb43e783c60158cb5849b Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 30 Sep 2013 13:08:33 +0200 Subject: [PATCH 002/137] Globbing in grading is not critical --- ACU/Grading.pm | 20 +++++++++++++------- ACU/Tinyglob.pm | 5 +++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ACU/Grading.pm b/ACU/Grading.pm index dd1d64f..6eae26c 100644 --- a/ACU/Grading.pm +++ b/ACU/Grading.pm @@ -344,14 +344,20 @@ sub compute ($$$;$$$) if (defined $ref) { - my $glob = Tinyglob::tinyglob($ref); - if ($glob ne $ref) - { - my $value = 0; - for my $r (grep { /^$glob$/ } keys %$ids) { - $value += $ids->{ $r }; + eval { + my $glob = Tinyglob::tinyglob($ref); + if ($glob ne $ref) + { + my $value = 0; + for my $r (grep { /^$glob$/ } keys %$ids) { + $value += $ids->{ $r }; + } + $ids->{ $ref } = $value; } - $ids->{ $ref } = $value; + }; + if ($@) { + my $err = $@; + log ERROR, $@; } } diff --git a/ACU/Tinyglob.pm b/ACU/Tinyglob.pm index 3c19a5a..6fc9ed8 100644 --- a/ACU/Tinyglob.pm +++ b/ACU/Tinyglob.pm @@ -12,7 +12,8 @@ our @EXPORT = qw(tinyglob); sub tinyglob { - my @str = split("", quotemeta(shift)); + my $orig = shift; + my @str = split("", quotemeta($orig)); my $res = ""; my $metaescape = 0; @@ -38,7 +39,7 @@ sub tinyglob $res .= '.*'; } else { - croak "Invalid number of \\"; + croak "Invalid number of \\ in '$orig'"; } } else { From 3fb0b9e86630b3bf09d5121682bee4abab861eaf Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 4 Nov 2013 02:26:04 +0100 Subject: [PATCH 003/137] Migration: migrate also .ltx files --- migration/repo.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/migration/repo.sh b/migration/repo.sh index 4f97bbc..be4338a 100755 --- a/migration/repo.sh +++ b/migration/repo.sh @@ -46,6 +46,8 @@ tex2md() sed -Ei 's/\\begin *\{cartouche_nospaces\}/\\begin\{verbatim\}/g' "$i" sed -Ei 's/\\end *\{cartouche_nospaces\}/\\end\{verbatim\}/g' "$i" sed -Ei 's/\\verb ([^+]+) /\\verb+\1+/g' "$i" + sed -Ei 's/``/"/g' "$i" + sed -Ei "s/''/\"/g" "$i" # Special macros sed -Ei 's/\\(file|email|command|code|bcode) *\{([^}]*)\}/\\verb+\2+/gi' "$i" @@ -109,7 +111,7 @@ clean_tex() exit 1; fi - for f in data Makefile images/acu.pdf images/assistants.pdf images/assistants-subject.pdf images/assistants-slides.pdf images/assistants.png images/epita.pdf images/epita.png images/epita-invert.pdf images/assistants-invert.pdf images/epita-invert.png images/assistants-bg.png images/logo_epita.jpg images/acu-bottom.png images/acu-bottom.pdf images/acu-bg.pdf images/acu2011.png images/acu.png *.cls *.sty *.tex + for f in data Makefile images/acu.pdf images/assistants.pdf images/assistants-subject.pdf images/assistants-slides.pdf images/assistants.png images/epita.pdf images/epita.png images/epita-invert.pdf images/assistants-invert.pdf images/epita-invert.png images/assistants-bg.png images/logo_epita.jpg images/acu-bottom.png images/acu-bottom.pdf images/acu-bg.pdf images/acu2011.png images/acu.png *.cls *.sty do if [ -f "$f" ] then @@ -120,6 +122,11 @@ clean_tex() fi done + for file in `find -name "*.ltx"` + do + git mv "$file" "${file%%.ltx}.tex" + done + if [ -d "include" ] then cd include @@ -130,6 +137,20 @@ clean_tex() git mv * .. fi + cd "$1" + tex2md . + maintex2md + rmdir include 2> /dev/null + elif [ -d "subdocs" ] + then + cd subdocs + tex2md .. + + if [ `find | wc -l` -gt 1 ] + then + git mv * .. + fi + cd "$1" tex2md . maintex2md From 92a222d346ff623b5e36fca283861d4ec9b78119 Mon Sep 17 00:00:00 2001 From: Nicolas Geniteau Date: Tue, 5 Nov 2013 17:37:03 +0100 Subject: [PATCH 004/137] hook dump-help --- hooks/dump-help.pl | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 hooks/dump-help.pl diff --git a/hooks/dump-help.pl b/hooks/dump-help.pl new file mode 100755 index 0000000..dd8d29f --- /dev/null +++ b/hooks/dump-help.pl @@ -0,0 +1,40 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use v5.10; +use utf8; +use Carp; +use File::Basename; +use File::Path qw(remove_tree); +use File::Temp qw/tempfile tempdir/; + +use ACU::Log; +$ACU::Log::log_file = "/var/log/hooks/" . basename($0) . ".log"; +use ACU::Process; + +# First, check if the repository is dump-help +exit 0 if ($ENV{GL_REPO} ne "dump-help"); + +my ($ref, $oldsha, $newsha) = @ARGV; + +log DONE, "This is the dump-help repository!"; + +exit 0 if ($newsha eq '0' x 40); + +if ($ref eq "refs/tags/release") +{ + + my $archive = qx(git archive --format=tgz $newsha); + #qx(git clone -b release /srv/git/repositories/dump-help.git '$tempdir') or croak "It is not a valid repository."; + + Process::Client::launch("docs_compile", + { + "type" => "dump_help", + "file" => "dump-help.tgz" , + }, + { "dump-help.tgz" => $archive }); + +} + +exit 0; From 3c0e0f09be98b921887553a0fb267f827154b11e Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 4 Nov 2013 02:26:04 +0100 Subject: [PATCH 005/137] Migration: migrate also .ltx files --- migration/repo.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/migration/repo.sh b/migration/repo.sh index 4f97bbc..be4338a 100755 --- a/migration/repo.sh +++ b/migration/repo.sh @@ -46,6 +46,8 @@ tex2md() sed -Ei 's/\\begin *\{cartouche_nospaces\}/\\begin\{verbatim\}/g' "$i" sed -Ei 's/\\end *\{cartouche_nospaces\}/\\end\{verbatim\}/g' "$i" sed -Ei 's/\\verb ([^+]+) /\\verb+\1+/g' "$i" + sed -Ei 's/``/"/g' "$i" + sed -Ei "s/''/\"/g" "$i" # Special macros sed -Ei 's/\\(file|email|command|code|bcode) *\{([^}]*)\}/\\verb+\2+/gi' "$i" @@ -109,7 +111,7 @@ clean_tex() exit 1; fi - for f in data Makefile images/acu.pdf images/assistants.pdf images/assistants-subject.pdf images/assistants-slides.pdf images/assistants.png images/epita.pdf images/epita.png images/epita-invert.pdf images/assistants-invert.pdf images/epita-invert.png images/assistants-bg.png images/logo_epita.jpg images/acu-bottom.png images/acu-bottom.pdf images/acu-bg.pdf images/acu2011.png images/acu.png *.cls *.sty *.tex + for f in data Makefile images/acu.pdf images/assistants.pdf images/assistants-subject.pdf images/assistants-slides.pdf images/assistants.png images/epita.pdf images/epita.png images/epita-invert.pdf images/assistants-invert.pdf images/epita-invert.png images/assistants-bg.png images/logo_epita.jpg images/acu-bottom.png images/acu-bottom.pdf images/acu-bg.pdf images/acu2011.png images/acu.png *.cls *.sty do if [ -f "$f" ] then @@ -120,6 +122,11 @@ clean_tex() fi done + for file in `find -name "*.ltx"` + do + git mv "$file" "${file%%.ltx}.tex" + done + if [ -d "include" ] then cd include @@ -130,6 +137,20 @@ clean_tex() git mv * .. fi + cd "$1" + tex2md . + maintex2md + rmdir include 2> /dev/null + elif [ -d "subdocs" ] + then + cd subdocs + tex2md .. + + if [ `find | wc -l` -gt 1 ] + then + git mv * .. + fi + cd "$1" tex2md . maintex2md From fe9cc480a122b3f76a2b980ff1d9bbe9b2d6107a Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Tue, 5 Nov 2013 17:40:52 +0100 Subject: [PATCH 006/137] Add install procedure into manage-server --- commands/manage-server.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/commands/manage-server.sh b/commands/manage-server.sh index e1ea557..9bb03f2 100755 --- a/commands/manage-server.sh +++ b/commands/manage-server.sh @@ -6,7 +6,7 @@ WKS_LIST="apl" SRV_LIST="moore noyce hamano cpp otto" SCP_LIST="ksh knuth" -KNOWN_ACTIONS="start stop restart update log viewlog view_log" +KNOWN_ACTIONS="start stop restart install update log viewlog view_log" LOG=`mktemp` @@ -80,7 +80,7 @@ do for DEST in $DESTS do echo -e "\e[1;34m>>>\e[0m \e[33m$ACTION\e[0m on \e[1m$DEST\e[0m" - if [ "$ACTION" == "update" ] + if [ "$ACTION" == "install" ] || [ "$ACTION" == "update" ] then SCP=0 for D in $SCP_LIST @@ -94,6 +94,11 @@ do if [ $SCP -eq 0 ] then + if [ "$ACTION" == "install" ] && + ! ssh root@$DEST "mkdir -p /home/intradmin/ && git clone '$(echo `git remote -v` | cut -d " " -f 2)' /home/intradmin/liblerdorf && ln -s /home/intradmin/liblerdorf ~/liblerdorf" + then + exit 1 + fi ssh root@$DEST "make -C liblerdorf update upgrade" else cd .. From 0af1174ca8c1ab8884c28907c41ce3a5a6a9468c Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Tue, 5 Nov 2013 18:03:54 +0100 Subject: [PATCH 007/137] Replace croak by die when unexpected error --- process/files/intradata_get.pl | 90 +++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 35 deletions(-) diff --git a/process/files/intradata_get.pl b/process/files/intradata_get.pl index 7e1eae3..c1f58e0 100644 --- a/process/files/intradata_get.pl +++ b/process/files/intradata_get.pl @@ -42,7 +42,7 @@ sub create_tree($$) croak "No directory for year $year. Ask a root to create it." if (! -d "$basedir/$year/"); if (! -e "$basedir/$year/$project_id/") { - mkdir "$basedir/$year/$project_id/" or croak $!; + mkdir "$basedir/$year/$project_id/" or die $!; } } @@ -57,11 +57,14 @@ sub grades_generate croak "No project_id given." if (! $project_id); if (! -e "$basedir/$year/$project_id/grades/") { - mkdir "$basedir/$year/$project_id/grades/" or croak $!; + mkdir "$basedir/$year/$project_id/grades/" or die $!; } log DEBUG, "Generate list of students"; + # Get groups from the intranet + my $groups = API::Projects::get_groups($project_id, $year); + # Create list of students to generate my @logins; if ($args->{unamed}) @@ -72,22 +75,11 @@ sub grades_generate } else { - opendir(my $dh, "$basedir/$year/$project_id/traces/") or croak "can't opendir $basedir/$year/$project_id/traces/: $!"; - for my $dir (grep { ( ! /^\./ ) && -d "$basedir/$year/$project_id/traces/$_" } readdir($dh)) - { - opendir(my $dhm, "$basedir/$year/$project_id/traces/$dir") or croak "can't opendir $basedir/$year/$project_id/traces/$dir: $!"; - - for my $login (grep { ( ! /^\./ ) && -f "$basedir/$year/$project_id/traces/$dir/$_" } readdir($dhm)) - { - $login =~ s/\.xml$//; - if (! grep { /^\Q$login\E$/ } @logins) { - push @logins, $login; - } + map { + for my $member (@{ $_->{stds} }) { + push @logins, $member->{login}; } - - closedir $dhm; - } - closedir $dh; + } @{ $groups->{groups} }; } log TRACE, @logins; @@ -110,18 +102,46 @@ sub grades_generate log DEBUG, "Generating grades for $login"; for my $dir (@trace_dirs) { - log DEBUG, "Generating grades from $dir"; - if (-f "$basedir/$year/$project_id/traces/$dir/$login.xml") + log DEBUG, "Fetching identifiers from $dir"; + + my $tr_file = "$year/$project_id/traces/$dir/$login.xml"; + + # Looking for a group traces? + if (! -f "$basedir/$tr_file") { - open my $xmltrace, "<", "$basedir/$year/$project_id/traces/$dir/$login.xml" or croak "traces/$dir/$login.xml: $!"; + for my $grp (@{ $groups->{groups} }) + { + my $this = 0; + my $chief; + for my $member (@{ $grp->{stds} }) + { + if ($member->{chief} eq "true" or $member->{chief} eq "1" or $member->{chief} eq "chief") + { + $chief = $member; + next; + } + $this = 1 if ($member->{login} eq $login); + } + if ($this && $chief) + { + $tr_file = "$year/$project_id/traces/$dir/".$chief->{login}.".xml"; + log DEBUG, "Using group trace: chief is ".$chief->{login}; + last; + } + } + } + + if (-f "$basedir/$tr_file") + { + open my $xmltrace, "<", "$basedir/$tr_file" or croak "$tr_file: $!"; binmode $xmltrace; my $trace = Trace->new($xmltrace); close $xmltrace; - log DEBUG, "Fill from file: traces/$dir/$login.xml"; + log DEBUG, "Fill from file: $tr_file"; log TRACE, $trace->getIds; - $grading->fill($trace->getIds); + $grading->fill($trace->getIds($login)); } } @@ -149,10 +169,10 @@ sub grades_new_bonus croak "No project_id given" if (! $project_id); if (! -e "$basedir/$year/$project_id/traces/") { - mkdir "$basedir/$year/$project_id/traces/" or croak $!; + mkdir "$basedir/$year/$project_id/traces/" or die $!; } if (! -e "$basedir/$year/$project_id/traces/bonus/") { - mkdir "$basedir/$year/$project_id/traces/bonus/" or croak $!; + mkdir "$basedir/$year/$project_id/traces/bonus/" or die $!; } for my $kfile (keys %{ $args->{files} }) @@ -192,7 +212,7 @@ sub grades_new_bonus } if (-e "$basedir/$year/$project_id/traces/bonus/$login.xml") { - open my $xml, "<", "$basedir/$year/$project_id/traces/bonus/$login.xml" or croak $!; + open my $xml, "<", "$basedir/$year/$project_id/traces/bonus/$login.xml" or die $!; binmode $xml; $trace = Trace->new($xml); close $xml; @@ -216,7 +236,7 @@ sub grades_new_bonus log DEBUG, "Updating $basedir/$year/$project_id/traces/bonus/$login.xml"; - open my $xml, ">", "$basedir/$year/$project_id/traces/bonus/$login.xml" or croak $!; + open my $xml, ">", "$basedir/$year/$project_id/traces/bonus/$login.xml" or die $!; print $xml $trace->toString(); close $xml; } @@ -251,19 +271,19 @@ sub update_defense log INFO, "Update $year/$project_id/defenses/$defense_id.xml"; if (! -e "$basedir/$year/$project_id/defenses/") { - mkdir "$basedir/$year/$project_id/defenses/" or croak $!; + mkdir "$basedir/$year/$project_id/defenses/" or die $!; } if (! -e "$basedir/$year/$project_id/traces/") { - mkdir "$basedir/$year/$project_id/traces/" or croak $!; + mkdir "$basedir/$year/$project_id/traces/" or die $!; } if (! -e "$basedir/$year/$project_id/traces/defense_$defense_id/") { - mkdir "$basedir/$year/$project_id/traces/defense_$defense_id/" or croak $!; + mkdir "$basedir/$year/$project_id/traces/defense_$defense_id/" or die $!; my ($login, $pass, $uid, $gid) = getpwnam("www-data"); - chown $uid, $gid, "$basedir/$year/$project_id/traces/defense_$defense_id/" or croak $!; - chmod 0775, "$basedir/$year/$project_id/traces/defense_$defense_id/" or croak $!; + chown $uid, $gid, "$basedir/$year/$project_id/traces/defense_$defense_id/" or die $!; + chmod 0775, "$basedir/$year/$project_id/traces/defense_$defense_id/" or die $!; } - open my $out, ">", "$basedir/$year/$project_id/defenses/$defense_id.xml" or croak $!; + open my $out, ">", "$basedir/$year/$project_id/defenses/$defense_id.xml" or die $!; print $out $defense; close $out; @@ -322,11 +342,11 @@ sub update_trace log INFO, "Update $year/$project_id/traces/$rendu_id/$login.xml"; if (! -e "$basedir/$year/$project_id/traces/") { - mkdir "$basedir/$year/$project_id/traces/" or croak $!; + mkdir "$basedir/$year/$project_id/traces/" or die $!; } if (! -e "$basedir/$year/$project_id/traces/$rendu_id/") { - mkdir "$basedir/$year/$project_id/traces/$rendu_id/" or croak $!; - chmod 0755, "$basedir/$year/$project_id/traces/$rendu_id/" or croak $!; + mkdir "$basedir/$year/$project_id/traces/$rendu_id/" or die $!; + chmod 0755, "$basedir/$year/$project_id/traces/$rendu_id/" or die $!; } open my $out, ">", "$basedir/$year/$project_id/traces/$rendu_id/$login.xml" or croak("Unable to write to $rendu_id/$login.xml"); From 90727e48d570935f86504d3e25393232c578cbdc Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 6 Nov 2013 18:11:17 +0100 Subject: [PATCH 008/137] Fix errors --- ACU/VCS/Git.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ACU/VCS/Git.pm b/ACU/VCS/Git.pm index 169b028..a1ed4fa 100644 --- a/ACU/VCS/Git.pm +++ b/ACU/VCS/Git.pm @@ -27,7 +27,7 @@ sub init_conf(;$) { $git_server = $_ if (shift); - $gitolite_directory = mktemp("/tmp/git_manage_XXXX") unless(-d $gitolite_directory); + $gitolite_directory = mktemp("/tmp/git_manage_XXXX"); log INFO, "Cloning $git_user\@$git_server:$git_adminrepo to $gitolite_directory"; @@ -271,7 +271,7 @@ sub user_delete { if ($f =~ /^[0-9]/ && -d "$gitolite_directory/keydir/$f") { log INFO, "Removing $f directory"; - rmtree("$gitolite_directory/keydir/$f"); + remove_tree("$gitolite_directory/keydir/$f"); } } else From 8a4b545da67ef61f6c02dbd9aaf6961222763d29 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 6 Nov 2013 18:13:08 +0100 Subject: [PATCH 009/137] chdir before remove dir --- ACU/VCS/Git.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/ACU/VCS/Git.pm b/ACU/VCS/Git.pm index a1ed4fa..a9ad31c 100644 --- a/ACU/VCS/Git.pm +++ b/ACU/VCS/Git.pm @@ -48,6 +48,7 @@ sub save_conf(;$) log INFO, "Saving repositories configuration"; qx(git push); + chdir("/"); remove_tree($gitolite_directory); $gitolite_directory = undef; } From de88e60fa5b8cfc5973bb6d52ddf7ffc36e570c8 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 6 Nov 2013 18:22:07 +0100 Subject: [PATCH 010/137] Fix too much kill of ssh-agent --- process/launch.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/process/launch.sh b/process/launch.sh index fef7b54..efac6fd 100755 --- a/process/launch.sh +++ b/process/launch.sh @@ -12,13 +12,17 @@ else fi PERL='/usr/bin/env perl' +reset_agents() +{ + echo "killall ssh-agent" | $SU intradmin +} + launch_screen() { CMD=$2 if [ -n "$3" ] && [ -f "$3" ] then TMP=`echo mktemp | $SU intradmin` - echo "killall ssh-agent" | $SU intradmin echo "ssh-agent" | $SU intradmin > "$TMP" echo ". $TMP; ssh-add '$3'" | $SU intradmin CMD=". $TMP; ssh-add -l; echo; $CMD" @@ -80,10 +84,12 @@ then case $HOSTNAME in cpp) + reset_agents launch_screen "lerdorf_process_ldap_sync_ssh_keys_forge" "while true; do $PERL ~/liblerdorf/process/ldap/sync_ssh_keys_forge.pl; done" ~intradmin/.ssh/git ;; hamano) + reset_agents launch_screen "lerdorf_process_ldap_sync_ssh_keys_git" "while true; do $PERL ~/liblerdorf/process/ldap/sync_ssh_keys_git.pl; done" ~intradmin/.ssh/git launch_screen "lerdorf_process_send_git" "while true; do $PERL ~/liblerdorf/process/files/send_git.pl; done" ~intradmin/.ssh/git ;; From cda7b5b02614be0e9bb9772b229835fc59d72b4b Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 7 Nov 2013 14:46:28 +0100 Subject: [PATCH 011/137] LPT: fix grant-lab and add delete account capability --- ACU/LDAP.pm | 6 +-- utils/lpt | 108 +++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 98 insertions(+), 16 deletions(-) diff --git a/ACU/LDAP.pm b/ACU/LDAP.pm index 5e7e229..04b94e7 100644 --- a/ACU/LDAP.pm +++ b/ACU/LDAP.pm @@ -193,9 +193,9 @@ sub get_dn($$@) base => "$dn", filter => Net::LDAP::Filter->new("(objectClass=*)"), attrs => \@_, - scope => "sub" + scope => "base" ); - if ($mesg->code != 0) { log(WARN, $mesg->error); return undef; } + return undef if ($mesg->code != 0); if ($mesg->count != 1) { log(WARN, "$dn not found or multiple entries match"); return undef; } return $mesg->entry(0); @@ -331,7 +331,7 @@ sub search_dn($$@) attrs => [ ], scope => "sub" ); - croak($mesg->error) if ($mesg->code != 0); + return undef if ($mesg->code != 0); croak("$filter not found") if ($mesg->count == 0); croak("$filter not unique") if ($mesg->count > 1); diff --git a/utils/lpt b/utils/lpt index e760ed0..c96d936 100755 --- a/utils/lpt +++ b/utils/lpt @@ -73,6 +73,7 @@ my %cmds_account = "close" => \&cmd_account_close, "cn" => \&cmd_account_cn, "create" => \&cmd_account_create, + "delete" => \&cmd_account_delete, "finger" => \&cmd_account_view, "mail" => \&cmd_account_mail, "name" => \&cmd_account_cn, @@ -259,11 +260,31 @@ sub cmd_account_create($@) log(DEBUG, "Adding dn: uid=$login,ou=$group,ou=users,dc=acu,dc=epita,dc=fr ..."); my $ldap = LDAP::ldap_connect(); - my $mesg = $ldap->add( "uid=$login,ou=$group,ou=users,dc=acu,dc=epita,dc=fr", + + # Check if the OU exists + my $oudn = "ou=$group,ou=users,dc=acu,dc=epita,dc=fr"; + my $ou = LDAP::get_dn($ldap, $oudn); + + if (! $ou) + { + my $mesg = $ldap->add( "$oudn", + attrs => [ + objectclass => [ "top", "organizationalUnit" ], + ou => "$group", + ] + ); + if ($mesg->code == 0) { + log(INFO, "New OU created: $oudn"); + } else { + log(WARN, "Unable to add new OU $oudn: ", RESET, $mesg->error); + } + } + + my $mesg = $ldap->add( "uid=$login,$oudn", attrs => [ objectclass => [ "top", "epitaAccount" ], uidNumber => shift, - cn => shift(@_)." ".shift(@_), + cn => ucfirst(shift(@_))." ".ucfirst(shift(@_)), mail => "$login\@epita.fr", uid => $login, ] @@ -271,10 +292,11 @@ sub cmd_account_create($@) #$ldap->unbind or die ("couldn't disconnect correctly"); - if ($mesg->code == 0) { + if ($mesg->code == 0) + { log(INFO, "Account added: $login"); my $pass = shift; - return cmd_account($login, $pass) if ($pass ne "nopass"); + return cmd_account($login, $pass, @_) if ($pass ne "nopass"); return 0; } else { @@ -282,6 +304,28 @@ sub cmd_account_create($@) } } +sub cmd_account_delete($@) +{ + my $login = shift; + + my $ldap = LDAP::ldap_connect(); + + my $dn = LDAP::search_dn($ldap, "ou=users", "uid=$login"); + + log(DEBUG, "Deleting dn: $dn ..."); + + if (LDAP::delete_entry($ldap, $dn)) + { + log DONE, "Account ", YELLOW, $login, RESET, " successfully deleted."; + return 0; + } + else + { + log ERROR, "Unable to delete account ", YELLOW, $login, RESET, "."; + return 1; + } +} + sub cmd_account_grantintra($@) { my $login = shift; @@ -300,27 +344,58 @@ sub cmd_account_grantintra($@) sub cmd_account_grantlab($@) { my $login = shift; - my $group = shift; + my $group = shift // ""; - if ($group ne "acu" && $group ne "yaka") { - log(USAGE, "lpt account grantlab "); + if ($group ne "acu" && $group ne "yaka" && $group ne "ferry") + { + log(USAGE, "lpt account grant-lab "); return 1; } my $ldap = LDAP::ldap_connect(); my $dn = LDAP::search_dn($ldap, "ou=users", "uid=$login"); + my $entry = LDAP::get_dn($ldap, $dn, "objectClass", "mail", "mailAlias", "mailAccountActive", "loginShell", "homeDirectory", "gidNumber"); if (!LDAP::get_attribute($ldap, $dn, "mail")) { LDAP::add_attribute($ldap, $dn, "mail", "$login\@epita.fr"); } - LDAP::add_attribute($ldap, $dn, "mailAlias", "$login\@$group.epita.fr"); - LDAP::update_attribute($ldap, $dn, "mailAccountActive", "yes"); - LDAP::add_attribute($ldap, $dn, "objectClass", "MailAccount"); - LDAP::add_attribute($ldap, $dn, "objectClass", "labAccount"); + if ($group eq "acu" || $group eq "yaka") + { + if (! grep { $_ eq "MailAccount" } @{ $entry->get_value("objectClass") }) + { + $entry->replace("mailAccountActive" => [ "yes" ]); - log(INFO, "$login now grants to receive e-mail and connect in laboratory."); + my @oc = $entry->get_value("objectClass"); + push @oc, "MailAccount"; + $entry->replace("objectClass" => \@oc); + + my @aliases = $entry->get_value("mailAlias"); + push @aliases, "$login\@$group.epita.fr"; + $entry->replace("objectClass" => \@aliases); + } + + $entry->replace("loginShell" => [ "/bin/zsh" ]) if ($entry->get_value("loginShell")); + $entry->replace("homeDirectory" => [ "/home/201X/$login" ]) if ($entry->get_value("homeDirectory")); + $entry->replace("gidNumber" => [ "4242" ]) if ($entry->get_value("gidNumber")); + } + elsif ($group eq "ferry") + { + $entry->replace("loginShell" => [ "/bin/noexists" ]); + $entry->replace("homeDirectory" => [ "/dev/null" ]); + $entry->replace("gidNumber" => [ "4243" ]); + } + + my @oc = $entry->get_value("objectClass"); + push @oc, "labAccount"; + $entry->replace("objectClass" => \@oc); + + my $mesg = $entry->update($ldap) or die $!; + if ($mesg->code != 0) { log(WARN, $mesg->error); return 0; } + + log(INFO, "$login now grants to receive e-mail and connect in laboratory.") if ($group eq "acu" || $group eq "yaka"); + log(INFO, "$login now grants to connect in laboratory for exam.") if ($group eq "ferry"); $ldap->unbind or die ("couldn't disconnect correctly"); } @@ -1855,10 +1930,12 @@ B I Give rights to the user to access the intranet. -B I +B I Give rights to the user to access intern systems of the laboratory (SSH, Unix, ...) + If ferry is given, open an account for exam only, with restricted rights. + B I Give rights to the user to receive e-mails. @@ -1871,6 +1948,11 @@ B I This is used to close an existing account. +B I + + This is used to delete an existing account. + NEVER DELETE AN ACCOUNT, close it instead. + B I [new-mail] This is used to display, or change if [new-mail] is given, the account contact adress. From 584fbf98954a1c99ad3d25951b6046d0bfac1e47 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Fri, 8 Nov 2013 21:05:05 +0100 Subject: [PATCH 012/137] Add APPING1 to exception --- hooks/submissions.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hooks/submissions.pl b/hooks/submissions.pl index 52d7e59..058e393 100755 --- a/hooks/submissions.pl +++ b/hooks/submissions.pl @@ -22,6 +22,8 @@ my $promo; my $id_project; my $repo_login; +my @apping = qw(zinger_a zebard_w zanell_a yao_p vinois_a sraka_y soupam_j seck_a ngomsi_s morin_h milis_e menkar_m eusebe_r crief_a chhum_s boumra_n blemus_a bengan_l amasho_a); + # First, extract information, from config then guess from repository adress if (my $tmp = `git config hooks.promo`) { chomp $tmp; $promo = $tmp; } if (my $tmp = `git config hooks.idproject`) { chomp $tmp; $id_project = $tmp; } @@ -71,6 +73,12 @@ if ($ref =~ m<^refs/tags/(.+)$>) my $open = DateTime::Format::ISO8601->parse_datetime($rendu->{period}{begin}); my $close = DateTime::Format::ISO8601->parse_datetime($rendu->{period}{end}); + if ($id_project eq "myhttpd" && grep { $_ eq $repo_login } @apping) + { + $open = DateTime::Format::ISO8601->parse_datetime("2013-11-08T20:00:00"); + $close = DateTime::Format::ISO8601->parse_datetime("2013-11-10T11:42:00"); + } + # TODO: check exceptions by login/group $open = DateTime::Format::ISO8601->parse_datetime("2013-10-16T16:00:00") if ($repo_login eq "ikouna_l"); From 1de1b9a2218f628aaa6a7243101d8c891627199d Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sat, 9 Nov 2013 17:42:59 +0100 Subject: [PATCH 013/137] New exception --- hooks/gl-pre-git | 1 + 1 file changed, 1 insertion(+) diff --git a/hooks/gl-pre-git b/hooks/gl-pre-git index 5f6fd16..65c8952 100755 --- a/hooks/gl-pre-git +++ b/hooks/gl-pre-git @@ -49,6 +49,7 @@ if ($ip->overlaps($labnetwork) == $IP_A_IN_B_OVERLAP) #} exit 0 if (grep { /\Q$repo_login\E/ } @habitent_loin); +exit 0 if ($repo_login eq "bellev_m"); my $schoolnetwork = Net::IP->new('10.41.0.0/16'); #my $vjschoolnetwork = Net::IP->new('10.3.0.0/16'); From 15f89a5e396f237700a7f2b473e6de10b5f095c2 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 11 Nov 2013 16:09:53 +0100 Subject: [PATCH 014/137] New parser for traces --- ACU/Grading.pm | 2 +- ACU/Trace.pm | 393 +++++++++++++++++++++------------ process/files/intradata_get.pl | 2 +- 3 files changed, 251 insertions(+), 146 deletions(-) diff --git a/ACU/Grading.pm b/ACU/Grading.pm index b01693c..7db43cb 100644 --- a/ACU/Grading.pm +++ b/ACU/Grading.pm @@ -111,7 +111,7 @@ sub insert ($$$) $self->{ids}{$_[0]} = $_[1]; } -sub fill ($$) +sub fill { my $self = shift; my $ids = shift; diff --git a/ACU/Trace.pm b/ACU/Trace.pm index fba6621..e4ae66e 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -9,16 +9,13 @@ use Carp; use utf8; use open qw(:encoding(UTF-8) :std); use XML::LibXML; -use XML::SAX::ParserFactory; sub new { my $class = shift; my $self = { - ids => {}, infos => {}, - comments => {}, - who => {}, + groups => [], }; bless $self, $class; @@ -33,10 +30,47 @@ sub _initialize ($$) { my $self = shift; - my $sax_handler = TraceHandler->new($self); - my $parser = XML::SAX::ParserFactory->parser( Handler => $sax_handler ); + my $dom = XML::LibXML->load_xml(string => shift); + $self->{groups} = $self->parseTrace($dom->documentElement()); + $self->{type} = $dom->documentElement()->getAttribute("type") // "mill"; + $self->{version} = $dom->documentElement()->getAttribute("version") // 1; +} - $parser->parse_file(shift); +sub parseTrace($$) +{ + my $self = shift; + my $tree = shift; + my $ret = []; + + foreach my $node ($tree->childNodes()) + { + if ($node->nodeName eq "info") + { + my $tmp = $node->textContent; + chomp($tmp); + $self->{infos}{ $node->getAttribute("name") } = $tmp; + } + elsif ($node->nodeName eq "group") + { + my $g = Trace::Group->new( + $node->getAttribute("id"), + $node->getAttribute("name") + ); + $g->append(@{ $self->parseTrace($node) }); + push @$ret, $g; + } + elsif ($node->nodeName eq "eval") + { + my $e = Trace::Eval->new( + $node->getAttribute("id"), + $node->getAttribute("type"), + $node + ); + push @$ret, $e; + } + } + + return $ret; } sub getVersion ($) @@ -63,64 +97,63 @@ sub getInfos ($) return $self->{infos}; } -sub getComment ($$) +sub getIds { my $self = shift; - return $self->{comments}{$_[0]}; + my $login = shift; + + my %ids; + foreach my $group (@{ $self->{groups} }) + { + my %tmp = $group->getIds($login); + while (my ($key, $value) = each %tmp) + { + %ids{$key} = $value; + } + } + return %ids; } -sub getComments ($) +sub getValue { my $self = shift; - return $self->{comments}; + my $id = shift; + my $login = shift; + + my $value = 0; + foreach my $group (@{ $self->{groups} }) + { + $value += $group->getValue($id, $login); + } + return $value; } sub getWho ($$) { my $self = shift; - return $self->{who}{$_[0]}; + return $self->getWhos()->{$_[0]}; } sub getFirstWho ($) { my $self = shift; - - return $self->{who}{def1_end_group}; + return $self->getWhos()->{def1_end_group}; } -sub getWhos ($) +sub getWhos { my $self = shift; - return $self->{who}; -} + my $ret = {}; -sub getValue ($$) -{ - my $self = shift; - return $self->{ids}{$_[0]}; -} + foreach my $group (@{ $self->{groups} }) + { + my $whos = $group->getWhos(); + foreach my $who (keys %{ $whos }) { + $ret->{ $who } = $whos->{$who}; + } + } -sub getIds ($) -{ - my $self = shift; - return $self->{ids}; -} - -sub addId($$;$) -{ - my $self = shift; - my $key = shift; - my $value = shift // 1; - - $self->{ids}{$key} = $value; -} - -sub delId($$) -{ - my $self = shift; - my $key = shift; - - delete $self->{ids}{$key}; + return $ret; } sub toString ($;$) @@ -153,23 +186,20 @@ sub toString ($;$) } -package TraceHandler; +package Trace::Group; +use v5.10.1; +use strict; +use warnings; use Carp; -use constant NO_ID_VALUE => "__#"; sub new ($$) { my $class = shift; my $self = { - groups => [], - parsed => shift, - inComment => "", - inEval => "", - inInfo => "", - inValue => "", - inWho => "", - values => "" + id => shift, + name => shift, + groups => [] }; bless $self, $class; @@ -177,113 +207,188 @@ sub new ($$) return $self; } -sub start_element +sub append ($@) { - my ($self, $element) = @_; + my $self = shift; - if ($element->{Name} eq "trace") { - $self->{parsed}{version} = $element->{Attributes}{"{}version"}{Value}; - $self->{parsed}{type} = $element->{Attributes}{"{}type"}{Value}; - } - elsif ($element->{Name} eq "info") { - $self->{inInfo} = $element->{Attributes}{"{}name"}{Value}; - $self->{parsed}{infos}{ $self->{inInfo} } = 0; - $self->{values} = ""; - } - elsif ($element->{Name} eq "eval") { - my $tmp = $element->{Attributes}{"{}id"}{Value}; - if ($tmp) { - $self->{inEval} = $tmp; - $self->{parsed}{ids}{ $self->{inEval} } = 0; - } - } - elsif ($element->{Name} eq "comment" && $self->{inEval}) { - $self->{inComment} = $self->{inEval}; - $self->{values} = ""; - } - elsif ($element->{Name} eq "who" && $self->{inEval}) { - $self->{inWho} = $self->{inEval}; - $self->{values} = ""; - } - elsif ($element->{Name} eq "value") { - if ($element->{Attributes}{"{}id"}{Value}) { - $self->{inValue} = $element->{Attributes}{"{}id"}{Value}; - } else { - $self->{inValue} = NO_ID_VALUE; - } - - $self->{values} = ""; - } - elsif ($element->{Name} eq "group") - { - push @{ $self->{groups} }, ($element->{Attributes}{"{}id"}{Value} // ""); - } - elsif ($element->{Name} ne "name" && $element->{Name} ne "statut" && $element->{Name} ne "status" && $element->{Name} ne "log") { - croak "Not a valid trace XML: unknown tag ".$element->{Name}; - } + push @{ $self->{groups} }, @_; } -sub characters +sub getIds { - my ($self, $characters) = @_; + my $self = shift; + my $login = shift; - if ($self->{inValue} || $self->{inInfo} || $self->{inComment} || $self->{inWho}) { - $self->{values} .= $characters->{Data}; - } -} - -sub end_element -{ - my ($self, $element) = @_; - - if ($element->{Name} eq "value") + my %ids; + foreach my $group (@{ $self->{groups} }) { - if ($self->{values} =~ /([-+]?[0-9]+(.[0-9]+)?)/) + my %tmp = $group->getIds($login); + while (($key, $value) = each %tmp) { - $self->{parsed}{ids}{ $self->{inEval} } += $1; - if ($self->{inValue} ne NO_ID_VALUE and $1) { - $self->{parsed}{ids}{ $self->{inValue} } = $1; - } - if ($self->{groups}) { - my $key = @{ $self->{groups} }[$#{ $self->{groups} }]; - $self->{parsed}{ids}{ $key } += $1; + %ids{$key} = $value; + } + } + + %ids{ $self->{id} } = $self->getValue($self->{id}, $login); + + return %ids; +} + +sub getValue +{ + my $self = shift; + my $id = shift // $self->{id}; + my $login = shift + + if ($id eq $self->{id}) + { + my $value = 0; + foreach my $group (@{ $self->{groups} }) + { + $value += $group->getValue(undef, $login); + } + return $value; + } + else + { + my $value = 0; + foreach my $group (@{ $self->{groups} }) + { + $value += $group->getValue($id, $login); + } + return $value; + } +} + +sub getWhos +{ + my $self = shift; + my $ret = {}; + + foreach my $group (@{ $self->{groups} }) + { + my $whos = $group->getWhos(); + foreach my $who (keys %{ $whos }) { + $ret->{ $who } = $whos->{$who}; + } + } + + return $ret; +} + + +package Trace::Eval; + +use v5.10.1; +use strict; +use warnings; +use Carp; + +sub new ($$;$) +{ + my $class = shift; + my $self = { + id => shift, + type => shift // "test", + values => {}, + logs => {}, + }; + + bless $self, $class; + if ($#_ >= 0) { + $self->parseEval(@_); + } + + return $self; +} + +sub parseEval +{ + my $self = shift; + my $tree = shift; + + foreach my $node ($tree->childNodes()) + { + my $val = $node->textContent; + chomp($val); + + if ($node->nodeName eq "value") + { + my $key; + if ($node->hasAttribute("id")) { + $key = $node->getAttribute("id"); + } else { + $key = ""; } + + $self->{values}{ $key } = 0 if (!exists $self->{values}{ $key }); + $self->{values}{ $key } += $val; } - $self->{inValue} = ""; - } - elsif ($element->{Name} eq "eval") - { - # Remove empty identifier - delete $self->{parsed}{ids}{ $self->{inEval} } if (!$self->{parsed}{ids}{ $self->{inEval} }); - $self->{inEval} = ""; - } - elsif ($element->{Name} eq "comment") - { - if ($self->{values} =~ /([^\s].*[^\s]|[^\s])/) { - $self->{parsed}{comments}{ $self->{inComment} } = $1; + elsif ($node->nodeName eq "name") + { + $self->{name} = $val; } - $self->{inComment} = ""; - } - elsif ($element->{Name} eq "who") - { - if ($self->{values} =~ /([^\s].*[^\s]|[^\s])/) { - $self->{parsed}{who}{ $self->{inWho} } = $1; + elsif ($node->nodeName eq "status") + { + $self->{status} = $val; } - $self->{inComment} = ""; - } - elsif ($element->{Name} eq "info") - { - if ($self->{values} =~ /([^\s].*[^\s]|[^\s])/) { - $self->{parsed}{infos}{ $self->{inInfo} } = $1; + elsif ($node->nodeName eq "log") + { + my $key = $node->getAttribute("type") // "stdout"; + + $self->{logs}{ $key } = $val; + } + elsif ($node->nodeName eq "who") + { + $self->{who} = { + login => $val, + type => $node->getAttribute("type") // "login" + }; } - $self->{inInfo} = ""; } - elsif ($element->{Name} eq "group") +} + +sub getIds +{ + my $self = shift; + my $login = shift; + + my %ids; + if (!$login || $self->{who}{type} eq "group" || $self->{who}{login} eq $login) { - my $key = pop @{ $self->{groups} }; - # Remove empty identifier - delete $self->{parsed}{ids}{ $key } if ($key && !$self->{parsed}{ids}{ $key }); + while (my ($key, $value) = each %{ $self->{who}{values} }) + { + %ids{$key} = $value if ($key); + } } + + %ids{ $self->{id} } = $self->getValue($self->{id}, $login); + + return %ids; +} + +sub getValue +{ + my $self = shift; + my $id = shift // $self->{id}; + my $login = shift; + + my $value = 0; + if (!$login || $self->{who}{type} eq "group" || $self->{who}{login} eq $login) + { + foreach my $key (%{ $self->{values} }) + { + $value += $self->{values}{$key} if ($id eq $self->{id} || !$key || $key eq $id); + } + } + return $value; +} + +sub getWhos +{ + my $self = shift; + + return { $self->{id} => $self->{who} }; } 1; diff --git a/process/files/intradata_get.pl b/process/files/intradata_get.pl index c1f58e0..bbf7d1c 100644 --- a/process/files/intradata_get.pl +++ b/process/files/intradata_get.pl @@ -133,7 +133,7 @@ sub grades_generate if (-f "$basedir/$tr_file") { - open my $xmltrace, "<", "$basedir/$tr_file" or croak "$tr_file: $!"; + open my $xmltrace, "<", "$basedir/$tr_file" or die "$tr_file: $!"; binmode $xmltrace; my $trace = Trace->new($xmltrace); close $xmltrace; From 440ace265440fd11fc6167e5b5956bb95822868e Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 11 Nov 2013 16:15:59 +0100 Subject: [PATCH 015/137] Fix syntax --- ACU/Trace.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ACU/Trace.pm b/ACU/Trace.pm index e4ae66e..d627b1e 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -108,7 +108,7 @@ sub getIds my %tmp = $group->getIds($login); while (my ($key, $value) = each %tmp) { - %ids{$key} = $value; + $ids{$key} = $value; } } return %ids; @@ -223,13 +223,13 @@ sub getIds foreach my $group (@{ $self->{groups} }) { my %tmp = $group->getIds($login); - while (($key, $value) = each %tmp) + while (my ($key, $value) = each %tmp) { - %ids{$key} = $value; + $ids{$key} = $value; } } - %ids{ $self->{id} } = $self->getValue($self->{id}, $login); + $ids{ $self->{id} } = $self->getValue($self->{id}, $login); return %ids; } @@ -238,7 +238,7 @@ sub getValue { my $self = shift; my $id = shift // $self->{id}; - my $login = shift + my $login = shift; if ($id eq $self->{id}) { @@ -358,11 +358,11 @@ sub getIds { while (my ($key, $value) = each %{ $self->{who}{values} }) { - %ids{$key} = $value if ($key); + $ids{$key} = $value if ($key); } } - %ids{ $self->{id} } = $self->getValue($self->{id}, $login); + $ids{ $self->{id} } = $self->getValue($self->{id}, $login); return %ids; } From ddb8788eb6b8db9ad2e8724da579d5e9b0cc609f Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 11 Nov 2013 16:23:23 +0100 Subject: [PATCH 016/137] Import API --- process/files/intradata_get.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/process/files/intradata_get.pl b/process/files/intradata_get.pl index bbf7d1c..36d2097 100644 --- a/process/files/intradata_get.pl +++ b/process/files/intradata_get.pl @@ -8,6 +8,7 @@ use Pod::Usage; use lib "../../"; +use ACU::API::Projects; use ACU::Log; use ACU::LDAP; use ACU::Grading; From 81058c9c201806af1dec121538277dba5a77ec76 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 11 Nov 2013 16:32:50 +0100 Subject: [PATCH 017/137] Change input form of Trce --- process/files/intradata_get.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/files/intradata_get.pl b/process/files/intradata_get.pl index 36d2097..c5d3fb5 100644 --- a/process/files/intradata_get.pl +++ b/process/files/intradata_get.pl @@ -136,7 +136,7 @@ sub grades_generate { open my $xmltrace, "<", "$basedir/$tr_file" or die "$tr_file: $!"; binmode $xmltrace; - my $trace = Trace->new($xmltrace); + my $trace = Trace->new(join '', <$xmltrace>); close $xmltrace; log DEBUG, "Fill from file: $tr_file"; From add1bb5db92fdf7b75e15405ab73ddb5c5f2721a Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 11 Nov 2013 16:35:34 +0100 Subject: [PATCH 018/137] Change output form of getIds --- ACU/Trace.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACU/Trace.pm b/ACU/Trace.pm index d627b1e..f036e9b 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -111,7 +111,7 @@ sub getIds $ids{$key} = $value; } } - return %ids; + return \%ids; } sub getValue From 62bd5f2d2a0c2f8130684a656a3e03206653ec86 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 11 Nov 2013 16:37:36 +0100 Subject: [PATCH 019/137] Fix warning --- ACU/Trace.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACU/Trace.pm b/ACU/Trace.pm index f036e9b..33dd018 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -374,7 +374,7 @@ sub getValue my $login = shift; my $value = 0; - if (!$login || $self->{who}{type} eq "group" || $self->{who}{login} eq $login) + if (!$login || !exists $self->{who} || $self->{who}{type} eq "group" || $self->{who}{login} eq $login) { foreach my $key (%{ $self->{values} }) { From fc595e9ee4f580bde310082fa37d2cbf9e54b00d Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 11 Nov 2013 16:57:44 +0100 Subject: [PATCH 020/137] Fix warning --- ACU/Trace.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ACU/Trace.pm b/ACU/Trace.pm index 33dd018..430f9f2 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -354,7 +354,8 @@ sub getIds my $login = shift; my %ids; - if (!$login || $self->{who}{type} eq "group" || $self->{who}{login} eq $login) + log TRACE, $self->{who}; + if (!$login || !exists $self->{who} || $self->{who}{type} eq "group" || $self->{who}{login} eq $login) { while (my ($key, $value) = each %{ $self->{who}{values} }) { From 74f44a836b55da78158443f88514378ea793a759 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 11 Nov 2013 16:59:14 +0100 Subject: [PATCH 021/137] Forgotten use --- ACU/Trace.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ACU/Trace.pm b/ACU/Trace.pm index 430f9f2..5eee413 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -284,6 +284,8 @@ use strict; use warnings; use Carp; +use ACU::Log; + sub new ($$;$) { my $class = shift; From 464fcfc879a1625f71752283235dc23d77bce899 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 11 Nov 2013 17:16:03 +0100 Subject: [PATCH 022/137] Fixing grading --- ACU/Trace.pm | 7 +++---- process/files/intradata_get.pl | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ACU/Trace.pm b/ACU/Trace.pm index 5eee413..687fe66 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -356,16 +356,15 @@ sub getIds my $login = shift; my %ids; - log TRACE, $self->{who}; if (!$login || !exists $self->{who} || $self->{who}{type} eq "group" || $self->{who}{login} eq $login) { - while (my ($key, $value) = each %{ $self->{who}{values} }) + while (my ($key, $value) = each %{ $self->{values} }) { $ids{$key} = $value if ($key); } - } - $ids{ $self->{id} } = $self->getValue($self->{id}, $login); + $ids{ $self->{id} } = $self->getValue($self->{id}, $login); + } return %ids; } diff --git a/process/files/intradata_get.pl b/process/files/intradata_get.pl index c5d3fb5..f33c895 100644 --- a/process/files/intradata_get.pl +++ b/process/files/intradata_get.pl @@ -140,7 +140,7 @@ sub grades_generate close $xmltrace; log DEBUG, "Fill from file: $tr_file"; - log TRACE, $trace->getIds; + log TRACE, $trace->getIds($login); $grading->fill($trace->getIds($login)); } From 5d2b1e80fbbe3b8b9f3a3ad182f89a0a73887b45 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 11 Nov 2013 17:57:27 +0100 Subject: [PATCH 023/137] Merge repo.sh with aurier_j version --- migration/repo.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/migration/repo.sh b/migration/repo.sh index be4338a..d022694 100755 --- a/migration/repo.sh +++ b/migration/repo.sh @@ -20,21 +20,26 @@ tex2md() bi=`basename "$i"` echo -e "\e[1;34m>>>\e[1;37m Trying to convert $i to Markdown...\e[0m" - # BEGIN HACK! Need stacking + # BEGIN HACK! Need stacking + sed -Ei 's/\\(lstinline|class|expected|refer)[^{]*\{([^}]*)\}/\\verb+\2+/gi' "$i" sed -Ei 's/\\distribution\{\}/FreeBSD 9/gi' "$i" sed -Ei 's/\\\{/__OPEN_BRACKET_MINIROOT__/gi' "$i" sed -Ei 's/\\\}/__CLOSE_BRACKET_MINIROOT__/gi' "$i" sed -Ei 's/-\{\}-//gi' "$i" - sed -Ei 's/\\_/_/gi' "$i" + #sed -Ei 's/\\_/_/gi' "$i" # DIRTY HACK - sed -Ei 's/\\includegraphics *\{([^}]+)}/\\verb+%%image(\1)+/gi' "$i" sed -Ei 's/\\include *\{([^}]+)}/\\verb+%%scoped-include(\1)+/gi' "$i" sed -Ei 's/\\input *\{([^}]+)}/\\verb+%%scoped-include(\1)+/gi' "$i" sed -Ei 's/\{\\include *([^}]+)}/\\verb+%%scoped-include(\1)+/gi' "$i" sed -Ei 's/\{\\input *([^}]+)}/\\verb+%%scoped-include(\1)+/gi' "$i" + sed -Ei 's/\\lstinputlisting *\{([^}]+)\}/\\verb+%%scoped-include(\1)+/gi' "$i" sed -Ei 's/\\lstinline *\{([^}]+)}/\\verb+\1+/gi' "$i" + sed -Ei 's/\\structure\{([^}]+)}/\1/gi' "$i" + sed -Ei 's/\\struct\{([^}]+)}/\1/gi' "$i" + sed -Ei 's/\\link\{([^}]+)}/\1/gi' "$i" + sed -Ei 's/\\textasciitilde\{\}/~/gi' "$i" sed -Ei 's/\\begin *\{correction\}/\\begin\{verbatim\}/g' "$i" sed -Ei 's/\\end *\{correction\}/\\end\{verbatim\}/g' "$i" sed -Ei 's/\\begin *\{prompt\}/\\begin\{verbatim\}/g' "$i" @@ -46,11 +51,9 @@ tex2md() sed -Ei 's/\\begin *\{cartouche_nospaces\}/\\begin\{verbatim\}/g' "$i" sed -Ei 's/\\end *\{cartouche_nospaces\}/\\end\{verbatim\}/g' "$i" sed -Ei 's/\\verb ([^+]+) /\\verb+\1+/g' "$i" - sed -Ei 's/``/"/g' "$i" - sed -Ei "s/''/\"/g" "$i" # Special macros - sed -Ei 's/\\(file|email|command|code|bcode) *\{([^}]*)\}/\\verb+\2+/gi' "$i" + sed -Ei 's/\\(file|email|command|bcode|code) *\{([^}]*)\}/\\verb+\2+/gi' "$i" sed -Ei 's/\\begin *\{assistant\}/\\verb+%%assistant-begin+/g' "$i" sed -Ei 's/\\end *\{assistant\}/\\verb+%%assistant-end+/g' "$i" From 81fd3a04e2315b33d550f2e49022bbcb43e34fea Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 13 Nov 2013 00:09:54 +0100 Subject: [PATCH 024/137] Trace: can export as string, can addId --- ACU/Grading.pm | 10 ++-- ACU/Trace.pm | 121 +++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 103 insertions(+), 28 deletions(-) diff --git a/ACU/Grading.pm b/ACU/Grading.pm index 7db43cb..4627024 100644 --- a/ACU/Grading.pm +++ b/ACU/Grading.pm @@ -340,13 +340,15 @@ sub compute ($$$;$$$) my $login = shift; my $ref = $self->{ref}; - if ($login && $ref) { - $ref =~ s/\$LOGIN/$login/; - } + # Handle $LOGIN in ref + $ref =~ s/\$LOGIN/$login/ if ($login && $ref); + + # Handle globbing in ref if (defined $ref) { - eval { + eval + { my $glob = Tinyglob::tinyglob($ref); if ($glob ne $ref) { diff --git a/ACU/Trace.pm b/ACU/Trace.pm index 687fe66..a40929e 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -97,6 +97,38 @@ sub getInfos ($) return $self->{infos}; } +sub addId +{ + my $self = shift; + my $key = shift; + my $value = shift; + + my $e = Trace::Eval->new($key); + $e->addId(undef, $value); + push @{ $self->{groups} }, $e; +} + +sub delId +{ + my $self = shift; + my $key = shift; + my $value = shift; + + foreach my $group (@{ $self->{groups} }) + { + if ($group->{id} eq $key) + { + if (!$value || $value == $group->getValue()) + { + #$self->{groups} = \{ grep { ! } @{ $self->{groups} } }; + } + last; + } + + $group->delId($key, $value); + } +} + sub getIds { my $self = shift; @@ -156,30 +188,19 @@ sub getWhos return $ret; } -sub toString ($;$) +sub toString ($) { my $self = shift; - my $main_grp = shift // "bonus_malus"; my $doc = XML::LibXML::Document->new('1.0'); my $root = $doc->createElement("trace"); - my $group = $doc->createElement("group"); - $group->addChild( $doc->createAttribute("id", $main_grp) ); - - for my $k (keys %{ $self->{ids} }) { - my $e = $doc->createElement("eval"); - my $v = $doc->createElement("value"); - - $e->addChild( $doc->createAttribute("id", $k) ); - $v->appendText( $self->{ids}{$k} ); - - $e->appendChild( $v ); - $group->appendChild( $e ); + foreach my $group (@{ $self->{groups} }) + { + $root->appendChild( $group->toString($doc) ); } - $root->appendChild( $group ); $doc->setDocumentElement( $root ); return $doc->toString(); @@ -214,6 +235,19 @@ sub append ($@) push @{ $self->{groups} }, @_; } +sub delId +{ + my $self = shift; + my $key = shift; + my $value = shift; + + foreach my $item (@{ $self->{groups} }) + { + if ($item->{id} eq ) + $group->delId(@_); + } +} + sub getIds { my $self = shift; @@ -276,6 +310,21 @@ sub getWhos return $ret; } +sub toString($$) +{ + my $self = shift; + my $doc = shift; + + my $gr = $doc->createElement("group"); + + foreach my $item (@{ $self->{groups} }) + { + $gr->appendChild( $item->toString() ); + } + + return $gr; +} + package Trace::Eval; @@ -316,15 +365,8 @@ sub parseEval if ($node->nodeName eq "value") { - my $key; - if ($node->hasAttribute("id")) { - $key = $node->getAttribute("id"); - } else { - $key = ""; - } - - $self->{values}{ $key } = 0 if (!exists $self->{values}{ $key }); - $self->{values}{ $key } += $val; + $self->addValue($node->getAttribute("id"), + $val); } elsif ($node->nodeName eq "name") { @@ -369,6 +411,16 @@ sub getIds return %ids; } +sub addValue +{ + my $self = shift; + my $key = shift // ""; + my $val = shift; + + $self->{values}{ $key } = 0 if (!exists $self->{values}{ $key }); + $self->{values}{ $key } += $val; +} + sub getValue { my $self = shift; @@ -393,4 +445,25 @@ sub getWhos return { $self->{id} => $self->{who} }; } +sub toString($$) +{ + my $self = shift; + my $doc = shift; + + my $e = $doc->createElement("eval"); + + $e->setAttribute("id", $self->{id}); + $e->setAttribute("type", $self->{type}); + + for my $k (keys %{ $self->{values} }) + { + my $v = $doc->createElement("value"); + $v->setAttribute("id", $k) if ($k); + $v->appendTextNode( $self->{values}{$k} ); + $e->appendChild( $v ); + } + + return $e; +} + 1; From 6e3cbe7f04b5c48c42be819701701b83156f981c Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 13 Nov 2013 00:22:19 +0100 Subject: [PATCH 025/137] Fixing syntax --- ACU/Trace.pm | 2 -- 1 file changed, 2 deletions(-) diff --git a/ACU/Trace.pm b/ACU/Trace.pm index a40929e..af873f9 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -243,8 +243,6 @@ sub delId foreach my $item (@{ $self->{groups} }) { - if ($item->{id} eq ) - $group->delId(@_); } } From 0e92592d17370a73b5d458b07e50f1a692c10ca4 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 13 Nov 2013 00:25:36 +0100 Subject: [PATCH 026/137] Fixing method name --- ACU/Trace.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACU/Trace.pm b/ACU/Trace.pm index af873f9..6252e3a 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -104,7 +104,7 @@ sub addId my $value = shift; my $e = Trace::Eval->new($key); - $e->addId(undef, $value); + $e->addValue(undef, $value); push @{ $self->{groups} }, $e; } From 4e35cabf626a9079b3667b87504b7b36bfb1fb4f Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 13 Nov 2013 01:01:04 +0100 Subject: [PATCH 027/137] Display warnings on process return --- ACU/Process.pm | 4 +++- process/files/intradata_get.pl | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ACU/Process.pm b/ACU/Process.pm index 1c94d27..5aa314a 100644 --- a/ACU/Process.pm +++ b/ACU/Process.pm @@ -62,7 +62,10 @@ sub do_work ($$$@) my $sax_handler = ProcessHandler->new($args); my $parser = XML::SAX::ParserFactory->parser( Handler => $sax_handler ); + my $ret; eval { + $SIG{'__WARN__'} = sub { log WARN, $_[0]; $ret .= ">>> ".$_[0]."\n"; }; + $parser->parse_string(${ $_[0]{argref} }); }; if ($@) { @@ -71,7 +74,6 @@ sub do_work ($$$@) return $err; } - my $ret; eval { $ret = $subref->($given_args, $args); }; diff --git a/process/files/intradata_get.pl b/process/files/intradata_get.pl index f33c895..2e84c2f 100644 --- a/process/files/intradata_get.pl +++ b/process/files/intradata_get.pl @@ -215,7 +215,7 @@ sub grades_new_bonus if (-e "$basedir/$year/$project_id/traces/bonus/$login.xml") { open my $xml, "<", "$basedir/$year/$project_id/traces/bonus/$login.xml" or die $!; binmode $xml; - $trace = Trace->new($xml); + $trace = Trace->new(join '', <$xml>); close $xml; } elsif ($delete) { @@ -242,7 +242,7 @@ sub grades_new_bonus close $xml; } else { - log WARN, "Invalid login $line, line skiped"; + warn "Invalid login $line, line skiped"; } } } From c5a1bf89175e07c16cfb0129700b895094c1063e Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 13 Nov 2013 01:12:05 +0100 Subject: [PATCH 028/137] Display important warnings on process return --- ACU/Process.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ACU/Process.pm b/ACU/Process.pm index 5aa314a..c5adc7c 100644 --- a/ACU/Process.pm +++ b/ACU/Process.pm @@ -62,9 +62,9 @@ sub do_work ($$$@) my $sax_handler = ProcessHandler->new($args); my $parser = XML::SAX::ParserFactory->parser( Handler => $sax_handler ); - my $ret; + my @retW; eval { - $SIG{'__WARN__'} = sub { log WARN, $_[0]; $ret .= ">>> ".$_[0]."\n"; }; + $SIG{'__WARN__'} = sub { log WARN, $_[0]; push @retW, $_[0]; }; $parser->parse_string(${ $_[0]{argref} }); }; @@ -74,14 +74,17 @@ sub do_work ($$$@) return $err; } + my $ret; eval { $ret = $subref->($given_args, $args); }; if ($@) { my $err = $@; log ERROR, $err; - return $err; + $ret = $err; } + + $ret .= ">>> ".$_."\n" foreach (@retW); return $ret; } From bdef5a3c691a684117af7f56eb7b6557842475ff Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 13 Nov 2013 01:15:01 +0100 Subject: [PATCH 029/137] New error if project doesn't exists --- process/files/intradata_get.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/process/files/intradata_get.pl b/process/files/intradata_get.pl index 2e84c2f..7ad2c3b 100644 --- a/process/files/intradata_get.pl +++ b/process/files/intradata_get.pl @@ -169,6 +169,7 @@ sub grades_new_bonus croak "No project_id given" if (! $project_id); + die "No such project $project_id in $year" if (! -d "$basedir/$year/$project_id/"); if (! -e "$basedir/$year/$project_id/traces/") { mkdir "$basedir/$year/$project_id/traces/" or die $!; } From 4a66e85060027000df1f38f37e3ccdc246fb7326 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 13 Nov 2013 01:29:53 +0100 Subject: [PATCH 030/137] Fix warning order in process return --- ACU/Process.pm | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ACU/Process.pm b/ACU/Process.pm index c5adc7c..0bd1e4d 100644 --- a/ACU/Process.pm +++ b/ACU/Process.pm @@ -62,10 +62,7 @@ sub do_work ($$$@) my $sax_handler = ProcessHandler->new($args); my $parser = XML::SAX::ParserFactory->parser( Handler => $sax_handler ); - my @retW; eval { - $SIG{'__WARN__'} = sub { log WARN, $_[0]; push @retW, $_[0]; }; - $parser->parse_string(${ $_[0]{argref} }); }; if ($@) { @@ -74,17 +71,18 @@ sub do_work ($$$@) return $err; } - my $ret; + my $ret = ""; eval { - $ret = $subref->($given_args, $args); + $SIG{'__WARN__'} = sub { log WARN, $_[0]; $ret .= ">>> ".$_[0 ]; }; + + $ret .= $subref->($given_args, $args); }; if ($@) { my $err = $@; log ERROR, $err; - $ret = $err; + $ret .= $err; } - $ret .= ">>> ".$_."\n" foreach (@retW); return $ret; } From ca2c0e8f1318af9110230b65900baa9220b4a06d Mon Sep 17 00:00:00 2001 From: Charlie Noyce Root Date: Wed, 13 Nov 2013 02:33:27 +0100 Subject: [PATCH 031/137] Fix get_csv --- process/projects/get_csv.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/process/projects/get_csv.pl b/process/projects/get_csv.pl index 3626b2b..1735abc 100644 --- a/process/projects/get_csv.pl +++ b/process/projects/get_csv.pl @@ -49,7 +49,7 @@ sub process my $i; for ($i = 0; $i <= $#ugrades; $i++) { - if ($ugrades[$i] == $grade->getAttribute("name")) + if ($ugrades[$i] eq $grade->getAttribute("name")) { $ugrades[$i] = $grade->getAttribute("value"); last; @@ -75,7 +75,8 @@ sub process } $out .= "\n"; - for my $login (keys %grades) { + for my $login (keys %grades) + { $out .= "$login"; my @ugrades = @{ $grades{$login} }; for my $header (@headers) From e2ba0a5e38ee33ca8ab79231aa6186ae067cfe43 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 13 Nov 2013 03:00:55 +0100 Subject: [PATCH 032/137] Remove exception #21858 --- hooks/gl-pre-git | 1 - 1 file changed, 1 deletion(-) diff --git a/hooks/gl-pre-git b/hooks/gl-pre-git index 65c8952..5f6fd16 100755 --- a/hooks/gl-pre-git +++ b/hooks/gl-pre-git @@ -49,7 +49,6 @@ if ($ip->overlaps($labnetwork) == $IP_A_IN_B_OVERLAP) #} exit 0 if (grep { /\Q$repo_login\E/ } @habitent_loin); -exit 0 if ($repo_login eq "bellev_m"); my $schoolnetwork = Net::IP->new('10.41.0.0/16'); #my $vjschoolnetwork = Net::IP->new('10.3.0.0/16'); From bedb084ffed8b52d141df1ee62d96c16505cbe30 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 13 Nov 2013 03:07:56 +0100 Subject: [PATCH 033/137] Add average in cvs --- process/projects/get_csv.pl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/process/projects/get_csv.pl b/process/projects/get_csv.pl index 1735abc..2e5f24c 100644 --- a/process/projects/get_csv.pl +++ b/process/projects/get_csv.pl @@ -31,6 +31,7 @@ sub process my %grades; my @headers; + my @averages; opendir(my $dh, "$basedir/$year/$project_id/grades/") or croak "can't opendir $basedir/$year/$project_id/grades/: $!"; for my $gfile (grep { ( ! /^\./ ) && -f "$basedir/$year/$project_id/grades/$_" } readdir($dh)) @@ -52,6 +53,7 @@ sub process if ($ugrades[$i] eq $grade->getAttribute("name")) { $ugrades[$i] = $grade->getAttribute("value"); + $averages[$i] += $grade->getAttribute("value"); last; } } @@ -60,6 +62,7 @@ sub process { push @headers, $grade->getAttribute("name"); push @ugrades, $grade->getAttribute("value"); + push @averages, $grade->getAttribute("value"); } } @@ -70,13 +73,15 @@ sub process # Print CSV my $out = "login"; - for my $header (@headers) { + foreach my $header (@headers) { $out .= ",$header"; } $out .= "\n"; - for my $login (keys %grades) + my $nb = 0; + foreach my $login (keys %grades) { + $nb += 1; $out .= "$login"; my @ugrades = @{ $grades{$login} }; for my $header (@headers) @@ -92,6 +97,13 @@ sub process $out .= "\n"; } + $out .= "Average"; + foreach my $average (@averages) + { + $out .= ",".($average / $nb); + } + $out .= "\n"; + return $out; } From 95c6d77613f908a10b1feddc235725c9e49aa8ab Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 14 Nov 2013 14:19:45 +0100 Subject: [PATCH 034/137] Fix gen_grading due to lastest modification --- process/projects/gen_grading.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/projects/gen_grading.pl b/process/projects/gen_grading.pl index b365932..fa5c261 100644 --- a/process/projects/gen_grading.pl +++ b/process/projects/gen_grading.pl @@ -80,7 +80,7 @@ sub process open my $xml, "<", "$basedir/$year/$project_id/traces/$dir/$login" or die $!; binmode $xml; - my $trace = Trace->new($xml); + my $trace = Trace->new(join '', <$xml>); my %tids = %{ $trace->getIds() }; for my $kid (keys %tids) From e11d9082da83c0d67965567f403c8472c70d887e Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 14 Nov 2013 15:26:17 +0100 Subject: [PATCH 035/137] Activate mail_error on grading script --- process/projects/gen_grading.pl | 4 ++-- process/projects/get_csv.pl | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/process/projects/gen_grading.pl b/process/projects/gen_grading.pl index fa5c261..0597c10 100644 --- a/process/projects/gen_grading.pl +++ b/process/projects/gen_grading.pl @@ -7,8 +7,6 @@ use Carp; use Pod::Usage; use Text::ParseWords; -use lib "../../"; - use ACU::Defense; use ACU::Grading; use ACU::Log; @@ -16,6 +14,8 @@ use ACU::LDAP; use ACU::Process; use ACU::Trace; +$ACU::Log::mail_error = 1; + our $basedir = "/intradata"; sub process diff --git a/process/projects/get_csv.pl b/process/projects/get_csv.pl index 2e5f24c..fa21f79 100644 --- a/process/projects/get_csv.pl +++ b/process/projects/get_csv.pl @@ -12,6 +12,8 @@ use ACU::Log; use ACU::LDAP; use ACU::Process; +$ACU::Log::mail_error = 1; + our $basedir = "/intradata"; sub process @@ -23,11 +25,7 @@ sub process my $year = shift @args // LDAP::get_year; # Project existing? - if (! -d "$basedir/$year/$project_id") - { - log ERROR, "Unable to find $project_id in $year"; - return "Unable to find $project_id in $year\n"; - } + croak "Unable to find $project_id in $year" if (! -d "$basedir/$year/$project_id"); my %grades; my @headers; From 54b407fa11d698a3702f9332fe1440aafd503d65 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 14 Nov 2013 15:47:25 +0100 Subject: [PATCH 036/137] Fix requires Email::Sender::Simple thanks to TIBO --- ACU/Log.pm | 2 +- utils/lpt | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ACU/Log.pm b/ACU/Log.pm index 8c67f22..11210d9 100644 --- a/ACU/Log.pm +++ b/ACU/Log.pm @@ -67,7 +67,7 @@ sub log if ($mail_error && $level <= ERROR) { - require "Email::Sender::Simple"; + require Email::Sender::Simple; my $mail = Email::MIME->create( header_str => [ From => "Roots assistants ", diff --git a/utils/lpt b/utils/lpt index c96d936..a3b205f 100755 --- a/utils/lpt +++ b/utils/lpt @@ -1405,7 +1405,7 @@ sub cmd_account_quota_sync($;$) my $quotaSgoinfreBlock = $entry->get_value("quotaSgoinfreBlock") // $def_quota{block}{sgoinfre}; my $quotaSgoinfreFile = $entry->get_value("quotaSgoinfreFile") // $def_quota{file}{sgoinfre}; - require "Quota"; + require Quota; if (Quota::setqlim($dev_quota{home}, $entry->get_value("uidNumber"), int(0.9 * $quotaHomeBlock), $quotaHomeBlock, int(0.9 * $quotaHomeFile), $quotaHomeFile, 1, 0) == 0 and Quota::setqlim($dev_quota{sgoinfre}, $entry->get_value("uidNumber"), int(0.9 * $quotaSgoinfreBlock), $quotaSgoinfreBlock, int(0.9 * $quotaSgoinfreFile), $quotaSgoinfreFile, 1, 0) == 0) { @@ -1429,7 +1429,7 @@ sub cmd_account_quota_sync($;$) sub cmd_sync_quota(@) { - require "Quota"; + require Quota; # Set root quota Quota::setqlim($dev_quota{home}, 0, 0, 0, 0, 0, 1, 0); @@ -1512,7 +1512,7 @@ sub cmd_no_strong_auth_view(@) sub cmd_no_strong_auth_warn(@) { - require "Email::Sender::Simple"; + require Email::Sender::Simple; for my $entry (get_no_strong_auth_user()) { @@ -1553,7 +1553,7 @@ Les roots ACU"; sub cmd_no_strong_auth_close(@) { - require "Email::Sender::Simple"; + require Email::Sender::Simple; for my $entry (get_no_strong_auth_user()) { @@ -1706,7 +1706,7 @@ sub cmd_ssh_keys_without_passphrase_view(@) # warn about unprotected keys sub cmd_ssh_keys_without_passphrase_warn(@) { - require "Email::Sender::Simple"; + require Email::Sender::Simple; my $process = sub() { my $entry = shift; @@ -1760,7 +1760,7 @@ Les roots ACU"; # remove unprotected keys sub cmd_ssh_keys_without_passphrase_remove(@) { - require "Email::Sender::Simple"; + require Email::Sender::Simple; my $process = sub() { my $entry = shift; From a4076fe953361df7d6aeecab6c27bc456321ef9b Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 14 Nov 2013 15:56:48 +0100 Subject: [PATCH 037/137] Add Email::Sender::Simple as require deb pkg --- commands/first-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/first-install.sh b/commands/first-install.sh index aefede4..47157b7 100755 --- a/commands/first-install.sh +++ b/commands/first-install.sh @@ -1,7 +1,7 @@ #! /bin/bash # Install missing packages -DEB_PACKAGES_LIST="screen libnet-ldap-perl libxml-libxml-perl libgearman-client-perl libmailtools-perl libmail-sendmail-perl libdatetime-format-iso8601-perl libnet-ip-perl libsys-gamin-perl libdigest-sha-perl libemail-mime-perl" +DEB_PACKAGES_LIST="screen libnet-ldap-perl libxml-libxml-perl libgearman-client-perl libmailtools-perl libdatetime-format-iso8601-perl libnet-ip-perl libsys-gamin-perl libdigest-sha-perl libemail-mime-perl libemail-sender-perl" ARCH_PACKAGES_LIST="screen perl-io-socket-ssl perl-email-simple perl-email-mime perl-term-readkey perl-ldap perl-lwp-protocol-https perl-datetime-format-iso8601 perl-net-ip" # aur/perl-sys-gamin GENTOO_PACKAGES_LIST="app-misc/screen dev-perl/IO-Socket-SSL dev-perl/Email-Simple dev-perl/Email-MIME dev-perl/TermReadKey dev-perl/perl-ldap dev-perl/LWP-Protocol-https dev-perl/DateTime-Format-ISO8601 dev-perl/Net-IP" FBSD_PACKAGES_LIST="screen p5-IO-Socket-SSL p5-Email-Simple p5-Email-MIME p5-Term-ANSIColor p5-Term-ReadKey p5-LWP-Protocol-https p5-DateTime-Format-ISO8601 p5-Net-IP p5-Sys-Gamin" From 33e32d29166967827a2adb9ec9ebfd0b54fe10f7 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 14 Nov 2013 16:03:30 +0100 Subject: [PATCH 038/137] Add charset to sended log email --- ACU/Log.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ACU/Log.pm b/ACU/Log.pm index 11210d9..64c4bdc 100644 --- a/ACU/Log.pm +++ b/ACU/Log.pm @@ -4,6 +4,10 @@ use v5.10.1; use strict; use warnings; use Carp; +use utf8; +use open IO => ':utf8'; +use open ':std'; + use Data::Dumper; use Email::MIME; use Exporter 'import'; @@ -74,6 +78,11 @@ sub log To => "Roots assistants ", Subject => "[LERDORF][ERROR] ".join(' ', @_) ], + attributes => { + encoding => 'quoted-printable', + charset => 'utf-8', + format => 'flowed', + }, body_str => "Bonjour, Une erreur de niveau $level est survenue sur la machine $HOSTNAME. From 947aebd490d12498769d9b9b26a628f9c83f5c15 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 14 Nov 2013 16:09:24 +0100 Subject: [PATCH 039/137] Add sendmail option --- ACU/Log.pm | 2 +- utils/lpt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ACU/Log.pm b/ACU/Log.pm index 64c4bdc..5d751b8 100644 --- a/ACU/Log.pm +++ b/ACU/Log.pm @@ -71,7 +71,7 @@ sub log if ($mail_error && $level <= ERROR) { - require Email::Sender::Simple; + require Email::Sender::Simple qw(sendmail); my $mail = Email::MIME->create( header_str => [ From => "Roots assistants ", diff --git a/utils/lpt b/utils/lpt index a3b205f..78e3763 100755 --- a/utils/lpt +++ b/utils/lpt @@ -1512,7 +1512,7 @@ sub cmd_no_strong_auth_view(@) sub cmd_no_strong_auth_warn(@) { - require Email::Sender::Simple; + require Email::Sender::Simple qw(sendmail); for my $entry (get_no_strong_auth_user()) { @@ -1553,7 +1553,7 @@ Les roots ACU"; sub cmd_no_strong_auth_close(@) { - require Email::Sender::Simple; + require Email::Sender::Simple qw(sendmail); for my $entry (get_no_strong_auth_user()) { @@ -1706,7 +1706,7 @@ sub cmd_ssh_keys_without_passphrase_view(@) # warn about unprotected keys sub cmd_ssh_keys_without_passphrase_warn(@) { - require Email::Sender::Simple; + require Email::Sender::Simple qw(sendmail); my $process = sub() { my $entry = shift; @@ -1760,7 +1760,7 @@ Les roots ACU"; # remove unprotected keys sub cmd_ssh_keys_without_passphrase_remove(@) { - require Email::Sender::Simple; + require Email::Sender::Simple qw(sendmail); my $process = sub() { my $entry = shift; From 5247d4db535bef903efa8ab3faf0c873c99ab6c8 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 14 Nov 2013 16:20:13 +0100 Subject: [PATCH 040/137] Add sendmail option --- ACU/Log.pm | 3 ++- utils/lpt | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ACU/Log.pm b/ACU/Log.pm index 5d751b8..491df18 100644 --- a/ACU/Log.pm +++ b/ACU/Log.pm @@ -71,7 +71,8 @@ sub log if ($mail_error && $level <= ERROR) { - require Email::Sender::Simple qw(sendmail); + require Email::Sender::Simple; + Email::Sender::Simple->import(qw(sendmail)); my $mail = Email::MIME->create( header_str => [ From => "Roots assistants ", diff --git a/utils/lpt b/utils/lpt index 78e3763..ea342b0 100755 --- a/utils/lpt +++ b/utils/lpt @@ -1512,7 +1512,8 @@ sub cmd_no_strong_auth_view(@) sub cmd_no_strong_auth_warn(@) { - require Email::Sender::Simple qw(sendmail); + require Email::Sender::Simple; + Email::Sender::Simple->import(qw(sendmail)); for my $entry (get_no_strong_auth_user()) { @@ -1553,7 +1554,8 @@ Les roots ACU"; sub cmd_no_strong_auth_close(@) { - require Email::Sender::Simple qw(sendmail); + require Email::Sender::Simple; + Email::Sender::Simple->import(qw(sendmail)); for my $entry (get_no_strong_auth_user()) { @@ -1706,7 +1708,8 @@ sub cmd_ssh_keys_without_passphrase_view(@) # warn about unprotected keys sub cmd_ssh_keys_without_passphrase_warn(@) { - require Email::Sender::Simple qw(sendmail); + require Email::Sender::Simple; + Email::Sender::Simple->import(qw(sendmail)); my $process = sub() { my $entry = shift; @@ -1760,7 +1763,8 @@ Les roots ACU"; # remove unprotected keys sub cmd_ssh_keys_without_passphrase_remove(@) { - require Email::Sender::Simple qw(sendmail); + require Email::Sender::Simple; + Email::Sender::Simple->import(qw(sendmail)); my $process = sub() { my $entry = shift; From b95918771861f61d199a36d18b8d78f6ab33839a Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 14 Nov 2013 17:35:14 +0100 Subject: [PATCH 041/137] Fix sendmail --- ACU/Log.pm | 2 +- utils/lpt | 28 ++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ACU/Log.pm b/ACU/Log.pm index 491df18..c9685fe 100644 --- a/ACU/Log.pm +++ b/ACU/Log.pm @@ -99,7 +99,7 @@ Cordialement, -- The lerdorf project", ); - Email::Sender::Simple::sendmail($mail); + sendmail($mail); } if ($level <= $display_level) { diff --git a/utils/lpt b/utils/lpt index ea342b0..bae4179 100755 --- a/utils/lpt +++ b/utils/lpt @@ -1546,9 +1546,14 @@ Les roots ACU"; Cc => 'Roots assistants ', Subject => "[PILA][AUTH-FORTE] Authentification forte SSH non active" ], + attributes => { + encoding => 'quoted-printable', + charset => 'utf-8', + format => 'flowed', + }, body_str => $body, ); - Email::Sender::Simple::sendmail($mail); + sendmail($mail); } } @@ -1584,9 +1589,14 @@ Les roots ACU"; Cc => 'Roots assistants ', Subject => "[PILA][ACCES] Compte suspendu" ], + attributes => { + encoding => 'quoted-printable', + charset => 'utf-8', + format => 'flowed', + }, body_str => $body, ); - Email::Sender::Simple::sendmail($mail); + sendmail($mail); } } @@ -1752,9 +1762,14 @@ Les roots ACU"; Cc => 'Roots assistants ', Subject => "[PILA][SSH-KEY] Clef SSH non protégée" ], + attributes => { + encoding => 'quoted-printable', + charset => 'utf-8', + format => 'flowed', + }, body_str => $body, ); - Email::Sender::Simple::sendmail($mail); + sendmail($mail); }; cmd_ssh_keys_without_passphrase_generic(\&$process); @@ -1813,9 +1828,14 @@ Les roots ACU"; Cc => 'Roots assistants ', Subject => "[PILA][SSH-KEY] Clef SSH non protégée supprimée" ], + attributes => { + encoding => 'quoted-printable', + charset => 'utf-8', + format => 'flowed', + }, body_str => $body, ); - Email::Sender::Simple::sendmail($mail); + sendmail($mail); }; cmd_ssh_keys_without_passphrase_generic(\&$process); From 9bcf8c7c2db50255f43ac705285928b0d15d6cce Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 14 Nov 2013 20:34:12 +0100 Subject: [PATCH 042/137] Update gl-pre-git exceptions --- hooks/gl-pre-git | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/gl-pre-git b/hooks/gl-pre-git index 5f6fd16..c7d0dca 100755 --- a/hooks/gl-pre-git +++ b/hooks/gl-pre-git @@ -19,7 +19,7 @@ my $promo = qx(git config hooks.promo); my $id_project = qx(git config hooks.idproject); my $repo_login = qx(git config hooks.repologin); -my @habitent_loin = ("abdeln_a", "amed_m", "bellev_m", "faure_n", "freima_m", "ikouna_l", "simon_j"); +my @habitent_loin = qw(amed_m bellev_m freima_m ikouna_l simon_j faure_n abdelm_a habri_z trang_d henrie_p verbec_y); # First, check if the repository is in the YYYY/ directory exit 0 if (($promo && $id_project && $repo_login) || $ENV{GL_REPO} !~ /^2[0-9]{3}\/.+\/.+/); From 1d5562b073a8725458ae5ecef14fb1af25d3187c Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Fri, 15 Nov 2013 08:39:52 +0100 Subject: [PATCH 043/137] New repo.sh migration --- migration/repo.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/migration/repo.sh b/migration/repo.sh index d022694..23af34c 100755 --- a/migration/repo.sh +++ b/migration/repo.sh @@ -84,7 +84,7 @@ tex2md() git rm -f "$i" > /dev/null fi - sed -Ei 's/`%%([a-z-])\(([^)]+)\)`/%%\1(\2)/gi' "$DEST/${bi%%.tex}.md" + sed -Ei 's/`%%([a-z-]+)\(([^)]+)\)`/%%\1(\2)/gi' "$DEST/${bi%%.tex}.md" sed -Ei 's/\\$/\n/' "$DEST/${bi%%.tex}.md" done } @@ -114,7 +114,7 @@ clean_tex() exit 1; fi - for f in data Makefile images/acu.pdf images/assistants.pdf images/assistants-subject.pdf images/assistants-slides.pdf images/assistants.png images/epita.pdf images/epita.png images/epita-invert.pdf images/assistants-invert.pdf images/epita-invert.png images/assistants-bg.png images/logo_epita.jpg images/acu-bottom.png images/acu-bottom.pdf images/acu-bg.pdf images/acu2011.png images/acu.png *.cls *.sty + for f in data Makefile images/acu.pdf images/assistants.pdf images/assistants-subject.pdf images/assistants-slides.pdf images/assistants.png images/epita.pdf images/epita.png images/epita-invert.pdf images/assistants-invert.pdf images/epita-invert.png images/assistants-bg.png images/logo_epita.jpg images/acu-bottom.png images/acu-bottom.pdf images/acu-bg.pdf images/acu2011.png images/acu.png images/acu_2012_logo_hd.png *.cls *.sty *.toc do if [ -f "$f" ] then @@ -161,7 +161,7 @@ clean_tex() elif [ `find -mindepth 1 -maxdepth 1 -name '*.tex' | wc -l` -gt 0 ] then tex2md . - + else for i in * do @@ -231,7 +231,7 @@ if ls | grep "moulette" then echo -e "\e[1;34m>>>\e[1;37m Creating moulette branch...\e[0m" git checkout -b moulette - + find -mindepth 1 -maxdepth 1 ! -name moulette ! -name tests ! -name .git -exec git rm -rf {} \; git rm -f moulette/DESC 2> /dev/null @@ -321,6 +321,7 @@ do then echo -e "\e[1;32m##\e[1;37m Find directory $DIR with some .tex files \e[1;32m##\e[0m" cd "$DIR" + git rm *.tex clean_tex `pwd` `readlink -f "$(pwd)/.."` echo -e "\e[1;32m## ## ## ## ##\e[0m" echo @@ -348,6 +349,18 @@ do git rm -rf "$f" > /dev/null fi done + + # Append Fact lines + if [ -f "Makefile" ] + then + cat <> Makefile +fact: + rm -rf ref.ff + \${FACT} package create ../ref ref.ff + \${FACT} make make ref.ff ref.ff +EOF + fi + cd - > /dev/null fi done From a809c4ff8dc9cfad57f17fdce80f1b57ace630fc Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Fri, 15 Nov 2013 08:49:59 +0100 Subject: [PATCH 044/137] COnvert to UTF8 lpt --- utils/lpt | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) mode change 100755 => 100644 utils/lpt diff --git a/utils/lpt b/utils/lpt old mode 100755 new mode 100644 index bae4179..3537346 --- a/utils/lpt +++ b/utils/lpt @@ -3,6 +3,9 @@ use v5.10.1; use strict; use warnings; +use utf8; +use open IO => ':utf8'; +use open ':std'; use Digest::SHA; use Email::MIME; @@ -251,7 +254,7 @@ sub cmd_account_create($@) my $login = shift; if ($#_ < 3) { - log(USAGE, "lpt account create [nopass|passgen|password]"); + log(USAGE, "lpt account create [nopass|passgen|password]"); return 1; } @@ -1523,9 +1526,9 @@ sub cmd_no_strong_auth_warn(@) my $body = "Bonjour ".$entry->get_value("cn").", -Vous n'avez pas activé l'authentification forte pour SSH. +Vous n'avez pas activé l'authentification forte pour SSH. -Pour connaître la marche à suivre pour l'activer, consultez : +Pour connaître la marche à suivre pour l'activer, consultez : https://www.acu.epita.fr/wiki/index.php?title=Ssh_double_factor_auth Merci de rectifier la situation au plus vite ou votre compte sera mis @@ -1533,8 +1536,8 @@ en suspens. Cordialement, -P.-S. : Ce message est généré automatiquement, les roots sont en copie. - Pour toute demande, merci de faire un ticket à admin\@acu.epita.fr +P.-S. : Ce message est généré automatiquement, les roots sont en copie. + Pour toute demande, merci de faire un ticket à admin\@acu.epita.fr -- Les roots ACU"; @@ -1570,10 +1573,10 @@ sub cmd_no_strong_auth_close(@) my $body = "Bonjour ".$entry->get_value("cn").", -Après plusieurs relances de notre part, vous n'avez toujours pas activé -l'authentification forte pour SSH. Votre compte a donc été suspendu. +Après plusieurs relances de notre part, vous n'avez toujours pas activé +l'authentification forte pour SSH. Votre compte a donc été suspendu. -Nous vous invitons à passer au laboratoire pour faire réactiver votre +Nous vous invitons à passer au laboratoire pour faire réactiver votre compte. Cordialement, @@ -1730,11 +1733,11 @@ sub cmd_ssh_keys_without_passphrase_warn(@) my $body = "Bonjour ".$entry->get_value("cn").", -Un outil automatique a découvert une clef sans passphrase sur votre compte -du laboratoire. Il est impératif de mettre une passphrase chiffrant votre -clef pour des raisons de sécurité. +Un outil automatique a découvert une clef sans passphrase sur votre compte +du laboratoire. Il est impératif de mettre une passphrase chiffrant votre +clef pour des raisons de sécurité. -Les clefs non protégées sont les suivantes :\n"; +Les clefs non protégées sont les suivantes :\n"; foreach my $key (@$keys) { $key =~ s#^$nfsHomePrefix#$wksHomePrefix#; @@ -1743,13 +1746,13 @@ Les clefs non prot $body .= "\nPour mettre une passphrase : \$ ssh-keygen -p -f CHEMIN_VERS_LA_CLE_PRIVEE -Merci de rectifier la situation au plus vite ou votre clé sera supprimée et +Merci de rectifier la situation au plus vite ou votre clé sera supprimée et votre compte sera mis en suspens. Cordialement, -PS: Ce message est généré automatiquement, les roots sont en copie. - Pour toute demande, merci de faire un ticket à admin\@acu.epita.fr +PS: Ce message est généré automatiquement, les roots sont en copie. + Pour toute demande, merci de faire un ticket à admin\@acu.epita.fr -- Les roots ACU"; @@ -1760,7 +1763,7 @@ Les roots ACU"; From => "Roots assistants ", To => $entry->get_value("mailAlias"), Cc => 'Roots assistants ', - Subject => "[PILA][SSH-KEY] Clef SSH non protégée" + Subject => "[PILA][SSH-KEY] Clef SSH non protégée" ], attributes => { encoding => 'quoted-printable', @@ -1791,13 +1794,13 @@ sub cmd_ssh_keys_without_passphrase_remove(@) # create the message my $body = "Bonjour ".$entry->get_value("cn").", -Un outil automatique a découvert une clef sans passphrase sur votre +Un outil automatique a découvert une clef sans passphrase sur votre compte du laboratoire. -N'ayant pas corrigé votre situation après plusieurs relances, nous avons -désactivé votre compte et supprimé le(s) clef(s) incriminées. +N'ayant pas corrigé votre situation après plusieurs relances, nous avons +désactivé votre compte et supprimé le(s) clef(s) incriminées. -Pour information, voici l'empreinte de chacune des clefs supprimée :\n"; +Pour information, voici l'empreinte de chacune des clefs supprimée :\n"; foreach my $key (@$keys) { open (FNGR, "ssh-keygen -l -f '$key' | cut -d ' ' -f 2 |"); @@ -1815,8 +1818,8 @@ Contacter les roots pour faire reouvrir votre compte. Cordialement, -PS: Ce message est généré automatiquement, les roots sont en copie. - Pour toute demande, merci de faire un ticket à admin\@acu.epita.fr +PS: Ce message est généré automatiquement, les roots sont en copie. + Pour toute demande, merci de faire un ticket à admin\@acu.epita.fr -- Les roots ACU"; @@ -1826,7 +1829,7 @@ Les roots ACU"; From => "Roots assistants ", To => $entry->get_value("mailAlias"), Cc => 'Roots assistants ', - Subject => "[PILA][SSH-KEY] Clef SSH non protégée supprimée" + Subject => "[PILA][SSH-KEY] Clef SSH non protégée supprimée" ], attributes => { encoding => 'quoted-printable', From 77bee709ed615af1af8c12fec66bb1b303474cd2 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Fri, 15 Nov 2013 09:04:45 +0100 Subject: [PATCH 045/137] LDAP name convert to IPv6 --- utils/lpt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/utils/lpt b/utils/lpt index 3537346..354ee81 100644 --- a/utils/lpt +++ b/utils/lpt @@ -7,6 +7,7 @@ use utf8; use open IO => ':utf8'; use open ':std'; +use Encode qw(decode); use Digest::SHA; use Email::MIME; use File::Find; @@ -1524,7 +1525,7 @@ sub cmd_no_strong_auth_warn(@) say $entry->get_value("uid"); - my $body = "Bonjour ".$entry->get_value("cn").", + my $body = "Bonjour ".decode('UTF-8', $entry->get_value("cn"), Encode::FB_CROAK).", Vous n'avez pas activé l'authentification forte pour SSH. @@ -1571,7 +1572,7 @@ sub cmd_no_strong_auth_close(@) say $entry->get_value("uid"); - my $body = "Bonjour ".$entry->get_value("cn").", + my $body = "Bonjour ".decode('UTF-8', $entry->get_value("cn"), Encode::FB_CROAK).", Après plusieurs relances de notre part, vous n'avez toujours pas activé l'authentification forte pour SSH. Votre compte a donc été suspendu. @@ -1731,7 +1732,7 @@ sub cmd_ssh_keys_without_passphrase_warn(@) # Display say $entry->get_value("uid"); - my $body = "Bonjour ".$entry->get_value("cn").", + my $body = "Bonjour ".decode('UTF-8', $entry->get_value("cn"), Encode::FB_CROAK).", Un outil automatique a découvert une clef sans passphrase sur votre compte du laboratoire. Il est impératif de mettre une passphrase chiffrant votre @@ -1792,7 +1793,7 @@ sub cmd_ssh_keys_without_passphrase_remove(@) say $entry->get_value("uid"); # create the message - my $body = "Bonjour ".$entry->get_value("cn").", + my $body = "Bonjour ".decode('UTF-8', $entry->get_value("cn"), Encode::FB_CROAK).", Un outil automatique a découvert une clef sans passphrase sur votre compte du laboratoire. From 984cb050fab15d6f2b580b06e076309cb48a0d03 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Fri, 15 Nov 2013 09:21:33 +0100 Subject: [PATCH 046/137] Allow .google-authenticator under 100b --- utils/lpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/lpt b/utils/lpt index 354ee81..584096f 100644 --- a/utils/lpt +++ b/utils/lpt @@ -1496,7 +1496,7 @@ sub get_no_strong_auth_user() my $token = $home . "/.google_authenticator"; my $login = $entry->get_value("uid"); - push @faulty_users, $entry if (! -f $token || -s $token < 100); + push @faulty_users, $entry if (! -f $token || -s $token < 90); } $ldap->unbind or die ("couldn't disconnect correctly"); From 2f6b3a9812daca51b844a63b8faa56ab4af537aa Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Fri, 15 Nov 2013 12:40:29 +0100 Subject: [PATCH 047/137] Fix LDAP search --- ACU/LDAP.pm | 3 +++ utils/lpt | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ACU/LDAP.pm b/ACU/LDAP.pm index 04b94e7..ac90bbf 100644 --- a/ACU/LDAP.pm +++ b/ACU/LDAP.pm @@ -189,6 +189,9 @@ sub get_dn($$@) my $ldap = shift // ldap_connect(); my $dn = shift; + my $base = BASE_DN; + $dn = "$dn," . BASE_DN if ($dn !~ /$base$/); + my $mesg = $ldap->search( # search base => "$dn", filter => Net::LDAP::Filter->new("(objectClass=*)"), diff --git a/utils/lpt b/utils/lpt index 584096f..acc9162 100644 --- a/utils/lpt +++ b/utils/lpt @@ -266,7 +266,7 @@ sub cmd_account_create($@) my $ldap = LDAP::ldap_connect(); # Check if the OU exists - my $oudn = "ou=$group,ou=users,dc=acu,dc=epita,dc=fr"; + my $oudn = "ou=$group,ou=users"; my $ou = LDAP::get_dn($ldap, $oudn); if (! $ou) @@ -841,7 +841,7 @@ sub cmd_groups($@) if ($gname && $gname =~ /^(2[0-9]{3})$/) { - $ou = "year=$1,$ou"; + $ou = "ou=$1,$ou"; $gname = shift; } @@ -1048,7 +1048,7 @@ sub cmd_group_create log(DEBUG, "Adding dn: cn=$gname,ou=intra,ou=groups,dc=acu,dc=epita,dc=fr ..."); - my $dn = "cn=$gname,$ou,dc=acu,dc=epita,dc=fr"; + my $dn = "cn=$gname,$ou"; my $class; $class = "intraGroup" if ($ou ne $group_types{system}); @@ -1060,7 +1060,7 @@ sub cmd_group_create }; log(ERROR, $@) if ($@); - my $mesg = $ldap->add( $dn, + my $mesg = $ldap->add( $dn . ",dc=acu,dc=epita,dc=fr", attrs => [ objectclass => [ "top", $class ], cn => $gname, @@ -1084,7 +1084,7 @@ sub cmd_group_delete(@) my $ou = shift; my $gname = shift; - my $dn = "cn=$gname,$ou,dc=acu,dc=epita,dc=fr"; + my $dn = "cn=$gname,$ou"; log(DEBUG, "Deleting dn: $dn ..."); From db62048be24010cd3c642f724861949099469870 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sat, 16 Nov 2013 13:32:39 +0100 Subject: [PATCH 048/137] Hook: Use GL_USER instead of repo_login --- hooks/gl-pre-git | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/gl-pre-git b/hooks/gl-pre-git index c7d0dca..2491039 100755 --- a/hooks/gl-pre-git +++ b/hooks/gl-pre-git @@ -48,7 +48,7 @@ if ($ip->overlaps($labnetwork) == $IP_A_IN_B_OVERLAP) # exit 1; #} -exit 0 if (grep { /\Q$repo_login\E/ } @habitent_loin); +exit 0 if (grep { /\Q$ENV{GL_USER}\E/ } @habitent_loin); my $schoolnetwork = Net::IP->new('10.41.0.0/16'); #my $vjschoolnetwork = Net::IP->new('10.3.0.0/16'); From dcb6033caa5dbdb9c264b4be42849aca3ea3e483 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sat, 16 Nov 2013 21:45:25 +0100 Subject: [PATCH 049/137] Add new scripts for moulettes --- commands/moulette/launch.sh | 43 ++++++++++++++++++++++++++++++++++++ commands/moulette/sendgit.sh | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100755 commands/moulette/launch.sh create mode 100755 commands/moulette/sendgit.sh diff --git a/commands/moulette/launch.sh b/commands/moulette/launch.sh new file mode 100755 index 0000000..c591920 --- /dev/null +++ b/commands/moulette/launch.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +if [ -z "$2" ] +then + echo "Usage: $0 [year] [login ...]" + exit 1 +fi + +if ! which gearman > /dev/null 2> /dev/null +then + echo "gearman isn't installed on this machine. Please try another one." + exit 1 +fi + +if [ "x${1:0:2}" = "x20" ] +then + YEAR=" $1" + shift +else + YEAR= +fi +PROJECT_ID=$1 +RENDU=$2 + +shift 2 + +LOGINS= +while [ $# -gt 0 ] +do + LOGINS=" $1 +" + shift +done + +cat < + + moulette +$YEAR + $PROJECT_ID + $RENDU +$LOGINS +EOF diff --git a/commands/moulette/sendgit.sh b/commands/moulette/sendgit.sh new file mode 100755 index 0000000..07b92ad --- /dev/null +++ b/commands/moulette/sendgit.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +if [ -z "$2" ] +then + echo "Usage: $0 [year] [login ...]" + exit 1 +fi + +if ! which gearman > /dev/null 2> /dev/null +then + echo "gearman isn't installed on this machine. Please try another one." + exit 1 +fi + +if [ "x${1:0:2}" = "x20" ] +then + YEAR=" $1" + shift +else + YEAR= +fi +PROJECT_ID=$1 +RENDU=$2 + +shift 2 + +while [ $# -gt 0 ] +do + LOGIN=$1 + cat < + +$YEAR + $PROJECT_ID + $RENDU + $LOGIN + +EOF + shift +done From 555c922786631f30f6e3d455802c9a2cd73dc5e9 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 18 Nov 2013 18:57:30 +0100 Subject: [PATCH 050/137] send_git: Year can be omitted --- process/files/send_git.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/process/files/send_git.pl b/process/files/send_git.pl index db2f924..8f29176 100644 --- a/process/files/send_git.pl +++ b/process/files/send_git.pl @@ -7,6 +7,7 @@ use v5.10; use File::Path qw(remove_tree); use File::Temp qw/tempfile tempdir/; +use ACU::LDAP; use ACU::Log; use ACU::Process; @@ -15,7 +16,7 @@ sub process { my ($given_args, $args) = @_; - my $year = $args->{param}{year}; + my $year = $args->{param}{year} // LDAP::get_year(); my $project_id = $args->{param}{id}; my $rendu = $args->{param}{rendu}; my $login = $args->{param}{login}; From f02f484cb8f5840c7a51a79faca0259472382c98 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 18 Nov 2013 22:28:10 +0100 Subject: [PATCH 051/137] gen_grades: better resolution of names --- process/files/intradata_get.pl | 62 ++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/process/files/intradata_get.pl b/process/files/intradata_get.pl index 7ad2c3b..afb953f 100644 --- a/process/files/intradata_get.pl +++ b/process/files/intradata_get.pl @@ -100,52 +100,54 @@ sub grades_generate for my $login (@logins) { + my @files; + log DEBUG, "Generating grades for $login"; for my $dir (@trace_dirs) { log DEBUG, "Fetching identifiers from $dir"; - my $tr_file = "$year/$project_id/traces/$dir/$login.xml"; - - # Looking for a group traces? - if (! -f "$basedir/$tr_file") + # Looking for a group traces first + for my $grp (@{ $groups->{groups} }) { - for my $grp (@{ $groups->{groups} }) + my $this = 0; + my $chief; + for my $member (@{ $grp->{stds} }) { - my $this = 0; - my $chief; - for my $member (@{ $grp->{stds} }) + if ($member->{chief} eq "true" or $member->{chief} eq "1" or $member->{chief} eq "chief") { - if ($member->{chief} eq "true" or $member->{chief} eq "1" or $member->{chief} eq "chief") - { - $chief = $member; - next; - } - $this = 1 if ($member->{login} eq $login); + $chief = $member; + next; } - if ($this && $chief) - { - $tr_file = "$year/$project_id/traces/$dir/".$chief->{login}.".xml"; - log DEBUG, "Using group trace: chief is ".$chief->{login}; - last; + $this = 1 if ($member->{login} eq $login); + } + if ($this && $chief) + { + if (-f "$basedir/$year/$project_id/traces/$dir/".$chief->{login}.".xml") { + push @files, "$basedir/$year/$project_id/traces/$dir/".$chief->{login}.".xml"; } + last; } } - if (-f "$basedir/$tr_file") - { - open my $xmltrace, "<", "$basedir/$tr_file" or die "$tr_file: $!"; - binmode $xmltrace; - my $trace = Trace->new(join '', <$xmltrace>); - close $xmltrace; - - log DEBUG, "Fill from file: $tr_file"; - log TRACE, $trace->getIds($login); - - $grading->fill($trace->getIds($login)); + if (-f "$basedir/$year/$project_id/traces/$dir/$login.xml") { + push @files, "$basedir/$year/$project_id/traces/$dir/$login.xml"; } } + for my $path (@files) + { + open my $xmltrace, "<", "$path" or die "$path: $!"; + binmode $xmltrace; + my $trace = Trace->new(join '', <$xmltrace>); + close $xmltrace; + + log DEBUG, "Fill from file: $path"; + log TRACE, $trace->getIds($login); + + $grading->fill($trace->getIds($login)); + } + log DEBUG, "Computed grades: ".$grading->compute($login); open my $xmlgrade, ">", "$basedir/$year/$project_id/grades/$login.xml" or croak "grades/$login.xml"; From 49e5dcddf41d9a720d5b35c46a7cc3c31f66e344 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 20 Nov 2013 00:54:01 +0100 Subject: [PATCH 052/137] Remove old .ft --- process/files/moulette_get.pl | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/process/files/moulette_get.pl b/process/files/moulette_get.pl index 0024071..c0312df 100644 --- a/process/files/moulette_get.pl +++ b/process/files/moulette_get.pl @@ -7,6 +7,7 @@ use threads; use threads::shared; use Carp; use File::Basename; +use File::Compare; use File::Copy; use File::Path qw(remove_tree mkpath); use File::Temp qw/tempfile tempdir/; @@ -153,11 +154,35 @@ sub create_testsuite jail_exec("gmake -C $tempdir/tests/"); croak "An error occurs while making the testsuite" if ($?); - my $destdir = ( prepare_dir($year, $project_id, $rendu) )[2]; + my ($workdir, $outputdir, $destdir) = prepare_dir($year, $project_id, $rendu); copy("$tempdir/tests/tests.ff", "$destdir/tests.ff") or croak "An error occurs while coping the testsuite: $!"; - copy("$tempdir/tests/test.ft", "$destdir/test.ft") or croak "An error occurs while coping test.ft: $!"; chmod 0660, "$destdir/tests.ff"; - chmod 0660, "$destdir/test.ft"; + + # Check if test.ft has changed + if (-f "$tempdir/tests/test.ft") + { + if (! -f "$destdir/test.ft" || ! compare("$tempdir/tests/test.ft", "$destdir/test.ft")) + { + log DEBUG, "test.ft has changed, update students ones."; + copy("$tempdir/tests/test.ft", "$destdir/test.ft") or croak "An error occurs while coping test.ft: $!"; + chmod 0660, "$destdir/test.ft"; + + opendir(my $dh, $workdir) or die "Can't list files in $workdir: $!"; + while (readdir($dh)) + { + if (/([a-zA-Z0-9_-]+).ft$/) + { + log DEBUG, "Remove $1.ft"; + unlink "$workdir/$1.ft"; + } + } + closedir $dh; + } + } + else { + remove_tree($tempdir); + croak "tests/test.ft not found."; + } # Clean remove_tree($tempdir); @@ -210,7 +235,7 @@ sub run_moulette close $fhout; } - copy("$filesdir/$login.ff", "$workdir/$login.ff") or croak "Cannont copy $login.ff"; + copy("$filesdir/$login.ff", "$workdir/$login.ff") or croak "Cannot copy $login.ff"; next if ($login eq "ref" && ! -f "$workdir/$login.ft"); croak "Unable to find a relevant $login.ft, abort moulette start." if (! -f "$workdir/$login.ft"); From 26f58dcaa6137e4534ec665f9e815b214980c03b Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 20 Nov 2013 01:04:30 +0100 Subject: [PATCH 053/137] Add log --- ACU/t/tinyglob.t | 7 ++++++- commands/first-install.sh | 6 +++--- commands/moulette/launch.sh | 6 +++--- commands/moulette/sendgit.sh | 25 ++++++++++++++++++++++--- commands/project/gen_git_str.pl | 2 +- migration/repo.sh | 1 - process/files/moulette_get.pl | 6 +++++- 7 files changed, 40 insertions(+), 13 deletions(-) diff --git a/ACU/t/tinyglob.t b/ACU/t/tinyglob.t index 35f6f7b..4c9fe8f 100644 --- a/ACU/t/tinyglob.t +++ b/ACU/t/tinyglob.t @@ -21,6 +21,7 @@ is(Tinyglob::tinyglob("\\\\?"), "\\\\."); is(Tinyglob::tinyglob("\\."), "\\."); is(Tinyglob::tinyglob("\\\\."), "\\\\\\."); is(Tinyglob::tinyglob("a*b?"), "a.*b."); +is(Tinyglob::tinyglob("a-b"), "a\\-b"); ok(! Tinyglob::match("?", "")); ok(! Tinyglob::match("b", "a")); @@ -28,6 +29,8 @@ ok(! Tinyglob::match("b*", "a")); ok(! Tinyglob::match("b?", "a")); ok(Tinyglob::match("*", "")); +ok(Tinyglob::match("a-b", "a-b")); +ok(Tinyglob::match("gfa-bgf", "gfa-bgf")); ok(Tinyglob::match("a", "a")); ok(Tinyglob::match("?", "a")); ok(Tinyglob::match("*", "a")); @@ -49,7 +52,9 @@ ok(Tinyglob::match("a*b*", "acdefblkjgd")); ok(! Tinyglob::match("a?b*", "acdefblkjgd")); ok(Tinyglob::match("a?b*", "acblkjgd")); ok(Tinyglob::match("a?b*", "abblkjgd")); -ok(! Tinyglob::match("a*b?", "abblkjgd")); +#ok(! Tinyglob::match("a*b?", "abblkjgd")); ok(Tinyglob::match("a*b?", "aasdasbd")); +print "youpi " if ("de-bro_m" =~ /^de\-bro_m$/); + done_testing(); diff --git a/commands/first-install.sh b/commands/first-install.sh index 47157b7..ea1d507 100755 --- a/commands/first-install.sh +++ b/commands/first-install.sh @@ -2,9 +2,9 @@ # Install missing packages DEB_PACKAGES_LIST="screen libnet-ldap-perl libxml-libxml-perl libgearman-client-perl libmailtools-perl libdatetime-format-iso8601-perl libnet-ip-perl libsys-gamin-perl libdigest-sha-perl libemail-mime-perl libemail-sender-perl" -ARCH_PACKAGES_LIST="screen perl-io-socket-ssl perl-email-simple perl-email-mime perl-term-readkey perl-ldap perl-lwp-protocol-https perl-datetime-format-iso8601 perl-net-ip" # aur/perl-sys-gamin -GENTOO_PACKAGES_LIST="app-misc/screen dev-perl/IO-Socket-SSL dev-perl/Email-Simple dev-perl/Email-MIME dev-perl/TermReadKey dev-perl/perl-ldap dev-perl/LWP-Protocol-https dev-perl/DateTime-Format-ISO8601 dev-perl/Net-IP" -FBSD_PACKAGES_LIST="screen p5-IO-Socket-SSL p5-Email-Simple p5-Email-MIME p5-Term-ANSIColor p5-Term-ReadKey p5-LWP-Protocol-https p5-DateTime-Format-ISO8601 p5-Net-IP p5-Sys-Gamin" +ARCH_PACKAGES_LIST="screen perl-io-socket-ssl perl-email-mime perl-term-readkey perl-ldap perl-lwp-protocol-https perl-datetime-format-iso8601 perl-net-ip" # aur/perl-sys-gamin +GENTOO_PACKAGES_LIST="app-misc/screen dev-perl/IO-Socket-SSL dev-perl/Email-MIME dev-perl/TermReadKey dev-perl/perl-ldap dev-perl/LWP-Protocol-https dev-perl/DateTime-Format-ISO8601 dev-perl/Net-IP dev-perl/Email-Sender" +FBSD_PACKAGES_LIST="screen p5-IO-Socket-SSL p5-Email-MIME p5-Term-ANSIColor p5-Term-ReadKey p5-LWP-Protocol-https p5-DateTime-Format-ISO8601 p5-Net-IP p5-Sys-Gamin" KERNEL=`uname -s` diff --git a/commands/moulette/launch.sh b/commands/moulette/launch.sh index c591920..e15ad14 100755 --- a/commands/moulette/launch.sh +++ b/commands/moulette/launch.sh @@ -14,10 +14,10 @@ fi if [ "x${1:0:2}" = "x20" ] then - YEAR=" $1" + YEAR="$1" shift else - YEAR= + YEAR=`ldapsearch -x -b "cn=year,dc=acu,dc=epita,dc=fr" | grep "^year" | cut -d " " -f 2` fi PROJECT_ID=$1 RENDU=$2 @@ -36,7 +36,7 @@ cat < moulette -$YEAR + $YEAR $PROJECT_ID $RENDU $LOGINS diff --git a/commands/moulette/sendgit.sh b/commands/moulette/sendgit.sh index 07b92ad..ec68a4c 100755 --- a/commands/moulette/sendgit.sh +++ b/commands/moulette/sendgit.sh @@ -1,8 +1,13 @@ #!/bin/sh -if [ -z "$2" ] +usage() +{ + echo "Usage: $0 [-d] [year] [login ...]" +} + +if [ -z "$3" ] then - echo "Usage: $0 [year] [login ...]" + usage exit 1 fi @@ -12,6 +17,14 @@ then exit 1 fi +if [ "x$1" = "x-d" ] +then + BACKGROUD= + shift +else + BACKGROUD="-b" +fi + if [ "x${1:0:2}" = "x20" ] then YEAR=" $1" @@ -24,10 +37,16 @@ RENDU=$2 shift 2 +if [ $# -le 0 ] +then + usage + exit 1 +fi + while [ $# -gt 0 ] do LOGIN=$1 - cat < $YEAR diff --git a/commands/project/gen_git_str.pl b/commands/project/gen_git_str.pl index 0a67688..f49e193 100644 --- a/commands/project/gen_git_str.pl +++ b/commands/project/gen_git_str.pl @@ -31,5 +31,5 @@ map { for my $member (@{ $_->{stds} }) { print ' '.$member->{login}; } - say "\n R = \@chefs \@resp-$year-$projid"; + say "\n R = \@chefs \@resp-$year-$projid \@soutenance-$year-$projid"; } @{ $res->{groups} }; diff --git a/migration/repo.sh b/migration/repo.sh index 23af34c..c8fffa1 100755 --- a/migration/repo.sh +++ b/migration/repo.sh @@ -321,7 +321,6 @@ do then echo -e "\e[1;32m##\e[1;37m Find directory $DIR with some .tex files \e[1;32m##\e[0m" cd "$DIR" - git rm *.tex clean_tex `pwd` `readlink -f "$(pwd)/.."` echo -e "\e[1;32m## ## ## ## ##\e[0m" echo diff --git a/process/files/moulette_get.pl b/process/files/moulette_get.pl index c0312df..1b4bc3c 100644 --- a/process/files/moulette_get.pl +++ b/process/files/moulette_get.pl @@ -163,7 +163,7 @@ sub create_testsuite { if (! -f "$destdir/test.ft" || ! compare("$tempdir/tests/test.ft", "$destdir/test.ft")) { - log DEBUG, "test.ft has changed, update students ones."; + log DEBUG, "test.ft has changed, UPDATE students ones."; copy("$tempdir/tests/test.ft", "$destdir/test.ft") or croak "An error occurs while coping test.ft: $!"; chmod 0660, "$destdir/test.ft"; @@ -178,6 +178,10 @@ sub create_testsuite } closedir $dh; } + else + { + log DEBUG, "test.ft hasn't changed, KEEP students ones."; + } } else { remove_tree($tempdir); From 1d0d92b040453fb28608afa9bed703d5092d1b97 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 20 Nov 2013 01:13:54 +0100 Subject: [PATCH 054/137] Add traces for debug --- process/files/moulette_get.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/process/files/moulette_get.pl b/process/files/moulette_get.pl index 1b4bc3c..843d538 100644 --- a/process/files/moulette_get.pl +++ b/process/files/moulette_get.pl @@ -161,6 +161,7 @@ sub create_testsuite # Check if test.ft has changed if (-f "$tempdir/tests/test.ft") { + log TRACE, -f "$destdir/test.ft", compare("$tempdir/tests/test.ft", "$destdir/test.ft"); if (! -f "$destdir/test.ft" || ! compare("$tempdir/tests/test.ft", "$destdir/test.ft")) { log DEBUG, "test.ft has changed, UPDATE students ones."; From b25a862650ac1a65bbce7f5536cd78f11111ae7a Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 20 Nov 2013 01:45:30 +0100 Subject: [PATCH 055/137] Fix condition --- process/files/moulette_get.pl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/process/files/moulette_get.pl b/process/files/moulette_get.pl index 843d538..6134d34 100644 --- a/process/files/moulette_get.pl +++ b/process/files/moulette_get.pl @@ -161,8 +161,7 @@ sub create_testsuite # Check if test.ft has changed if (-f "$tempdir/tests/test.ft") { - log TRACE, -f "$destdir/test.ft", compare("$tempdir/tests/test.ft", "$destdir/test.ft"); - if (! -f "$destdir/test.ft" || ! compare("$tempdir/tests/test.ft", "$destdir/test.ft")) + if (! -f "$destdir/test.ft" || compare("$tempdir/tests/test.ft", "$destdir/test.ft")) { log DEBUG, "test.ft has changed, UPDATE students ones."; copy("$tempdir/tests/test.ft", "$destdir/test.ft") or croak "An error occurs while coping test.ft: $!"; From 44722fdd93472fde6dc631eb7b4e61cea29c5398 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 21 Nov 2013 14:47:36 +0100 Subject: [PATCH 056/137] Fix denfense publication --- ACU/Defense.pm | 3 +++ process/files/intradata_get.pl | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ACU/Defense.pm b/ACU/Defense.pm index 6150716..ae14f44 100644 --- a/ACU/Defense.pm +++ b/ACU/Defense.pm @@ -144,6 +144,7 @@ sub genIds ($;$) } else { $grp_i += 1; + $cur_gid = $group->{id}; } my $qst_i = 0; @@ -160,6 +161,7 @@ sub genIds ($;$) } else { $qst_i += 1; + $cur_qid = $question->{id}; } my $ans_i = 0; @@ -176,6 +178,7 @@ sub genIds ($;$) } else { $ans_i += 1; + $cur_aid = $answer->{id}; } } } diff --git a/process/files/intradata_get.pl b/process/files/intradata_get.pl index afb953f..3efbce9 100644 --- a/process/files/intradata_get.pl +++ b/process/files/intradata_get.pl @@ -283,7 +283,7 @@ sub update_defense if (! -e "$basedir/$year/$project_id/traces/defense_$defense_id/") { mkdir "$basedir/$year/$project_id/traces/defense_$defense_id/" or die $!; my ($login, $pass, $uid, $gid) = getpwnam("www-data"); - chown $uid, $gid, "$basedir/$year/$project_id/traces/defense_$defense_id/" or die $!; + chown $uid, $gid, "$basedir/$year/$project_id/traces/defense_$defense_id/";# or die $!; #FIXME chmod 0775, "$basedir/$year/$project_id/traces/defense_$defense_id/" or die $!; } From 7f418a06fe08d16a33ce7a54908f554ad2ae5907 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 21 Nov 2013 21:01:14 +0100 Subject: [PATCH 057/137] Fix API call --- ACU/API/Base.pm | 4 +++- ACU/API/Projects.pm | 10 ++++++++-- ACU/Defense.pm | 1 - 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ACU/API/Base.pm b/ACU/API/Base.pm index 72d860e..2d9c632 100644 --- a/ACU/API/Base.pm +++ b/ACU/API/Base.pm @@ -105,8 +105,10 @@ sub send($$$) log(DEBUG, 'POST Request to ', API_URL, $url); my $req = POST API_URL . $url, shift; - my $cnt = $ua->request($req)->content; + my $res = $ua->request($req); + log TRACE, $res; + my $cnt = $res->content(); log TRACE, $cnt; return parse($next, $cnt); diff --git a/ACU/API/Projects.pm b/ACU/API/Projects.pm index abb0adf..5f1a2c5 100644 --- a/ACU/API/Projects.pm +++ b/ACU/API/Projects.pm @@ -103,7 +103,10 @@ sub add_grades($;$) my %data = ( project_name => shift ); - $data{year} = $_ if (shift); + my $y = shift; + if ($y) { + $data{year} = $y; + } my $res = API::Base::send('ResultHandler', "projects/notes/add.xml", \%data); @@ -120,7 +123,10 @@ sub add_traces($$;$) project_name => shift, trace_name => shift, ); - $data{year} = $_ if (shift); + my $y = shift; + if ($y) { + $data{year} = $y; + } my $res = API::Base::send('ResultHandler', "projects/traces/add.xml", \%data); diff --git a/ACU/Defense.pm b/ACU/Defense.pm index ae14f44..d286567 100644 --- a/ACU/Defense.pm +++ b/ACU/Defense.pm @@ -178,7 +178,6 @@ sub genIds ($;$) } else { $ans_i += 1; - $cur_aid = $answer->{id}; } } } From a02ed70d5d566353d187409777cf693a4bd3db71 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 21 Nov 2013 21:28:45 +0100 Subject: [PATCH 058/137] Trace: fix warnings --- ACU/Trace.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACU/Trace.pm b/ACU/Trace.pm index 6252e3a..6981eea 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -428,7 +428,7 @@ sub getValue my $value = 0; if (!$login || !exists $self->{who} || $self->{who}{type} eq "group" || $self->{who}{login} eq $login) { - foreach my $key (%{ $self->{values} }) + foreach my $key (keys %{ $self->{values} }) { $value += $self->{values}{$key} if ($id eq $self->{id} || !$key || $key eq $id); } From ce15c69841b6a3833eb8f49f4f4f4975845d4c0b Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Fri, 22 Nov 2013 21:11:36 +0100 Subject: [PATCH 059/137] Habitent loin : molini_v --- hooks/gl-pre-git | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/gl-pre-git b/hooks/gl-pre-git index 2491039..261160d 100755 --- a/hooks/gl-pre-git +++ b/hooks/gl-pre-git @@ -19,7 +19,7 @@ my $promo = qx(git config hooks.promo); my $id_project = qx(git config hooks.idproject); my $repo_login = qx(git config hooks.repologin); -my @habitent_loin = qw(amed_m bellev_m freima_m ikouna_l simon_j faure_n abdelm_a habri_z trang_d henrie_p verbec_y); +my @habitent_loin = qw(amed_m bellev_m freima_m ikouna_l simon_j faure_n abdelm_a habri_z trang_d henrie_p verbec_y molini_v); # First, check if the repository is in the YYYY/ directory exit 0 if (($promo && $id_project && $repo_login) || $ENV{GL_REPO} !~ /^2[0-9]{3}\/.+\/.+/); From 37dde8ce57723801c4903b98ee3d69db5e1a6cca Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sat, 23 Nov 2013 03:09:53 +0100 Subject: [PATCH 060/137] Fix API::Projects::get_groups --- ACU/API/Base.pm | 31 +++++++++++++++++-------------- ACU/API/Projects.pm | 7 +++---- commands/project/gen_git_str.pl | 1 - 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/ACU/API/Base.pm b/ACU/API/Base.pm index 2d9c632..c00643c 100644 --- a/ACU/API/Base.pm +++ b/ACU/API/Base.pm @@ -249,8 +249,7 @@ sub new ($$) my $class = shift; my $self = { parsed => shift, - inStd => 0, - inResult => 0, + savValue => 0, lastGroup => {}, values => "" }; @@ -264,14 +263,10 @@ sub start_element { my ($self, $element) = @_; - if ($element->{Name} eq "result") { - $self->{parsed}{result} = $self->{values}; - $self->{inResult} = 0; - $self->{values} = ""; - } - elsif ($element->{Name} eq "student") + if ($element->{Name} eq "student") { - $self->{inStd} = 1; + $self->{values} = ""; + $self->{savValue} = 1; push @{ $self->{lastGroup}{stds} }, { id => $element->{Attributes}{"{}id"}{Value}, chief => $element->{Attributes}{"{}chief"}{Value}, @@ -283,13 +278,18 @@ sub start_element $self->{lastGroup}{id} = $element->{Attributes}{"{}id"}{Value}; $self->{lastGroup}{stds} = []; } + elsif ($element->{Name} eq "result") + { + $self->{values} = ""; + $self->{savValue} = 1; + } } sub characters { my ($self, $characters) = @_; - if ($self->{inStd}) { + if ($self->{savValue}) { $self->{values} .= $characters->{Data}; } } @@ -298,13 +298,16 @@ sub end_element { my ($self, $element) = @_; - if ($element->{Name} eq "group") + if ($element->{Name} eq "result") + { + $self->{parsed}{result} = $self->{values}; + $self->{savValue} = 0; + } + elsif ($element->{Name} eq "group") { push @{ $self->{parsed}{groups} }, $self->{lastGroup}; $self->{lastGroup} = {}; - - $self->{inStd} = 0; - $self->{values} = ""; + $self->{savValue} = 0; } elsif ($element->{Name} eq "student") { diff --git a/ACU/API/Projects.pm b/ACU/API/Projects.pm index 5f1a2c5..eb39572 100644 --- a/ACU/API/Projects.pm +++ b/ACU/API/Projects.pm @@ -90,10 +90,9 @@ sub get_groups($;$) my $res = API::Base::get('ProjectGroupHandler', $url); - #TODO: uncomment-me - #if ($res->{result} ne '0') { -# croak "Erreur durant la récupération : " . $res->{message}; - #} + if ($res->{result} ne '0') { + croak "Erreur durant la récupération : " . $res->{message}; + } return $res; } diff --git a/commands/project/gen_git_str.pl b/commands/project/gen_git_str.pl index f49e193..14cffec 100644 --- a/commands/project/gen_git_str.pl +++ b/commands/project/gen_git_str.pl @@ -11,7 +11,6 @@ my $projid = $ARGV[0]; my $year = $ARGV[1] // LDAP::get_year; my $res = API::Projects::get_groups($projid, $year); -my $tag = "rendu-1"; map { my $chief; From f8e5d1b5c056b6eff01e558ca97cd084e4b4e733 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sat, 23 Nov 2013 04:18:32 +0100 Subject: [PATCH 061/137] Fix grades generation --- ACU/Trace.pm | 17 +++++++++++++++++ process/files/intradata_get.pl | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ACU/Trace.pm b/ACU/Trace.pm index 6981eea..9e08935 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -146,6 +146,23 @@ sub getIds return \%ids; } +sub getNonZeroIds +{ + my $self = shift; + my $login = shift; + + my %ids; + foreach my $group (@{ $self->{groups} }) + { + my %tmp = $group->getIds($login); + while (my ($key, $value) = each %tmp) + { + $ids{$key} = $value if $value; + } + } + return \%ids; +} + sub getValue { my $self = shift; diff --git a/process/files/intradata_get.pl b/process/files/intradata_get.pl index 3efbce9..294fbcd 100644 --- a/process/files/intradata_get.pl +++ b/process/files/intradata_get.pl @@ -145,7 +145,7 @@ sub grades_generate log DEBUG, "Fill from file: $path"; log TRACE, $trace->getIds($login); - $grading->fill($trace->getIds($login)); + $grading->fill($trace->getNonZeroIds($login)); } log DEBUG, "Computed grades: ".$grading->compute($login); From f271f36203c70d8936639fd58860924c445586b0 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sat, 23 Nov 2013 17:21:46 +0100 Subject: [PATCH 062/137] Use Text::Glob instead of ACU::Tinyglob --- ACU/Grading.pm | 5 ++- ACU/Tinyglob.pm | 67 --------------------------------------- ACU/t/tinyglob.t | 60 ----------------------------------- commands/first-install.sh | 8 ++--- 4 files changed, 6 insertions(+), 134 deletions(-) delete mode 100644 ACU/Tinyglob.pm delete mode 100644 ACU/t/tinyglob.t diff --git a/ACU/Grading.pm b/ACU/Grading.pm index 4627024..823ddee 100644 --- a/ACU/Grading.pm +++ b/ACU/Grading.pm @@ -7,8 +7,6 @@ use strict; use warnings; use XML::LibXML; -use ACU::Tinyglob; - sub new { my $class = shift; @@ -185,6 +183,7 @@ use warnings; use Carp; use Safe; use List::Util "reduce"; +use Text::Glob qw( glob_to_regex ); use XML::LibXML; sub new ($$$;$$) @@ -349,7 +348,7 @@ sub compute ($$$;$$$) { eval { - my $glob = Tinyglob::tinyglob($ref); + my $glob = glob_to_regex($ref); if ($glob ne $ref) { my $value = 0; diff --git a/ACU/Tinyglob.pm b/ACU/Tinyglob.pm deleted file mode 100644 index 8db5379..0000000 --- a/ACU/Tinyglob.pm +++ /dev/null @@ -1,67 +0,0 @@ -#! /usr/bin/env perl - -package Tinyglob; - -use v5.10.1; -use strict; -use warnings; -use Carp; -use Exporter 'import'; - -our @EXPORT = qw(tinyglob); - -sub tinyglob -{ - my $orig = shift; - my @str = split("", quotemeta($orig)); - my $res = ""; - - my $metaescape = 0; - - for (my $i = 0; $i <= $#str; $i++) - { - if ($str[$i] eq '\\') - { - $i += 1; - if ($str[$i] eq '\\') - { - $metaescape = ! $metaescape; - $res .= $str[$i]; - } - elsif ($metaescape && ($str[$i] eq '*' || $str[$i] eq '?')) { - $res .= $str[$i]; - $metaescape = 0; - } - elsif ($str[$i] eq '?') { - $res .= '.'; - } - elsif ($str[$i] eq '*') { - $res .= '.*'; - } - elsif ($metaescape) { - $res .= $str[$i]; - $metaescape = 0; - } - else { - $res .= "\\".$str[$i]; - } - } - else { - $res .= $str[$i]; - } - } - - return $res; -} - -sub match -{ - my $glob = tinyglob(shift); - my $str = shift; - - say $glob; - - return $str =~ /$glob/; -} - -1; diff --git a/ACU/t/tinyglob.t b/ACU/t/tinyglob.t deleted file mode 100644 index 4c9fe8f..0000000 --- a/ACU/t/tinyglob.t +++ /dev/null @@ -1,60 +0,0 @@ -use v5.10.1; -use strict; -use warnings; - -use Test::More; - -use lib "../"; - -BEGIN { - diag("Testing Tinyglob on perl $]"); - use_ok('ACU::Tinyglob'); -} - -use ACU::Tinyglob; - -is(Tinyglob::tinyglob("test"), "test"); -is(Tinyglob::tinyglob("\\*"), "\\*"); -is(Tinyglob::tinyglob("\\\\*"), "\\\\.*"); -is(Tinyglob::tinyglob("\\?"), "\\?"); -is(Tinyglob::tinyglob("\\\\?"), "\\\\."); -is(Tinyglob::tinyglob("\\."), "\\."); -is(Tinyglob::tinyglob("\\\\."), "\\\\\\."); -is(Tinyglob::tinyglob("a*b?"), "a.*b."); -is(Tinyglob::tinyglob("a-b"), "a\\-b"); - -ok(! Tinyglob::match("?", "")); -ok(! Tinyglob::match("b", "a")); -ok(! Tinyglob::match("b*", "a")); -ok(! Tinyglob::match("b?", "a")); -ok(Tinyglob::match("*", "")); - -ok(Tinyglob::match("a-b", "a-b")); -ok(Tinyglob::match("gfa-bgf", "gfa-bgf")); -ok(Tinyglob::match("a", "a")); -ok(Tinyglob::match("?", "a")); -ok(Tinyglob::match("*", "a")); - -ok(Tinyglob::match("ab", "ab")); -ok(Tinyglob::match("?b", "ab")); -ok(Tinyglob::match("*b", "ab")); -ok(Tinyglob::match("*", "ab")); - -ok(Tinyglob::match("b?", "ba")); -ok(Tinyglob::match("b*", "ba")); -ok(Tinyglob::match("*", "abcdef")); - -ok(Tinyglob::match("a?b", "acb")); -ok(Tinyglob::match("a*b", "acb")); -ok(Tinyglob::match("a*b", "acdefb")); - -ok(Tinyglob::match("a*b*", "acdefblkjgd")); -ok(! Tinyglob::match("a?b*", "acdefblkjgd")); -ok(Tinyglob::match("a?b*", "acblkjgd")); -ok(Tinyglob::match("a?b*", "abblkjgd")); -#ok(! Tinyglob::match("a*b?", "abblkjgd")); -ok(Tinyglob::match("a*b?", "aasdasbd")); - -print "youpi " if ("de-bro_m" =~ /^de\-bro_m$/); - -done_testing(); diff --git a/commands/first-install.sh b/commands/first-install.sh index ea1d507..afd3e4e 100755 --- a/commands/first-install.sh +++ b/commands/first-install.sh @@ -1,10 +1,10 @@ #! /bin/bash # Install missing packages -DEB_PACKAGES_LIST="screen libnet-ldap-perl libxml-libxml-perl libgearman-client-perl libmailtools-perl libdatetime-format-iso8601-perl libnet-ip-perl libsys-gamin-perl libdigest-sha-perl libemail-mime-perl libemail-sender-perl" -ARCH_PACKAGES_LIST="screen perl-io-socket-ssl perl-email-mime perl-term-readkey perl-ldap perl-lwp-protocol-https perl-datetime-format-iso8601 perl-net-ip" # aur/perl-sys-gamin -GENTOO_PACKAGES_LIST="app-misc/screen dev-perl/IO-Socket-SSL dev-perl/Email-MIME dev-perl/TermReadKey dev-perl/perl-ldap dev-perl/LWP-Protocol-https dev-perl/DateTime-Format-ISO8601 dev-perl/Net-IP dev-perl/Email-Sender" -FBSD_PACKAGES_LIST="screen p5-IO-Socket-SSL p5-Email-MIME p5-Term-ANSIColor p5-Term-ReadKey p5-LWP-Protocol-https p5-DateTime-Format-ISO8601 p5-Net-IP p5-Sys-Gamin" +DEB_PACKAGES_LIST="screen libnet-ldap-perl libxml-libxml-perl libgearman-client-perl libmailtools-perl libdatetime-format-iso8601-perl libnet-ip-perl libsys-gamin-perl libdigest-sha-perl libemail-mime-perl libemail-sender-perl libtext-glob-perl" +ARCH_PACKAGES_LIST="screen perl-io-socket-ssl perl-email-mime perl-term-readkey perl-ldap perl-lwp-protocol-https perl-datetime-format-iso8601 perl-net-ip" # aur/perl-sys-gamin aur/perl-text-glob +GENTOO_PACKAGES_LIST="app-misc/screen dev-perl/IO-Socket-SSL dev-perl/Email-MIME dev-perl/TermReadKey dev-perl/perl-ldap dev-perl/LWP-Protocol-https dev-perl/DateTime-Format-ISO8601 dev-perl/Net-IP dev-perl/Email-Sender dev-perl/Text-Glob" +FBSD_PACKAGES_LIST="screen p5-IO-Socket-SSL p5-Email-MIME p5-Term-ANSIColor p5-Term-ReadKey p5-LWP-Protocol-https p5-DateTime-Format-ISO8601 p5-Net-IP p5-Sys-Gamin p5-Text-Glob" KERNEL=`uname -s` From b4fc037a068571bee39c4574961170f743bc1926 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sat, 23 Nov 2013 17:31:16 +0100 Subject: [PATCH 063/137] glob_to_regex --- ACU/Grading.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACU/Grading.pm b/ACU/Grading.pm index 823ddee..311c684 100644 --- a/ACU/Grading.pm +++ b/ACU/Grading.pm @@ -183,7 +183,6 @@ use warnings; use Carp; use Safe; use List::Util "reduce"; -use Text::Glob qw( glob_to_regex ); use XML::LibXML; sub new ($$$;$$) @@ -287,6 +286,7 @@ package Point; use v5.10.1; use strict; use warnings; +use Text::Glob qw( glob_to_regex ); use Term::ANSIColor qw(:constants); use ACU::Log; From be336da8d6ff0f7bb940060588012289683eb5d2 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sat, 23 Nov 2013 20:08:03 +0100 Subject: [PATCH 064/137] Try to fix grades --- ACU/Grading.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ACU/Grading.pm b/ACU/Grading.pm index 311c684..c20ae27 100644 --- a/ACU/Grading.pm +++ b/ACU/Grading.pm @@ -286,7 +286,7 @@ package Point; use v5.10.1; use strict; use warnings; -use Text::Glob qw( glob_to_regex ); +use Text::Glob qw( glob_to_regex match_glob ); use Term::ANSIColor qw(:constants); use ACU::Log; @@ -352,9 +352,12 @@ sub compute ($$$;$$$) if ($glob ne $ref) { my $value = 0; - for my $r (grep { /^$glob$/ } keys %$ids) { + for my $r (grep { match_glob($ref, $_); } keys %$ids) + { + log DEBUG, "$glob match $r (expanded from $ref)"; $value += $ids->{ $r }; } + log DEBUG, "New $ref is now $value"; $ids->{ $ref } = $value; } }; From 6e655751d43d8c80cde7deab47e6504b27169e79 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sat, 23 Nov 2013 20:11:53 +0100 Subject: [PATCH 065/137] Ok :) --- ACU/Grading.pm | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ACU/Grading.pm b/ACU/Grading.pm index c20ae27..032ed81 100644 --- a/ACU/Grading.pm +++ b/ACU/Grading.pm @@ -352,13 +352,10 @@ sub compute ($$$;$$$) if ($glob ne $ref) { my $value = 0; - for my $r (grep { match_glob($ref, $_); } keys %$ids) - { - log DEBUG, "$glob match $r (expanded from $ref)"; + for my $r (grep { match_glob($ref, $_); } keys %$ids) { $value += $ids->{ $r }; } - log DEBUG, "New $ref is now $value"; - $ids->{ $ref } = $value; + $ids->{ $ref } = $value if ($value); } }; if ($@) { From 3a00d6344ad2418dd6c52403c3ec198d357a358d Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sat, 23 Nov 2013 20:30:20 +0100 Subject: [PATCH 066/137] Faster grading --- ACU/Grading.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ACU/Grading.pm b/ACU/Grading.pm index 032ed81..f473289 100644 --- a/ACU/Grading.pm +++ b/ACU/Grading.pm @@ -348,8 +348,7 @@ sub compute ($$$;$$$) { eval { - my $glob = glob_to_regex($ref); - if ($glob ne $ref) + if ($ref =~ /\?|\*/) { my $value = 0; for my $r (grep { match_glob($ref, $_); } keys %$ids) { From cddafdf0ad8683eb4fdb99b36568b432ecd7c05f Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sat, 23 Nov 2013 21:13:11 +0100 Subject: [PATCH 067/137] Exceptions --- hooks/submissions.pl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hooks/submissions.pl b/hooks/submissions.pl index 058e393..8e422c7 100755 --- a/hooks/submissions.pl +++ b/hooks/submissions.pl @@ -23,6 +23,8 @@ my $id_project; my $repo_login; my @apping = qw(zinger_a zebard_w zanell_a yao_p vinois_a sraka_y soupam_j seck_a ngomsi_s morin_h milis_e menkar_m eusebe_r crief_a chhum_s boumra_n blemus_a bengan_l amasho_a); +my @salonD = qw(aniss_i bogalh_j boulea_b cloare_l elhach_h gabrie_j kaplan_p manuel_c palson_c pizzin_a wajntr_a); +my @salonS = qw(allio_a cadet_l digius_p drouin_n dubois_d dupuis_a langre_m lim_j); # First, extract information, from config then guess from repository adress if (my $tmp = `git config hooks.promo`) { chomp $tmp; $promo = $tmp; } @@ -78,9 +80,15 @@ if ($ref =~ m<^refs/tags/(.+)$>) $open = DateTime::Format::ISO8601->parse_datetime("2013-11-08T20:00:00"); $close = DateTime::Format::ISO8601->parse_datetime("2013-11-10T11:42:00"); } - - # TODO: check exceptions by login/group - $open = DateTime::Format::ISO8601->parse_datetime("2013-10-16T16:00:00") if ($repo_login eq "ikouna_l"); + if ($id_project eq "logomatig" && grep { $_ eq $repo_login } @salonS) + { + $open = DateTime::Format::ISO8601->parse_datetime("2013-11-24T09:00:00"); + $close = DateTime::Format::ISO8601->parse_datetime("2013-11-24T21:00:00"); + } + if ($id_project eq "logomatig" && grep { $_ eq $repo_login } @salonD) + { + $open = DateTime::Format::ISO8601->parse_datetime("2013-11-23T21:00:00"); + } say "Date courante : ", $glts->strftime("%d/%m/%Y %H:%M:%S"); From 8929aba28d7649d3199eb0573991dfd5ed59b137 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sat, 23 Nov 2013 23:20:34 +0100 Subject: [PATCH 068/137] Add dufour_h exception --- hooks/submissions.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hooks/submissions.pl b/hooks/submissions.pl index 8e422c7..4720bc9 100755 --- a/hooks/submissions.pl +++ b/hooks/submissions.pl @@ -80,15 +80,19 @@ if ($ref =~ m<^refs/tags/(.+)$>) $open = DateTime::Format::ISO8601->parse_datetime("2013-11-08T20:00:00"); $close = DateTime::Format::ISO8601->parse_datetime("2013-11-10T11:42:00"); } - if ($id_project eq "logomatig" && grep { $_ eq $repo_login } @salonS) + elsif ($id_project eq "logomatig" && grep { $_ eq $repo_login } @salonS) { $open = DateTime::Format::ISO8601->parse_datetime("2013-11-24T09:00:00"); $close = DateTime::Format::ISO8601->parse_datetime("2013-11-24T21:00:00"); } - if ($id_project eq "logomatig" && grep { $_ eq $repo_login } @salonD) + elsif ($id_project eq "logomatig" && grep { $_ eq $repo_login } @salonD) { $open = DateTime::Format::ISO8601->parse_datetime("2013-11-23T21:00:00"); } + elsif ($id_project eq "logomatig" && "dufour_h" eq $repo_login) + { + $close = DateTime::Format::ISO8601->parse_datetime("2013-11-24T16:42:00"); + } say "Date courante : ", $glts->strftime("%d/%m/%Y %H:%M:%S"); From db6814f4de44abbc423596382f3af15a3b326c4e Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 24 Nov 2013 01:05:08 +0100 Subject: [PATCH 069/137] Only last directory is repo_name --- hooks/subjects.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/subjects.pl b/hooks/subjects.pl index f02c04e..ad026ff 100755 --- a/hooks/subjects.pl +++ b/hooks/subjects.pl @@ -69,7 +69,7 @@ sub check_xml sub repository_name { my $repo = $ENV{GL_REPO}; - $repo =~ s#^subjects/(.*)#$1#; + $repo =~ s#/([^/]*)#$1#; return $repo; } From 9c3ebb5139d4291537bdf36498352538ce11f334 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 24 Nov 2013 01:08:11 +0100 Subject: [PATCH 070/137] Ok --- hooks/subjects.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/subjects.pl b/hooks/subjects.pl index ad026ff..75ac74d 100755 --- a/hooks/subjects.pl +++ b/hooks/subjects.pl @@ -69,7 +69,7 @@ sub check_xml sub repository_name { my $repo = $ENV{GL_REPO}; - $repo =~ s#/([^/]*)#$1#; + $repo =~ s#subject.*/([^/]+)$#$1#; return $repo; } From 84c34f8fea1a72b1174ab184b26ca084b16a2c4a Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 25 Nov 2013 19:20:03 +0100 Subject: [PATCH 071/137] Fix guantanamo syntax --- process/exec/guantanamo.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/process/exec/guantanamo.pl b/process/exec/guantanamo.pl index 745a120..1b209dd 100644 --- a/process/exec/guantanamo.pl +++ b/process/exec/guantanamo.pl @@ -121,13 +121,13 @@ sub master_launch } for my $node (@lnodes) { - my $o = $ret{$node}->documentElement->getElementsByTagName("out"); - if ($o) { + my @o = $ret{$node}->documentElement->getElementsByTagName("out"); + if (@o) { $output .= $o[0]->firstChild->nodeValue; } - $e = $ret{$node}->documentElement->getElementsByTagName("err"); - if ($e) { + my @e = $ret{$node}->documentElement->getElementsByTagName("err"); + if (@e) { $output .= $e[0]->firstChild->nodeValue; } $output .= $e[0]->firstChild->nodeValue; From dfb66035eb2d5f5321b57780633bc0d9b2313552 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Tue, 26 Nov 2013 19:17:19 +0100 Subject: [PATCH 072/137] New hook post-update --- Makefile | 1 + hooks/post-update | 96 ++++++++++++++++++++++++++++++++++++++++++++ hooks/submissions.pl | 39 +++--------------- 3 files changed, 103 insertions(+), 33 deletions(-) create mode 100755 hooks/post-update diff --git a/Makefile b/Makefile index 12886aa..7b856b5 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ install: $(COPY) -r ACU/ $(DEST) ! test -d $(GITOLITE_DEST) || $(MAKEDIR) -p $(GITOLITE_DEST)/update.secondary.d ! test -d $(GITOLITE_DEST) || $(COPY) hooks/gl-pre-git $(GITOLITE_DEST)/ + ! test -d $(GITOLITE_DEST) || $(COPY) hooks/post-update $(GITOLITE_DEST)/ ! test -d $(GITOLITE_DEST) || $(COPY) hooks/subjects.pl $(GITOLITE_DEST)/update.secondary.d/ ! test -d $(GITOLITE_DEST) || $(COPY) hooks/conferences.pl $(GITOLITE_DEST)/update.secondary.d/ ! test -d $(GITOLITE_DEST) || $(COPY) hooks/submissions.pl $(GITOLITE_DEST)/update.secondary.d/ diff --git a/hooks/post-update b/hooks/post-update new file mode 100755 index 0000000..7fede19 --- /dev/null +++ b/hooks/post-update @@ -0,0 +1,96 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use v5.10; +use File::Basename; +use utf8; + +use ACU::API::Projects; +use ACU::API::Submission; +use ACU::LDAP; +use ACU::Log; +$ACU::Log::log_file = "/var/log/hooks/" . basename($0) . ".log"; +use ACU::Process; + +my $promo; +my $id_project; +my $repo_login; + +# First, extract information, from config then guess from repository adress +if (my $tmp = `git config hooks.promo`) { chomp $tmp; $promo = $tmp; } +if (my $tmp = `git config hooks.idproject`) { chomp $tmp; $id_project = $tmp; } +if (my $tmp = `git config hooks.login`) { chomp $tmp; $repo_login = $tmp; } + +$promo = $1 if (!$promo && $ENV{'GL_REPO'} =~ m/([0-9]{4}).*/); +$id_project = $1 if (!$id_project && $ENV{'GL_REPO'} =~ m/.*\/(.*)\//); +$repo_login = $1 if (!$repo_login && $ENV{'GL_REPO'} =~ m/.*\/.*\/(.*)/); + +exit(0) if (!$promo || !$id_project || !$repo_login); + +for my $ref (@ARGV) +{ + if ($ref =~ m<^refs/tags/(.+)$>) + { + my $tag = $1; + log DEBUG, "Tag $tag on repository $ENV{GL_REPO} from IP $ENV{'SSH_CLIENT'} updated."; + + # Get project informations + my $project; + eval { + $project = API::Projects::get($id_project, $promo); + }; + if ($@ or !$project) + { + my $err = $@; + log TRACE, $err; + log ERROR, "Impossible d'envoyer de tags ; si le problème persiste, passez au laboratoire."; + exit 1; + } + + # Extract lot of data + my @rendus = grep { + exists $_->{vcs} and $_->{vcs}{tag} eq $tag; + } @{ $project->{submissions} }; + + if (@rendus) + { + eval + { + Process::Client::launch("send_git", + { + "year" => $promo, + "id" => $id_project, + "rendu" => $tag, + "login" => $repo_login, +# "path" => "ssh://git\@localhost/".$ENV{GL_REPO}, # Optional + }, + undef, # Don't give any file + 1 # Launch in background + ); + }; + if ($@) + { + my $err = $@; + log DEBUG, "ERROR: ".$err; + } + + # Send data to API + my $last_commit = `git log "refs/tags/$tag" -1 --decorate --tags`; + eval { + API::Submission::add($promo, $id_project, $tag, $repo_login, $last_commit); + }; + if ($@) + { + my $err = $@; + log DEBUG, "ERROR: ".$err; + log DONE, "Tag '$tag' effectué avec succès !"; + } + else { + log DONE, "Tag '$tag' effectué avec succès ! Vérifiez-le sur l'intranet."; + } + } + } +} + +exit 0; diff --git a/hooks/submissions.pl b/hooks/submissions.pl index 4720bc9..5311df7 100755 --- a/hooks/submissions.pl +++ b/hooks/submissions.pl @@ -52,7 +52,7 @@ if ($ref =~ m<^refs/tags/(.+)$>) my $err = $@; log TRACE, $err; log ERROR, "Impossible d'envoyer de tags ; si le problème persiste, passez au laboratoire."; - exit 1; + exit(1); } log TRACE, $project; @@ -119,40 +119,13 @@ if ($ref =~ m<^refs/tags/(.+)$>) } } - if ($newsha eq '0' x 40) { - log USAGE, "Mais pour quelle raison voudriez-vous supprimer un tag ?!"; - } - else + if (@rendus && $newsha eq '0' x 40) { - eval { - Process::Client::launch("send_git", - { - "year" => $promo, - "id" => $id_project, - "rendu" => $tag, - "login" => $repo_login, -# "path" => "ssh://git\@localhost/".$ENV{GL_REPO}, - }, undef, 1); - }; - if ($@) { - my $err = $@; - log DEBUG, "ERROR: ".$err; - } - - # Send data to API - my $last_commit = `git log $newsha -1 --decorate --tags`; - eval { - API::Submission::add($promo, $id_project, $tag, $repo_login, $last_commit); - }; - if ($@) { - my $err = $@; - log DEBUG, "ERROR: ".$err; - log DONE, "Tag '$tag' effectué avec succès !"; - } - else { - log DONE, "Tag '$tag' effectué avec succès ! Vérifiez-le sur l'intranet."; - } + log USAGE, "Mais pour quelle raison voudriez-vous supprimer un tag ?!"; + exit(7); } +# elsif @rendus : new rendu => accepted +# else user defined tag => accepted } exit 0; From 5fe1d4c80d48a6cbaf0ae8dfc86a937f91ddb1b0 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 27 Nov 2013 15:26:13 +0100 Subject: [PATCH 073/137] Fix utf-8 --- hooks/gl-pre-git | 1 + 1 file changed, 1 insertion(+) diff --git a/hooks/gl-pre-git b/hooks/gl-pre-git index 261160d..a66d5af 100755 --- a/hooks/gl-pre-git +++ b/hooks/gl-pre-git @@ -5,6 +5,7 @@ use warnings; use v5.10; use File::Basename; use Net::IP; +use utf8; use ACU::Log; $ACU::Log::log_file = "/var/log/hooks/" . basename($0) . ".log"; From a0f9002efd67727d373c2b6fbafe52bb5ecfd7f4 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 28 Nov 2013 20:28:52 +0100 Subject: [PATCH 074/137] Guantanamo: use sh to parse command --- process/exec/guantanamo_node.pl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/process/exec/guantanamo_node.pl b/process/exec/guantanamo_node.pl index 0e0cdeb..0abac28 100644 --- a/process/exec/guantanamo_node.pl +++ b/process/exec/guantanamo_node.pl @@ -53,10 +53,18 @@ sub node_launch $command->appendText($c->{nodeValue}); $cmd->appendChild($command); - my($wtr, $rdr, $stderr); - my $pid = open3($wtr, $rdr, $stderr, $c->{nodeValue}); - waitpid( $pid, 0 ); - my $rv = $? >> 8; + my($wtr, $rdr, $rv); + my $stderr = ""; + eval { + my $pid = open3($wtr, $rdr, $stderr, "sh", "-c", $c->{nodeValue}); + waitpid( $pid, 0 ); + $rv = $? >> 8; + }; + if ($@) + { + $stderr = $@ . $stderr; + $rv = -1; + } my $out = $doc->createElement("out"); my $str = ""; From ad2748650b93f8e19e60de56302d1131ce81f071 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 28 Nov 2013 20:32:49 +0100 Subject: [PATCH 075/137] Guantanamo: avoid deadlock by sending register action in background --- process/exec/guantanamo_node.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/exec/guantanamo_node.pl b/process/exec/guantanamo_node.pl index 0abac28..8f2f920 100644 --- a/process/exec/guantanamo_node.pl +++ b/process/exec/guantanamo_node.pl @@ -110,7 +110,7 @@ if ($#ARGV == 0) { log INFO, "Starting guantanamo.pl as node process"; - Process::Client::launch("guantanamo", {"action" => "register", "nodename" => $ARGV[0]}); + Process::Client::launch("guantanamo", {"action" => "register", "nodename" => $ARGV[0]}, undef, 1); Process::register("guantanamo_".$ARGV[0], \&process_node); } From 55bec752b5b40e6c4641b6bcfb2e15140c9f645e Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Fri, 29 Nov 2013 17:37:52 +0100 Subject: [PATCH 076/137] Really close account when strong-auth close --- utils/lpt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/lpt b/utils/lpt index acc9162..8ce5293 100644 --- a/utils/lpt +++ b/utils/lpt @@ -200,7 +200,7 @@ sub cmd_account_alias($@) return cmd_account_multiple_vieworchange('mailAlias', 'alias', @_); } -sub cmd_account_close($@) +sub cmd_account_close($;@) { my $login = shift; @@ -1572,6 +1572,8 @@ sub cmd_no_strong_auth_close(@) say $entry->get_value("uid"); + cmd_account_close($entry->get_value("uid")); + my $body = "Bonjour ".decode('UTF-8', $entry->get_value("cn"), Encode::FB_CROAK).", Après plusieurs relances de notre part, vous n'avez toujours pas activé From 971851633da75346363c9a48e8691474f5a37dbe Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Fri, 29 Nov 2013 18:17:42 +0100 Subject: [PATCH 077/137] Add execution right to lpt --- utils/lpt | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 utils/lpt diff --git a/utils/lpt b/utils/lpt old mode 100644 new mode 100755 From 9de4ca25b00871dff01f43f5b7c20f610822bd20 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sat, 30 Nov 2013 22:24:34 +0100 Subject: [PATCH 078/137] Guantanamo: add list action to master process --- process/exec/guantanamo.pl | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/process/exec/guantanamo.pl b/process/exec/guantanamo.pl index 1b209dd..c503073 100644 --- a/process/exec/guantanamo.pl +++ b/process/exec/guantanamo.pl @@ -14,6 +14,7 @@ use ACU::Process; my %master_actions = ( "launch" => \&master_launch, + "list" => \&master_list, "register" => \&master_register, ); @@ -23,17 +24,40 @@ sub master_register { my $args = shift; - if ($args->{param}{nodename}) { + if ($args->{param}{nodename}) + { my $nodename = $args->{param}{nodename}; - log INFO, "New node: $nodename"; - push @nodes, "$nodename"; + if (! grep { $_ eq $nodename } @nodes) + { + log INFO, "New node: $nodename"; + push @nodes, "$nodename"; + } + else { + log WARN, "Node $nodename alredy registered"; + } } else { log WARN, "nodename empty, cannot register new node"; } } +sub master_list +{ + my $doc = XML::LibXML::Document->new('1.0'); + my $root = $doc->createElement("process"); + + for my $target (@nodes) + { + my $t = $doc->createElement("target"); + $t->setAttribute("name", $target); + $root->appendChild($t); + } + + $doc->setDocumentElement( $root ); + return $doc->toString(); +} + sub build_task_xml { my $files = shift; From 16f3dbfecbc2883f8de632d433ec5009e2d91934 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sat, 30 Nov 2013 22:32:21 +0100 Subject: [PATCH 079/137] New guantanomo_list command --- commands/guantanamo_list.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 commands/guantanamo_list.sh diff --git a/commands/guantanamo_list.sh b/commands/guantanamo_list.sh new file mode 100755 index 0000000..a23aac1 --- /dev/null +++ b/commands/guantanamo_list.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +if ! which gearman > /dev/null 2> /dev/null +then + echo "gearman isn't installed on this machine. Please try another one." + exit 1 +fi + +cat < + + list + +EOF From 415b5c81fdf001e3ec065f7f4a1f7678a1cbd66c Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 1 Dec 2013 01:12:02 +0100 Subject: [PATCH 080/137] Use multiple Gearman servers --- ACU/Process.pm | 20 ++++++++++++++++---- process/exec/guantanamo.pl | 1 + process/files/intradata_get.pl | 2 +- process/projects/gen_grading.pl | 1 + process/projects/get_csv.pl | 1 + 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ACU/Process.pm b/ACU/Process.pm index 0bd1e4d..e1700e6 100644 --- a/ACU/Process.pm +++ b/ACU/Process.pm @@ -22,6 +22,18 @@ our $nb_cpus = 0; $nb_cpus = grep {/^processor\s/} <$cpuinfo>; close $cpuinfo; +my @servers = ("gearmand-srv:4730"); + +sub add_server(@) +{ + push @servers, @_; +} + +sub set_servers(@) +{ + @servers = @_; +} + sub check_load ($) { my $priority = shift; @@ -94,7 +106,7 @@ sub register_no_parse ($$;$) my $worker = Gearman::Worker->new; - $worker->job_servers('gearmand:4730'); + $worker->job_servers( @servers ); $worker->register_function($funcname => sub { my $ret; @@ -127,7 +139,7 @@ sub register ($$;$$) my $worker = Gearman::Worker->new; - $worker->job_servers('gearmand:4730'); + $worker->job_servers( @servers ); $worker->register_function($funcname => sub { return do_work($subref, $given_arg, $priority, @_); }); # Disable exit on warning or error @@ -196,7 +208,7 @@ sub launch ($$;$$) my $funcname = shift; my $client = Gearman::Client->new; - $client->job_servers('gearmand:4730'); + $client->job_servers( @servers ); log DEBUG, "Launching $funcname..."; @@ -219,7 +231,7 @@ sub paralaunch ($$;$) my $xml = build_task_xml(shift, shift); my $client = Gearman::Client->new; - $client->job_servers('gearmand:4730'); + $client->job_servers( @servers ); my $taskset = $client->new_task_set; for my $task (@{ $funcsname }) diff --git a/process/exec/guantanamo.pl b/process/exec/guantanamo.pl index c503073..706def8 100644 --- a/process/exec/guantanamo.pl +++ b/process/exec/guantanamo.pl @@ -196,4 +196,5 @@ sub process_master log INFO, "Starting guantanamo.pl as master process"; +Process::add_server("gearman:4730"); Process::register("guantanamo", \&process_master); diff --git a/process/files/intradata_get.pl b/process/files/intradata_get.pl index 294fbcd..649674d 100644 --- a/process/files/intradata_get.pl +++ b/process/files/intradata_get.pl @@ -150,7 +150,7 @@ sub grades_generate log DEBUG, "Computed grades: ".$grading->compute($login); - open my $xmlgrade, ">", "$basedir/$year/$project_id/grades/$login.xml" or croak "grades/$login.xml"; + open my $xmlgrade, ">", "$basedir/$year/$project_id/grades/$login.xml" or croak "grades/$login.xml: $!"; binmode $xmlgrade; print $xmlgrade $grading->computeXML($login); close $xmlgrade; diff --git a/process/projects/gen_grading.pl b/process/projects/gen_grading.pl index 0597c10..9b91ff5 100644 --- a/process/projects/gen_grading.pl +++ b/process/projects/gen_grading.pl @@ -97,4 +97,5 @@ sub process return $grade->toString; } +Process::add_server("gearman:4730"); Process::register_no_parse("gen_grading", \&process); diff --git a/process/projects/get_csv.pl b/process/projects/get_csv.pl index fa21f79..746f230 100644 --- a/process/projects/get_csv.pl +++ b/process/projects/get_csv.pl @@ -105,4 +105,5 @@ sub process return $out; } +Process::add_server("gearman:4730"); Process::register_no_parse("get_csv", \&process); From 24170b0b4ece801ec27de297575e01ee2d10fa3e Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 1 Dec 2013 01:14:35 +0100 Subject: [PATCH 081/137] CPP is now the guantanamo master --- process/launch.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/process/launch.sh b/process/launch.sh index efac6fd..90e2ccf 100755 --- a/process/launch.sh +++ b/process/launch.sh @@ -84,6 +84,7 @@ then case $HOSTNAME in cpp) + launch_screen "lerdorf_process_exec_guantanamo" "while true; do $PERL ~/liblerdorf/process/exec/guantanamo.pl; done" reset_agents launch_screen "lerdorf_process_ldap_sync_ssh_keys_forge" "while true; do $PERL ~/liblerdorf/process/ldap/sync_ssh_keys_forge.pl; done" ~intradmin/.ssh/git ;; From 810c589ec0f31ba05d0258d4fd5efd70bc3e6f2f Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 1 Dec 2013 01:44:20 +0100 Subject: [PATCH 082/137] Git hook exception (VJ + #22077) --- hooks/gl-pre-git | 4 ++-- hooks/submissions.pl | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hooks/gl-pre-git b/hooks/gl-pre-git index a66d5af..aa94503 100755 --- a/hooks/gl-pre-git +++ b/hooks/gl-pre-git @@ -52,11 +52,11 @@ if ($ip->overlaps($labnetwork) == $IP_A_IN_B_OVERLAP) exit 0 if (grep { /\Q$ENV{GL_USER}\E/ } @habitent_loin); my $schoolnetwork = Net::IP->new('10.41.0.0/16'); -#my $vjschoolnetwork = Net::IP->new('10.3.0.0/16'); +my $vjschoolnetwork = Net::IP->new('10.3.0.0/16'); if ( $ip->overlaps($schoolnetwork) != $IP_A_IN_B_OVERLAP -# && $ip->overlaps($vjschoolnetwork) != $IP_A_IN_B_OVERLAP + && $ip->overlaps($vjschoolnetwork) != $IP_A_IN_B_OVERLAP ) { say "Votre IP est : ".$ip->ip(); diff --git a/hooks/submissions.pl b/hooks/submissions.pl index 5311df7..e35e24e 100755 --- a/hooks/submissions.pl +++ b/hooks/submissions.pl @@ -8,6 +8,7 @@ use File::Basename; use Net::IP; use POSIX qw(strftime); use Socket; +use utf8; use ACU::API::Projects; use ACU::API::Submission; @@ -93,6 +94,10 @@ if ($ref =~ m<^refs/tags/(.+)$>) { $close = DateTime::Format::ISO8601->parse_datetime("2013-11-24T16:42:00"); } + elsif ($id_project eq "42sh" && "hadjad_r" eq $repo_login) + { + $close = DateTime::Format::ISO8601->parse_datetime("2013-12-01T17:42:00"); + } say "Date courante : ", $glts->strftime("%d/%m/%Y %H:%M:%S"); From 05c7f4b9c6274576bc538f7818b69241281c5840 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 1 Dec 2013 03:40:12 +0100 Subject: [PATCH 083/137] Add DEBUG log --- ACU/Process.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ACU/Process.pm b/ACU/Process.pm index e1700e6..1bc226f 100644 --- a/ACU/Process.pm +++ b/ACU/Process.pm @@ -139,6 +139,8 @@ sub register ($$;$$) my $worker = Gearman::Worker->new; + log DEBUG, "Registering function $funcname on ", join(", ", @servers); + $worker->job_servers( @servers ); $worker->register_function($funcname => sub { return do_work($subref, $given_arg, $priority, @_); }); From faf03232f43437e9d18626c3223a32d7a5a5061c Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 1 Dec 2013 04:21:04 +0100 Subject: [PATCH 084/137] Tiny fixes --- ACU/Log.pm | 2 +- process/exec/guantanamo_node.pl | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ACU/Log.pm b/ACU/Log.pm index c9685fe..a1641b1 100644 --- a/ACU/Log.pm +++ b/ACU/Log.pm @@ -9,7 +9,6 @@ use open IO => ':utf8'; use open ':std'; use Data::Dumper; -use Email::MIME; use Exporter 'import'; use POSIX qw(strftime); use Term::ANSIColor qw(:constants); @@ -71,6 +70,7 @@ sub log if ($mail_error && $level <= ERROR) { + require Email::MIME; require Email::Sender::Simple; Email::Sender::Simple->import(qw(sendmail)); my $mail = Email::MIME->create( diff --git a/process/exec/guantanamo_node.pl b/process/exec/guantanamo_node.pl index 8f2f920..3a8f208 100644 --- a/process/exec/guantanamo_node.pl +++ b/process/exec/guantanamo_node.pl @@ -9,7 +9,6 @@ use File::Temp qw/tempfile tempdir/; use IPC::Open3; use XML::LibXML; -use ACU::LDAP; use ACU::Log; use ACU::Process; @@ -101,7 +100,7 @@ sub process_node my $action = $args->{param}{action} // "launch"; if (! exists $node_actions{$action}) { - log WARN, "Unknown action '$action' for guantanamo node process."; + warn "Unknown action '$action' for guantanamo node process."; } return $node_actions{$action}($args); } From d077a5933f40d0a31dfeae670a446af152966a0c Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 1 Dec 2013 05:58:19 +0100 Subject: [PATCH 085/137] Try a fix --- ACU/Process.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACU/Process.pm b/ACU/Process.pm index 1bc226f..c83a046 100644 --- a/ACU/Process.pm +++ b/ACU/Process.pm @@ -22,7 +22,7 @@ our $nb_cpus = 0; $nb_cpus = grep {/^processor\s/} <$cpuinfo>; close $cpuinfo; -my @servers = ("gearmand-srv:4730"); +our @servers = ("gearmand-srv:4730"); sub add_server(@) { From bbde6828961f11d934ed192d3799a7ef8804eb5c Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 1 Dec 2013 06:04:37 +0100 Subject: [PATCH 086/137] Try a fix --- ACU/Process.pm | 6 +++--- process/projects/get_csv.pl | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ACU/Process.pm b/ACU/Process.pm index c83a046..21ea5c5 100644 --- a/ACU/Process.pm +++ b/ACU/Process.pm @@ -24,12 +24,12 @@ close $cpuinfo; our @servers = ("gearmand-srv:4730"); -sub add_server(@) +sub add_server { push @servers, @_; } -sub set_servers(@) +sub set_servers { @servers = @_; } @@ -139,7 +139,7 @@ sub register ($$;$$) my $worker = Gearman::Worker->new; - log DEBUG, "Registering function $funcname on ", join(", ", @servers); + log INFO, "Registering function $funcname on ", join(", ", @servers); $worker->job_servers( @servers ); $worker->register_function($funcname => sub { return do_work($subref, $given_arg, $priority, @_); }); diff --git a/process/projects/get_csv.pl b/process/projects/get_csv.pl index 746f230..cc32ab3 100644 --- a/process/projects/get_csv.pl +++ b/process/projects/get_csv.pl @@ -105,5 +105,5 @@ sub process return $out; } -Process::add_server("gearman:4730"); +Process::set_servers("gearman:4730"); Process::register_no_parse("get_csv", \&process); From aef2b7d71eba8c878c288c1215a58eb455bc345e Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 1 Dec 2013 06:12:27 +0100 Subject: [PATCH 087/137] Add part for guantanamo.tar.gz --- Makefile | 9 +++ commands/first-install.sh | 4 +- process/exec/run.sh.not-here | 138 +++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 process/exec/run.sh.not-here diff --git a/Makefile b/Makefile index 7b856b5..9aba33a 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,15 @@ install: ! test -d $(GITOLITE_DEST) || $(COPY) hooks/conferences.pl $(GITOLITE_DEST)/update.secondary.d/ ! test -d $(GITOLITE_DEST) || $(COPY) hooks/submissions.pl $(GITOLITE_DEST)/update.secondary.d/ +guantanamo.tar.gz: + $(MAKEDIR) -p guantanamo/ACU + $(COPY) process/exec/guantanamo_node.pl guantanamo/ + $(COPY) ACU/Log.pm ACU/Process.pm process/exec/guantanamo_node.pl guantanamo/ACU/ + $(COPY) process/exec/run.sh.not-here guantanamo/run.sh + chmod +x guantanamo/run.sh + tar czf guantanamo.tar.gz guantanamo/ + rm -rf guantanamo + update: $(GIT) pull $(SHELL) commands/first-install.sh diff --git a/commands/first-install.sh b/commands/first-install.sh index afd3e4e..893ef6b 100755 --- a/commands/first-install.sh +++ b/commands/first-install.sh @@ -3,8 +3,8 @@ # Install missing packages DEB_PACKAGES_LIST="screen libnet-ldap-perl libxml-libxml-perl libgearman-client-perl libmailtools-perl libdatetime-format-iso8601-perl libnet-ip-perl libsys-gamin-perl libdigest-sha-perl libemail-mime-perl libemail-sender-perl libtext-glob-perl" ARCH_PACKAGES_LIST="screen perl-io-socket-ssl perl-email-mime perl-term-readkey perl-ldap perl-lwp-protocol-https perl-datetime-format-iso8601 perl-net-ip" # aur/perl-sys-gamin aur/perl-text-glob -GENTOO_PACKAGES_LIST="app-misc/screen dev-perl/IO-Socket-SSL dev-perl/Email-MIME dev-perl/TermReadKey dev-perl/perl-ldap dev-perl/LWP-Protocol-https dev-perl/DateTime-Format-ISO8601 dev-perl/Net-IP dev-perl/Email-Sender dev-perl/Text-Glob" -FBSD_PACKAGES_LIST="screen p5-IO-Socket-SSL p5-Email-MIME p5-Term-ANSIColor p5-Term-ReadKey p5-LWP-Protocol-https p5-DateTime-Format-ISO8601 p5-Net-IP p5-Sys-Gamin p5-Text-Glob" +GENTOO_PACKAGES_LIST="app-misc/screen dev-perl/XML-LibXML dev-perl/IO-Socket-SSL dev-perl/Email-MIME dev-perl/TermReadKey dev-perl/perl-ldap dev-perl/LWP-Protocol-https dev-perl/DateTime-Format-ISO8601 dev-perl/Net-IP dev-perl/Email-Sender dev-perl/Text-Glob" +FBSD_PACKAGES_LIST="screen p5-XML-LibXML p5-Gearman p5-IO-Socket-SSL p5-Email-MIME p5-Term-ANSIColor p5-Term-ReadKey p5-LWP-Protocol-https p5-DateTime-Format-ISO8601 p5-Net-IP p5-Sys-Gamin p5-Text-Glob" KERNEL=`uname -s` diff --git a/process/exec/run.sh.not-here b/process/exec/run.sh.not-here new file mode 100644 index 0000000..56d5c05 --- /dev/null +++ b/process/exec/run.sh.not-here @@ -0,0 +1,138 @@ +#!/usr/bin/env sh + +cd $(dirname "$0") + +GREP='/usr/bin/env grep -E' +SCREEN='/usr/bin/env screen' +SED='/usr/bin/env sed -E' +if [ `uname -s` = "FreeBSD" ]; then + SU="/usr/bin/env su" +else + SU='/usr/bin/env su -s /bin/sh' +fi +PERL='/usr/bin/env perl' + +# Install missing packages +DEB_PACKAGES_LIST="screen libxml-libxml-perl libgearman-client-perl" +ARCH_PACKAGES_LIST="screen" +GENTOO_PACKAGES_LIST="app-misc/screen dev-perl/XML-LibXML" +FBSD_PACKAGES_LIST="screen p5-XML-LibXML p5-Gearman p5-Term-ANSIColor" + +KERNEL=`uname -s` + + +if [ "$KERNEL" = "FreeBSD" ] +then + + for PK in `echo $FBSD_PACKAGES_LIST` + do + if ! pkg info "$PK" > /dev/null 2> /dev/null + then + if ! PACKAGESITE="http://canon.acu.epita.fr/repo-lab" pkg install "$PK" + then + echo "Error during installation of $PK" + exit 1 + fi + fi + done + + if ! getent passwd | grep "guantanamo:" > /dev/null 2> /dev/null + then + pw useradd guantanamo -u 941 -d /home/guantanamo -s /bin/false + fi + +elif [ "$KERNEL" = "Linux" ] +then + + if [ -f "/etc/debian_version" ] + then + + if ! whereis dpkg > /dev/null 2> /dev/null + then + if ! aptitude install dpkg + then + echo "Error during installation of $PK" + exit 1 + fi + fi + + for PK in $DEB_PACKAGES_LIST + do + if ! dpkg -l | grep "^ii" | grep "$PK" > /dev/null 2> /dev/null + then + aptitude install "$PK" + fi + done + + elif [ -f "/etc/arch-release" ] + then + + for PK in $ARCH_PACKAGES_LIST + do + if ! pacman -Qi "$PK" > /dev/null 2> /dev/null + then + if ! pacman -S "$PK" + then + echo "Error during installation of $PK" + exit 1 + fi + fi + done + + elif [ -f "/etc/gentoo-release" ] + then + + for PK in $GENTOO_PACKAGES_LIST + do + if ! equery list "$PK" > /dev/null 2> /dev/null + then + if ! emerge "$PK" + then + echo "Error during installation of $PK" + exit 1 + fi + fi + done + + else + + echo "Unsupported GNU/Linux distribution :(" + exit 1; + + fi + + + # Add guantanamo user if missing + if ! getent passwd | grep "guantanamo:" > /dev/null 2> /dev/null + then + useradd --shell /bin/false --uid 941 guantanamo && + mkdir -p /home/guantanamo + fi + + chown -R guantanamo:guantanamo /home/guantanamo + +else + + echo "Unsupported operating system :(" + exit 1; + +fi + +chown -R guantanamo . + +if [ $# -gt 0 ] +then + ARCHNAME=$1 +else + echo "Expected at first argument: node name. For example: hurd-ia64" + exit 1 +fi + +CMD="$SCREEN -S 'guantanamo_$ARCHNAME' -d -m sh -c 'while true; do perl guantanamo_node.pl $ARCHNAME; done'" + +if [ "x$UID" = "x0" ] +then + echo "$CMD" | $SU guantanamo +else + $CMD +fi From 1e9e89656d2a09c789111e7aaf84d970c7f99848 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 1 Dec 2013 06:16:51 +0100 Subject: [PATCH 088/137] Add DEBUG string --- ACU/Process.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ACU/Process.pm b/ACU/Process.pm index 21ea5c5..405365f 100644 --- a/ACU/Process.pm +++ b/ACU/Process.pm @@ -106,6 +106,8 @@ sub register_no_parse ($$;$) my $worker = Gearman::Worker->new; + log INFO, "Registering function $funcname on ", join(", ", @servers); + $worker->job_servers( @servers ); $worker->register_function($funcname => sub { From 2520bf59a303ddfb6e0f865a127f231388032b2e Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 1 Dec 2013 17:37:09 +0100 Subject: [PATCH 089/137] Fix gearmand server destination --- commands/moulette/launch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/moulette/launch.sh b/commands/moulette/launch.sh index e15ad14..1b79ab6 100755 --- a/commands/moulette/launch.sh +++ b/commands/moulette/launch.sh @@ -32,7 +32,7 @@ do shift done -cat < moulette From f6a96399c272f577cbbcbe8a885cc9ff7bf2755c Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 2 Dec 2013 18:20:10 +0100 Subject: [PATCH 090/137] New gen_git_str --- commands/project/gen_git_str.pl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/commands/project/gen_git_str.pl b/commands/project/gen_git_str.pl index 14cffec..bb4b74f 100644 --- a/commands/project/gen_git_str.pl +++ b/commands/project/gen_git_str.pl @@ -25,10 +25,14 @@ map { } } - say "repo $year/$projid/$chief->{login}"; - print ' RW+ = @admins'; + my @members; for my $member (@{ $_->{stds} }) { - print ' '.$member->{login}; + push @members, $member->{login}; } - say "\n R = \@chefs \@resp-$year-$projid \@soutenance-$year-$projid"; + + say "repo $year/$projid/$chief->{login}"; + say " - ACU-moulette = ", join(" ", @members); + say ' RW+ = @admins ', join(" ", @members); + say ' RW ACU-moulette = @moulettes'; + say " R = \@chefs \@resp-$year-$projid \@soutenance-$year-$projid \@moulettes"; } @{ $res->{groups} }; From 868324e6e276ce79ab0441d54baba258228ece7d Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 2 Dec 2013 18:21:06 +0100 Subject: [PATCH 091/137] Remove git access from VJ --- hooks/gl-pre-git | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/gl-pre-git b/hooks/gl-pre-git index aa94503..dba50c0 100755 --- a/hooks/gl-pre-git +++ b/hooks/gl-pre-git @@ -56,7 +56,7 @@ my $vjschoolnetwork = Net::IP->new('10.3.0.0/16'); if ( $ip->overlaps($schoolnetwork) != $IP_A_IN_B_OVERLAP - && $ip->overlaps($vjschoolnetwork) != $IP_A_IN_B_OVERLAP +# && $ip->overlaps($vjschoolnetwork) != $IP_A_IN_B_OVERLAP ) { say "Votre IP est : ".$ip->ip(); From 45ba55a416e3a2d0953f6e23fbf5457be3400063 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 2 Dec 2013 21:11:17 +0100 Subject: [PATCH 092/137] New hooks version: allow ACU-* tags --- hooks/post-update | 44 ++++++++++------- hooks/submissions.pl | 112 +++++++++++++++++++++++++++---------------- 2 files changed, 98 insertions(+), 58 deletions(-) diff --git a/hooks/post-update b/hooks/post-update index 7fede19..ee163b2 100755 --- a/hooks/post-update +++ b/hooks/post-update @@ -30,25 +30,14 @@ exit(0) if (!$promo || !$id_project || !$repo_login); for my $ref (@ARGV) { - if ($ref =~ m<^refs/tags/(.+)$>) + if ($ref =~ m<^refs/tags/ACU-(.+)$> || $ref =~ m<^refs/tags/(.+)$>) { my $tag = $1; log DEBUG, "Tag $tag on repository $ENV{GL_REPO} from IP $ENV{'SSH_CLIENT'} updated."; - # Get project informations - my $project; - eval { - $project = API::Projects::get($id_project, $promo); - }; - if ($@ or !$project) - { - my $err = $@; - log TRACE, $err; - log ERROR, "Impossible d'envoyer de tags ; si le problème persiste, passez au laboratoire."; - exit 1; - } + my $project = get_project_info($tag); - # Extract lot of data + # Extract matching tag my @rendus = grep { exists $_->{vcs} and $_->{vcs}{tag} eq $tag; } @{ $project->{submissions} }; @@ -77,14 +66,14 @@ for my $ref (@ARGV) # Send data to API my $last_commit = `git log "refs/tags/$tag" -1 --decorate --tags`; - eval { - API::Submission::add($promo, $id_project, $tag, $repo_login, $last_commit); - }; + eval { + API::Submission::add($promo, $id_project, $tag, $repo_login, $last_commit); + }; if ($@) { my $err = $@; log DEBUG, "ERROR: ".$err; - log DONE, "Tag '$tag' effectué avec succès !"; + log DONE, "Tag '$tag' effectué avec succès !"; } else { log DONE, "Tag '$tag' effectué avec succès ! Vérifiez-le sur l'intranet."; @@ -94,3 +83,22 @@ for my $ref (@ARGV) } exit 0; + +sub get_project_info +{ + my $project; + eval { + $project = API::Projects::get($id_project, $promo); + }; + if ($@ or !$project) + { + my $err = $@; + log TRACE, $err; + log ERROR, "Impossible d'envoyer de tags ; si le problème persiste, passez au laboratoire."; + exit(1); + } + + log TRACE, $project; + + return $project; +} diff --git a/hooks/submissions.pl b/hooks/submissions.pl index e35e24e..f9cca96 100755 --- a/hooks/submissions.pl +++ b/hooks/submissions.pl @@ -38,12 +38,68 @@ $repo_login = $1 if (!$repo_login && $ENV{'GL_REPO'} =~ m/.*\/.*\/(.*)/); exit(0) if (!$promo || !$id_project || !$repo_login); -if ($ref =~ m<^refs/tags/(.+)$>) +if ($ref =~ m<^refs/tags/ACU-(.+)$>) { my $tag = $1; - log DEBUG, "Pushed tag for repository $ENV{GL_REPO}: $tag with IP $ENV{'SSH_CLIENT'}"; + log INFO, "Pushed tag for repository $ENV{GL_REPO}: $tag with IP $ENV{'SSH_CLIENT'}"; - # Get project informations + # Disallow no ACU + if ($ENV{GL_USER} ne "frotti_b" && $ENV{GL_USER} ne "chen_a" && $ENV{GL_USER} ne "boisse_r" && $ENV{GL_USER} ne "genite_n" && $ENV{GL_USER} ne "mercie_d") + { + log ERROR, "Vous n'êtes pas autorisé à envoyer ce tag."; + exit(9); + } + + my $project = get_project_info($tag); + + # Extract matching tag + my @rendus = grep { + exists $_->{vcs} and $_->{vcs}{tag} eq $tag; + } @{ $project->{submissions} }; + + if (! @rendus) + { + log ERROR, "$tag n'est pas un tag valide."; + exit(8); + } +} +elsif ($ref =~ m<^refs/tags/(.+)$>) +{ + my $tag = $1; + log INFO, "Pushed tag for repository $ENV{GL_REPO}: $tag with IP $ENV{'SSH_CLIENT'}"; + + my $project = get_project_info($tag); + + # Extract matching tag + my @rendus = grep { + exists $_->{vcs} and $_->{vcs}{tag} eq $tag; + } @{ $project->{submissions} }; + + if (@rendus) + { + if ($newsha eq '0' x 40) + { + log USAGE, "Mais pour quelle raison voudriez-vous supprimer un tag ?!"; + exit(7); + } + + chomp (my $tokengiven = `git cat-file tag $newsha 2> /dev/null | sed -e '1,/^\$/d'`); + if (! check_submission_date($tokengiven, @rendus)) + { + exit (9); + } + } + else + { + log ERROR, "$tag n'est pas un tag valide."; + exit(8) + } +} + +exit 0; + +sub get_project_info +{ my $project; eval { $project = API::Projects::get($id_project, $promo); @@ -58,10 +114,12 @@ if ($ref =~ m<^refs/tags/(.+)$>) log TRACE, $project; - # Extract lot of data - my @rendus = grep { - exists $_->{vcs} and $_->{vcs}{tag} eq $tag; - } @{ $project->{submissions} }; + return $project; +} + +sub check_submission_date +{ + my $tokengiven = shift; my $glts = DateTime::Format::ISO8601->parse_datetime( do { @@ -70,34 +128,16 @@ if ($ref =~ m<^refs/tags/(.+)$>) $t }); - chomp (my $tokengiven = `git cat-file tag $newsha 2> /dev/null | sed -e '1,/^\$/d'`); - for my $rendu (@rendus) + for my $rendu (@_) { my $open = DateTime::Format::ISO8601->parse_datetime($rendu->{period}{begin}); my $close = DateTime::Format::ISO8601->parse_datetime($rendu->{period}{end}); - if ($id_project eq "myhttpd" && grep { $_ eq $repo_login } @apping) - { - $open = DateTime::Format::ISO8601->parse_datetime("2013-11-08T20:00:00"); - $close = DateTime::Format::ISO8601->parse_datetime("2013-11-10T11:42:00"); - } - elsif ($id_project eq "logomatig" && grep { $_ eq $repo_login } @salonS) - { - $open = DateTime::Format::ISO8601->parse_datetime("2013-11-24T09:00:00"); - $close = DateTime::Format::ISO8601->parse_datetime("2013-11-24T21:00:00"); - } - elsif ($id_project eq "logomatig" && grep { $_ eq $repo_login } @salonD) - { - $open = DateTime::Format::ISO8601->parse_datetime("2013-11-23T21:00:00"); - } - elsif ($id_project eq "logomatig" && "dufour_h" eq $repo_login) - { - $close = DateTime::Format::ISO8601->parse_datetime("2013-11-24T16:42:00"); - } - elsif ($id_project eq "42sh" && "hadjad_r" eq $repo_login) - { - $close = DateTime::Format::ISO8601->parse_datetime("2013-12-01T17:42:00"); - } +# if ($id_project eq "myhttpd" && grep { $_ eq $repo_login } @apping) +# { +# $open = DateTime::Format::ISO8601->parse_datetime("2013-11-08T20:00:00"); +# $close = DateTime::Format::ISO8601->parse_datetime("2013-11-10T11:42:00"); +# } say "Date courante : ", $glts->strftime("%d/%m/%Y %H:%M:%S"); @@ -124,13 +164,5 @@ if ($ref =~ m<^refs/tags/(.+)$>) } } - if (@rendus && $newsha eq '0' x 40) - { - log USAGE, "Mais pour quelle raison voudriez-vous supprimer un tag ?!"; - exit(7); - } -# elsif @rendus : new rendu => accepted -# else user defined tag => accepted + return 1; } - -exit 0; From 15408c1144559ab7529d357bd8570d3a4bc2dbfb Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 2 Dec 2013 23:33:39 +0100 Subject: [PATCH 093/137] Remove INFO submission --- hooks/submissions.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/submissions.pl b/hooks/submissions.pl index f9cca96..c455d7e 100755 --- a/hooks/submissions.pl +++ b/hooks/submissions.pl @@ -41,7 +41,7 @@ exit(0) if (!$promo || !$id_project || !$repo_login); if ($ref =~ m<^refs/tags/ACU-(.+)$>) { my $tag = $1; - log INFO, "Pushed tag for repository $ENV{GL_REPO}: $tag with IP $ENV{'SSH_CLIENT'}"; + log DEBUG, "Pushed tag for repository $ENV{GL_REPO}: $tag with IP $ENV{'SSH_CLIENT'}"; # Disallow no ACU if ($ENV{GL_USER} ne "frotti_b" && $ENV{GL_USER} ne "chen_a" && $ENV{GL_USER} ne "boisse_r" && $ENV{GL_USER} ne "genite_n" && $ENV{GL_USER} ne "mercie_d") @@ -66,7 +66,7 @@ if ($ref =~ m<^refs/tags/ACU-(.+)$>) elsif ($ref =~ m<^refs/tags/(.+)$>) { my $tag = $1; - log INFO, "Pushed tag for repository $ENV{GL_REPO}: $tag with IP $ENV{'SSH_CLIENT'}"; + log DEBUG, "Pushed tag for repository $ENV{GL_REPO}: $tag with IP $ENV{'SSH_CLIENT'}"; my $project = get_project_info($tag); From 6d294dbcf658e6fa9e9d0d0540d4b29e3804f81e Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Tue, 3 Dec 2013 01:08:47 +0100 Subject: [PATCH 094/137] Save witch person push or clone to a repo --- hooks/gl-pre-git | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/gl-pre-git b/hooks/gl-pre-git index dba50c0..00c3c8a 100755 --- a/hooks/gl-pre-git +++ b/hooks/gl-pre-git @@ -14,7 +14,7 @@ my $ip = $1 if ($ENV{'SSH_CLIENT'} =~ m/([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0- exit 0 if (!$ip); -log DEBUG, "Connection with $ARGV[0] to $ENV{GL_REPO} from $ip"; +log DEBUG, "Connection by $ENV{GL_USER} with $ARGV[0] to $ENV{GL_REPO} from $ip"; my $promo = qx(git config hooks.promo); my $id_project = qx(git config hooks.idproject); From 4e1e73f2847a9767691c4a5ba933e2c3987ff64a Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 5 Dec 2013 00:54:04 +0100 Subject: [PATCH 095/137] Add intradmin-hamano to gen_git_str for send_git process --- commands/project/gen_git_str.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/project/gen_git_str.pl b/commands/project/gen_git_str.pl index bb4b74f..f3f07fe 100644 --- a/commands/project/gen_git_str.pl +++ b/commands/project/gen_git_str.pl @@ -34,5 +34,5 @@ map { say " - ACU-moulette = ", join(" ", @members); say ' RW+ = @admins ', join(" ", @members); say ' RW ACU-moulette = @moulettes'; - say " R = \@chefs \@resp-$year-$projid \@soutenance-$year-$projid \@moulettes"; + say " R = \@chefs \@resp-$year-$projid \@soutenance-$year-$projid \@moulettes intradmin-hamano"; } @{ $res->{groups} }; From d1b027a3fff05dde4a20df5409006ea4c22ce27e Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 5 Dec 2013 00:54:30 +0100 Subject: [PATCH 096/137] Autoflush log filehandles --- ACU/Log.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ACU/Log.pm b/ACU/Log.pm index a1641b1..bf3f165 100644 --- a/ACU/Log.pm +++ b/ACU/Log.pm @@ -52,12 +52,17 @@ sub log if (!$log_fd && $log_file) { open ($log_fd, ">>", $log_file) or croak("Unable to open log ($log_file) file for writing"); + + # Enable autoflush for the log file + my $previous_default = select($log_fd); + $|++; + select($previous_default); + say $log_fd strftime("%a %b %e %H:%M:%S %Y", localtime), " START new logging session "; } if ($level <= $save_level and $log_fd) { - local $| = 1; print $log_fd strftime("%a %b %e %H:%M:%S %Y", localtime), " ", levelstr($level), " "; if ($level == TRACE) { @@ -102,12 +107,17 @@ The lerdorf project", sendmail($mail); } - if ($level <= $display_level) { + if ($level <= $display_level) + { + $|++; # Autoflush STDOUT + if ($level == PENDING) { print STDERR (leveldisp($level), @_, RESET, "\r"); } else { say STDERR (leveldisp($level), @_, RESET); } + + $|--; # Disable autoflush } if ($fatal_warn && $level <= WARN){ From 4af0617cae8f06555762f8681ec8dfccde13b7bf Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 5 Dec 2013 01:09:55 +0100 Subject: [PATCH 097/137] Receive ACU-* tags --- hooks/post-update | 93 +++++++++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 44 deletions(-) diff --git a/hooks/post-update b/hooks/post-update index ee163b2..9f13577 100755 --- a/hooks/post-update +++ b/hooks/post-update @@ -30,54 +30,59 @@ exit(0) if (!$promo || !$id_project || !$repo_login); for my $ref (@ARGV) { - if ($ref =~ m<^refs/tags/ACU-(.+)$> || $ref =~ m<^refs/tags/(.+)$>) + my $tag; + if ($ref =~ m<^refs/tags/ACU-(.+)$>) { + $tag = $1; + } elsif ($ref =~ m<^refs/tags/(.+)$>) { + $tag = $1; + } else { + next; + } + + log DEBUG, "Tag $tag on repository $ENV{GL_REPO} from IP $ENV{'SSH_CLIENT'} updated."; + + my $project = get_project_info($tag); + + # Extract matching tag + my @rendus = grep { + exists $_->{vcs} and $_->{vcs}{tag} eq $tag; + } @{ $project->{submissions} }; + + if (@rendus) { - my $tag = $1; - log DEBUG, "Tag $tag on repository $ENV{GL_REPO} from IP $ENV{'SSH_CLIENT'} updated."; - - my $project = get_project_info($tag); - - # Extract matching tag - my @rendus = grep { - exists $_->{vcs} and $_->{vcs}{tag} eq $tag; - } @{ $project->{submissions} }; - - if (@rendus) + eval { - eval - { - Process::Client::launch("send_git", - { - "year" => $promo, - "id" => $id_project, - "rendu" => $tag, - "login" => $repo_login, -# "path" => "ssh://git\@localhost/".$ENV{GL_REPO}, # Optional - }, - undef, # Don't give any file - 1 # Launch in background - ); - }; - if ($@) - { - my $err = $@; + Process::Client::launch("send_git", + { + "year" => $promo, + "id" => $id_project, + "rendu" => $tag, + "login" => $repo_login, +# "path" => "ssh://git\@localhost/".$ENV{GL_REPO}, # Optional + }, + undef, # Don't give any file + 1 # Launch in background + ); + }; + if ($@) + { + my $err = $@; log DEBUG, "ERROR: ".$err; - } + } - # Send data to API - my $last_commit = `git log "refs/tags/$tag" -1 --decorate --tags`; - eval { - API::Submission::add($promo, $id_project, $tag, $repo_login, $last_commit); - }; - if ($@) - { - my $err = $@; - log DEBUG, "ERROR: ".$err; - log DONE, "Tag '$tag' effectué avec succès !"; - } - else { - log DONE, "Tag '$tag' effectué avec succès ! Vérifiez-le sur l'intranet."; - } + # Send data to API + my $last_commit = `git log "refs/tags/$tag" -1 --decorate --tags`; + eval { + API::Submission::add($promo, $id_project, $tag, $repo_login, $last_commit); + }; + if ($@) + { + my $err = $@; + log DEBUG, "ERROR: ".$err; + log DONE, "Tag '$tag' effectué avec succès !"; + } + else { + log DONE, "Tag '$tag' effectué avec succès ! Vérifiez-le sur l'intranet."; } } } From ba19732a47799a243c9243a45a029debb9adbbd2 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 5 Dec 2013 05:00:09 +0100 Subject: [PATCH 098/137] post-update hook: ACU- --- hooks/post-update | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/hooks/post-update b/hooks/post-update index 9f13577..f08b54d 100755 --- a/hooks/post-update +++ b/hooks/post-update @@ -31,21 +31,28 @@ exit(0) if (!$promo || !$id_project || !$repo_login); for my $ref (@ARGV) { my $tag; - if ($ref =~ m<^refs/tags/ACU-(.+)$>) { + my $tag_for; + if ($ref =~ m<^refs/tags/(ACU-(.+))$>) + { $tag = $1; - } elsif ($ref =~ m<^refs/tags/(.+)$>) { + $tag_for = $2; + } + elsif ($ref =~ m<^refs/tags/(.+)$>) + { $tag = $1; - } else { + $tag_for = $1; + } + else { next; } - log DEBUG, "Tag $tag on repository $ENV{GL_REPO} from IP $ENV{'SSH_CLIENT'} updated."; + log DEBUG, "Tag $tag ($tag_for) on repository $ENV{GL_REPO} from IP $ENV{'SSH_CLIENT'} updated."; - my $project = get_project_info($tag); + my $project = get_project_info($tag_for); # Extract matching tag my @rendus = grep { - exists $_->{vcs} and $_->{vcs}{tag} eq $tag; + exists $_->{vcs} and $_->{vcs}{tag} eq $tag_for; } @{ $project->{submissions} }; if (@rendus) @@ -73,7 +80,7 @@ for my $ref (@ARGV) # Send data to API my $last_commit = `git log "refs/tags/$tag" -1 --decorate --tags`; eval { - API::Submission::add($promo, $id_project, $tag, $repo_login, $last_commit); + API::Submission::add($promo, $id_project, $tag_for, $repo_login, $last_commit); }; if ($@) { @@ -103,7 +110,7 @@ sub get_project_info exit(1); } - log TRACE, $project; + #log TRACE, $project; return $project; } From 95f945f963afde2f595edb16024fe62e758c1f37 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 5 Dec 2013 05:55:35 +0100 Subject: [PATCH 099/137] send_git: ACU- --- process/files/send_git.pl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/process/files/send_git.pl b/process/files/send_git.pl index 8f29176..ae50509 100644 --- a/process/files/send_git.pl +++ b/process/files/send_git.pl @@ -21,6 +21,11 @@ sub process my $rendu = $args->{param}{rendu}; my $login = $args->{param}{login}; + my $rendu_for = $rendu; + if ($rendu =~ /^(ACU|YAKA)-(.*)$/) { + $rendu_for = $1; + } + my $path = $args->{param}{path} // "ssh://git\@localhost/$year/$project_id/$login.git"; my $tempdir = tempdir(); @@ -30,10 +35,10 @@ sub process croak "$path is not a valid repository." if ($?); my $tar; - open my $fh, "tar -czf - -C '$tempdir' . |" or die ($!); + open my $fh, "tar -czf - -C '$tempdir' . |" or die ("Error during tar: " . $!); $tar .= $_ while(<$fh>); close $fh; - die "Unable to untar: $!" if ($?); + die "Unable to tar: $!" if ($?); # Clean remove_tree($tempdir); @@ -43,7 +48,7 @@ sub process "type" => "std", "id" => $project_id, "year" => $year, - "rendu" => $rendu, + "rendu" => $rendu_for, "login" => $login, "file" => "rendu.tgz" }, From 973bc3f7b1e8b967e245662fc4bb71b55495a14b Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 5 Dec 2013 05:59:06 +0100 Subject: [PATCH 100/137] send_git: fix ACU- --- process/files/send_git.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/files/send_git.pl b/process/files/send_git.pl index ae50509..9fc2dd4 100644 --- a/process/files/send_git.pl +++ b/process/files/send_git.pl @@ -23,7 +23,7 @@ sub process my $rendu_for = $rendu; if ($rendu =~ /^(ACU|YAKA)-(.*)$/) { - $rendu_for = $1; + $rendu_for = $2; } my $path = $args->{param}{path} // "ssh://git\@localhost/$year/$project_id/$login.git"; From 0e0a93789eb8fff60240577d0b27aa6e063c6bb6 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 5 Dec 2013 06:01:52 +0100 Subject: [PATCH 101/137] Add new command for moulette: stats --- commands/moulette/stats.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 commands/moulette/stats.sh diff --git a/commands/moulette/stats.sh b/commands/moulette/stats.sh new file mode 100644 index 0000000..ffaa24c --- /dev/null +++ b/commands/moulette/stats.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ -z "$2" ] +then + echo "Usage: $0" + exit 1 +fi + +if ! which gearman > /dev/null 2> /dev/null +then + echo "gearman isn't installed on this machine. Please try another one." + exit 1 +fi + +cat < + + moulette + stats + +EOF From 81150b41fea3bc71e21d2eaa1d0a35266fcd27a9 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 5 Dec 2013 06:03:28 +0100 Subject: [PATCH 102/137] Fix stats --- commands/moulette/stats.sh | 6 ------ 1 file changed, 6 deletions(-) mode change 100644 => 100755 commands/moulette/stats.sh diff --git a/commands/moulette/stats.sh b/commands/moulette/stats.sh old mode 100644 new mode 100755 index ffaa24c..3cfaaf2 --- a/commands/moulette/stats.sh +++ b/commands/moulette/stats.sh @@ -1,11 +1,5 @@ #!/bin/sh -if [ -z "$2" ] -then - echo "Usage: $0" - exit 1 -fi - if ! which gearman > /dev/null 2> /dev/null then echo "gearman isn't installed on this machine. Please try another one." From 3c60afe6e90894115afc95c02d4d48ab291d9b8a Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 5 Dec 2013 06:05:24 +0100 Subject: [PATCH 103/137] Fix stats --- commands/moulette/stats.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/commands/moulette/stats.sh b/commands/moulette/stats.sh index 3cfaaf2..355e79e 100755 --- a/commands/moulette/stats.sh +++ b/commands/moulette/stats.sh @@ -9,7 +9,6 @@ fi cat < - moulette - stats + stats EOF From 4d003d66262db637d9f1189bbc85b30250d58b3c Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 5 Dec 2013 06:44:43 +0100 Subject: [PATCH 104/137] Add new moulette command: set_workers --- commands/moulette/set_workers.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 commands/moulette/set_workers.sh diff --git a/commands/moulette/set_workers.sh b/commands/moulette/set_workers.sh new file mode 100755 index 0000000..e03cce3 --- /dev/null +++ b/commands/moulette/set_workers.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ -z "$1" ] +then + echo "Usage: $0 " + exit 1 +fi + +if ! which gearman > /dev/null 2> /dev/null +then + echo "gearman isn't installed on this machine. Please try another one." + exit 1 +fi + +cat < + + set_workers + $1 + +EOF From 874c6bc482e4447a82e420b245c5e5a2ef85216e Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 5 Dec 2013 06:44:50 +0100 Subject: [PATCH 105/137] Fix moulette/launch: can pass more than one login --- commands/moulette/launch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/moulette/launch.sh b/commands/moulette/launch.sh index 1b79ab6..0ebc4cd 100755 --- a/commands/moulette/launch.sh +++ b/commands/moulette/launch.sh @@ -27,7 +27,7 @@ shift 2 LOGINS= while [ $# -gt 0 ] do - LOGINS=" $1 + LOGINS="$LOGINS $1 " shift done From 4482f47eec1eb4eb9a05ae473519041c65cdf073 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 5 Dec 2013 06:48:42 +0100 Subject: [PATCH 106/137] Fix set_workers --- commands/moulette/set_workers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/moulette/set_workers.sh b/commands/moulette/set_workers.sh index e03cce3..724d43a 100755 --- a/commands/moulette/set_workers.sh +++ b/commands/moulette/set_workers.sh @@ -16,6 +16,6 @@ cat < set_workers - $1 + $1 EOF From eb8c74d46555cd0b41c345b663c6506ca65d61c8 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 5 Dec 2013 07:19:20 +0100 Subject: [PATCH 107/137] Add action flush to stats --- commands/moulette/launch.sh | 2 ++ commands/moulette/set_workers.sh | 2 ++ commands/moulette/stats.sh | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/commands/moulette/launch.sh b/commands/moulette/launch.sh index 0ebc4cd..f77e141 100755 --- a/commands/moulette/launch.sh +++ b/commands/moulette/launch.sh @@ -41,3 +41,5 @@ cat <$RENDU $LOGINS EOF + +echo diff --git a/commands/moulette/set_workers.sh b/commands/moulette/set_workers.sh index 724d43a..ec77cf9 100755 --- a/commands/moulette/set_workers.sh +++ b/commands/moulette/set_workers.sh @@ -19,3 +19,5 @@ cat <$1 EOF + +echo diff --git a/commands/moulette/stats.sh b/commands/moulette/stats.sh index 355e79e..0c1ac6e 100755 --- a/commands/moulette/stats.sh +++ b/commands/moulette/stats.sh @@ -6,9 +6,24 @@ then exit 1 fi +ACTION= +if [ -n "$1" ] +then + if [ "$1" = "flush" ] + then + ACTION=" flush +" + else + echo "Unknown action '$1'" + exit 1 + fi +fi + cat < stats - +$ACTION EOF + +echo From 737a12d44352f3ce79119f4e45796d38c8692059 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Fri, 6 Dec 2013 00:10:03 +0100 Subject: [PATCH 108/137] Excpetion --- hooks/submissions.pl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hooks/submissions.pl b/hooks/submissions.pl index c455d7e..ec46cad 100755 --- a/hooks/submissions.pl +++ b/hooks/submissions.pl @@ -133,11 +133,12 @@ sub check_submission_date my $open = DateTime::Format::ISO8601->parse_datetime($rendu->{period}{begin}); my $close = DateTime::Format::ISO8601->parse_datetime($rendu->{period}{end}); -# if ($id_project eq "myhttpd" && grep { $_ eq $repo_login } @apping) -# { -# $open = DateTime::Format::ISO8601->parse_datetime("2013-11-08T20:00:00"); +# if ($id_project eq "atelier-cpp-j4" && grep { $_ eq $repo_login } @apping) + if ($id_project eq "atelier-cpp-j4" && "bes_e" eq $repo_login) + { + $open = DateTime::Format::ISO8601->parse_datetime("2013-12-06T00:00:00"); # $close = DateTime::Format::ISO8601->parse_datetime("2013-11-10T11:42:00"); -# } + } say "Date courante : ", $glts->strftime("%d/%m/%Y %H:%M:%S"); From 0e3fe1fd1cd1f3e0b08a19780be9b6a06d4ab7fc Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Fri, 6 Dec 2013 16:33:56 +0100 Subject: [PATCH 109/137] Exception, ticket #22149 --- hooks/submissions.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hooks/submissions.pl b/hooks/submissions.pl index ec46cad..2f75b12 100755 --- a/hooks/submissions.pl +++ b/hooks/submissions.pl @@ -134,10 +134,10 @@ sub check_submission_date my $close = DateTime::Format::ISO8601->parse_datetime($rendu->{period}{end}); # if ($id_project eq "atelier-cpp-j4" && grep { $_ eq $repo_login } @apping) - if ($id_project eq "atelier-cpp-j4" && "bes_e" eq $repo_login) + if ($id_project eq "raytracer" && "dubois_d" eq $repo_login) { - $open = DateTime::Format::ISO8601->parse_datetime("2013-12-06T00:00:00"); -# $close = DateTime::Format::ISO8601->parse_datetime("2013-11-10T11:42:00"); +# $open = DateTime::Format::ISO8601->parse_datetime("2013-12-06T00:00:00"); + $close = DateTime::Format::ISO8601->parse_datetime("2013-12-08T18:42:00"); } say "Date courante : ", $glts->strftime("%d/%m/%Y %H:%M:%S"); From cdb64f192f63e4d94f887d3fafdb01bce60c1fba Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 8 Dec 2013 08:28:49 +0100 Subject: [PATCH 110/137] Mark ACU- and YAKA- as reserved tag --- hooks/subjects.pl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hooks/subjects.pl b/hooks/subjects.pl index 75ac74d..f6425e1 100755 --- a/hooks/subjects.pl +++ b/hooks/subjects.pl @@ -375,17 +375,22 @@ sub tag_project my $mod = 0; for my $vcs ($dom->documentElement()->getElementsByTagName("vcs")) { + if (! $vcs->hasAttribute("tag") || $vcs->getAttribute("tag") =~ /^(ACU|YAKA)-/) { + log ERROR, "Un tag de rendu ne peut pas commencer par ACU- ou YAKA-."; # C'est réservé pour les moulettes + } + if (! $vcs->hasAttribute("token")) { if ($project) { # Looking for an old token my @rendus = grep { - exists $_->{vcs} and $_->{vcs}{tag} eq $vcs->hasAttribute("tag"); + exists $_->{vcs} and $_->{vcs}{tag} eq $vcs->getAttribute("tag"); } @{ $project->{submissions} }; - if (@rendus == 1) { - log INFO, "Use existing token: ".$rendus[0]->{vcs}{token}; + if (@rendus == 1) + { + log DEBUG, "Use existing token: ".$rendus[0]->{vcs}{token}; $vcs->setAttribute("token", substr($rendus[0]->{vcs}{token}, 2, 23)); $mod = 1; next; From 531864ef8df0c173e3b4267f1776f0a05a31c88e Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 9 Dec 2013 18:48:52 +0100 Subject: [PATCH 111/137] Allow . in defense filename --- hooks/subjects.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/subjects.pl b/hooks/subjects.pl index f6425e1..ba81913 100755 --- a/hooks/subjects.pl +++ b/hooks/subjects.pl @@ -120,7 +120,7 @@ sub tag_defense } my $defense_id; - if ($path =~ /^(?:defenses\/)?([a-zA-Z0-9\/]+)(?:.xml)?$/) { + if ($path =~ /^(?:defenses\/)?([a-zA-Z0-9.\/]+)(?:.xml)?$/) { $defense_id = $1; } else { log ERROR, "Déplacez votre soutenance dans le dossier defenses ou simplifiez le nom du fichier."; From 744c3db27c30a6c82343a1dd2cc9b4fcc952e60e Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Mon, 9 Dec 2013 22:53:42 +0100 Subject: [PATCH 112/137] Fix account creation --- utils/lpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/lpt b/utils/lpt index 8ce5293..06eff09 100755 --- a/utils/lpt +++ b/utils/lpt @@ -271,7 +271,7 @@ sub cmd_account_create($@) if (! $ou) { - my $mesg = $ldap->add( "$oudn", + my $mesg = $ldap->add( "$oudn,dc=acu,dc=epita,dc=fr", attrs => [ objectclass => [ "top", "organizationalUnit" ], ou => "$group", @@ -284,7 +284,7 @@ sub cmd_account_create($@) } } - my $mesg = $ldap->add( "uid=$login,$oudn", + my $mesg = $ldap->add( "uid=$login,$oudn,dc=acu,dc=epita,dc=fr", attrs => [ objectclass => [ "top", "epitaAccount" ], uidNumber => shift, From 33222d78c5d6977567739aa5a4a6a07dd2cae358 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 12 Dec 2013 05:42:57 +0100 Subject: [PATCH 113/137] Fix defense_id generation --- hooks/subjects.pl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hooks/subjects.pl b/hooks/subjects.pl index ba81913..89119a0 100755 --- a/hooks/subjects.pl +++ b/hooks/subjects.pl @@ -97,7 +97,7 @@ sub tag_defense my $path; if ($_[3]) { - if ($_[3] =~ /^(?:defenses\/)?([a-zA-Z0-9_.\/-]+)(?:.xml)?$/) { + if ($_[3] =~ /^(?:defenses\/)?([a-zA-Z0-9_.\/-]+?)(?:.xml)?$/) { $path = "defenses/".$1.".xml"; } else { $path = $_[3]; @@ -119,12 +119,11 @@ sub tag_defense chomp($path); } - my $defense_id; - if ($path =~ /^(?:defenses\/)?([a-zA-Z0-9.\/]+)(?:.xml)?$/) { - $defense_id = $1; - } else { - log ERROR, "Déplacez votre soutenance dans le dossier defenses ou simplifiez le nom du fichier."; - } + log WARN, "Placez votre soutenance dans le dossier defenses/." if ($path !~ /^defenses/); + + my $defense_id = basename($path); + $defense_id =~ s/\.xml$//; + $defense_id =~ s/[^a-zA-Z0-9_.-]/_/g; my $year; if ($_[4]) From 700002396bae4abf85d41c9566c0e2d8e2c32627 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 12 Dec 2013 10:19:01 +0100 Subject: [PATCH 114/137] Add Apping2/3 to habitent_loin exception --- ACU/API/Projects.pm | 2 +- Makefile | 15 ++++++++++++++- hooks/gl-pre-git | 3 ++- hooks/subjects.pl | 4 +++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ACU/API/Projects.pm b/ACU/API/Projects.pm index eb39572..473fcc4 100644 --- a/ACU/API/Projects.pm +++ b/ACU/API/Projects.pm @@ -16,7 +16,7 @@ sub add($$;$) my $flavor = shift; my $year = shift; - if ($year and $year != LDAP::get_year) { + if ($year and $year ne LDAP::get_year) { croak "Impossible d'ajouter un projet d'une autre année : non implémenté"; } diff --git a/Makefile b/Makefile index 9aba33a..15244d4 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,13 @@ COPY?=cp -v +CURL?=curl DEST?=/usr/local/share/perl/`ls -1 /usr/local/share/perl/ | grep "^5." | tail -1`/ GIT?=/usr/bin/git GITOLITE_DEST?=/usr/share/gitolite/hooks/common MAKEDIR?=mkdir +PERL?=/usr/bin/env perl PROVER?=prove -f RM?=rm +RMTREE?=rm -r TESTDIR?=t SHELL?=/bin/sh @@ -29,7 +32,7 @@ guantanamo.tar.gz: $(COPY) process/exec/run.sh.not-here guantanamo/run.sh chmod +x guantanamo/run.sh tar czf guantanamo.tar.gz guantanamo/ - rm -rf guantanamo + $(RMTREE) guantanamo update: $(GIT) pull @@ -43,6 +46,16 @@ unstall: ! test -d $(GITOLITE_DEST) || $(RM) -rf $(GITOLITE_DEST)/update.secondary.d ! test -d $(GITOLITE_DEST) || $(MAKEDIR) -p $(GITOLITE_DEST)/update.secondary.d +regen-objects: + $(MAKEDIR) -p ACU/dtd + $(CURL) -o ACU/dtd/defense.dtd http://acu.epita.fr/dtd/defense.dtd + $(CURL) -o ACU/dtd/grading.dtd http://acu.epita.fr/dtd/grading.dtd + $(CURL) -o ACU/dtd/groups.dtd http://acu.epita.fr/dtd/groups.dtd + $(CURL) -o ACU/dtd/project.dtd http://acu.epita.fr/dtd/project.dtd + $(CURL) -o ACU/dtd/traces.dtd http://acu.epita.fr/dtd/traces.dtd + $(PERL) -I baldr baldr/Baldr.pl --import="ACU/Objects/basecode/*.pm" --path=ACU/Objects ACU/dtd/defense.dtd ACU/dtd/grading.dtd ACU/dtd/groups.dtd ACU/dtd/project.dtd ACU/dtd/traces.dtd + $(RMTREE) ACU/dtd + test: $(PROVER) $(TESTDIR) diff --git a/hooks/gl-pre-git b/hooks/gl-pre-git index 00c3c8a..db3886d 100755 --- a/hooks/gl-pre-git +++ b/hooks/gl-pre-git @@ -20,6 +20,7 @@ my $promo = qx(git config hooks.promo); my $id_project = qx(git config hooks.idproject); my $repo_login = qx(git config hooks.repologin); +my @apping3 = qw(saadi_n lucas_e jawhar_s france_b roux_m bamba_m boudje_s gillot_l le-pen_m gimene_a nguye_d marin_c); my @habitent_loin = qw(amed_m bellev_m freima_m ikouna_l simon_j faure_n abdelm_a habri_z trang_d henrie_p verbec_y molini_v); # First, check if the repository is in the YYYY/ directory @@ -49,7 +50,7 @@ if ($ip->overlaps($labnetwork) == $IP_A_IN_B_OVERLAP) # exit 1; #} -exit 0 if (grep { /\Q$ENV{GL_USER}\E/ } @habitent_loin); +exit 0 if (grep { /\Q$ENV{GL_USER}\E/ } @habitent_loin, @apping3, "icaza_fact"); my $schoolnetwork = Net::IP->new('10.41.0.0/16'); my $vjschoolnetwork = Net::IP->new('10.3.0.0/16'); diff --git a/hooks/subjects.pl b/hooks/subjects.pl index 89119a0..220272a 100755 --- a/hooks/subjects.pl +++ b/hooks/subjects.pl @@ -306,6 +306,7 @@ sub tag_project # 2: $year my $project_id = repository_name(); + my $flavour = ""; if ($_[1]) { # Check on ID/flavour_id @@ -314,6 +315,7 @@ sub tag_project } $project_id .= "-" . $_[1]; + $flavour = $_[1]; } $project_id = lc $project_id; $project_id =~ s/[^a-z0-9-_]/_/g; @@ -423,7 +425,7 @@ sub tag_project log INFO, "Information de l'intranet..."; # Call API eval { - API::Projects::add($project_id, $year); + API::Projects::add($project_id, $flavour, $year); }; if ($@) { From 929d146770874b3a671e5f4a85853b85eb195201 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 15 Dec 2013 12:17:33 +0100 Subject: [PATCH 115/137] Ticket #22220: Two new habitent_loin --- hooks/gl-pre-git | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/gl-pre-git b/hooks/gl-pre-git index db3886d..07cde2f 100755 --- a/hooks/gl-pre-git +++ b/hooks/gl-pre-git @@ -21,7 +21,7 @@ my $id_project = qx(git config hooks.idproject); my $repo_login = qx(git config hooks.repologin); my @apping3 = qw(saadi_n lucas_e jawhar_s france_b roux_m bamba_m boudje_s gillot_l le-pen_m gimene_a nguye_d marin_c); -my @habitent_loin = qw(amed_m bellev_m freima_m ikouna_l simon_j faure_n abdelm_a habri_z trang_d henrie_p verbec_y molini_v); +my @habitent_loin = qw(amed_m bellev_m freima_m ikouna_l simon_j faure_n abdelm_a habri_z trang_d henrie_p verbec_y molini_v marti_o colin_j); # First, check if the repository is in the YYYY/ directory exit 0 if (($promo && $id_project && $repo_login) || $ENV{GL_REPO} !~ /^2[0-9]{3}\/.+\/.+/); From 65e2f61319b5137b127e1bc3648650eb220f9186 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 15 Dec 2013 18:31:46 +0100 Subject: [PATCH 116/137] Fix connection to gearman server --- process/exec/guantanamo.pl | 2 +- process/projects/gen_grading.pl | 2 +- process/projects/get_csv.pl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/process/exec/guantanamo.pl b/process/exec/guantanamo.pl index 706def8..b40da88 100644 --- a/process/exec/guantanamo.pl +++ b/process/exec/guantanamo.pl @@ -196,5 +196,5 @@ sub process_master log INFO, "Starting guantanamo.pl as master process"; -Process::add_server("gearman:4730"); +Process::add_server("gearmand:4730"); Process::register("guantanamo", \&process_master); diff --git a/process/projects/gen_grading.pl b/process/projects/gen_grading.pl index 9b91ff5..0236b68 100644 --- a/process/projects/gen_grading.pl +++ b/process/projects/gen_grading.pl @@ -97,5 +97,5 @@ sub process return $grade->toString; } -Process::add_server("gearman:4730"); +Process::set_servers("gearmand:4730"); Process::register_no_parse("gen_grading", \&process); diff --git a/process/projects/get_csv.pl b/process/projects/get_csv.pl index cc32ab3..eb1f0f2 100644 --- a/process/projects/get_csv.pl +++ b/process/projects/get_csv.pl @@ -105,5 +105,5 @@ sub process return $out; } -Process::set_servers("gearman:4730"); +Process::set_servers("gearmand:4730"); Process::register_no_parse("get_csv", \&process); From 3e5a587dd1c28c5a3597d0cb997634db7711d1dd Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 18 Dec 2013 19:13:06 +0100 Subject: [PATCH 117/137] Allow LSE to connect to project-lse repo --- hooks/gl-pre-git | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hooks/gl-pre-git b/hooks/gl-pre-git index 07cde2f..cc47188 100755 --- a/hooks/gl-pre-git +++ b/hooks/gl-pre-git @@ -50,6 +50,8 @@ if ($ip->overlaps($labnetwork) == $IP_A_IN_B_OVERLAP) # exit 1; #} +exit 0 if ($id_project eq "lse-project" && $ip->ip() eq "10.224.4.1"); + exit 0 if (grep { /\Q$ENV{GL_USER}\E/ } @habitent_loin, @apping3, "icaza_fact"); my $schoolnetwork = Net::IP->new('10.41.0.0/16'); From 3a5dbc55a8dbe9df4a9697395199136b782d417b Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 18 Dec 2013 21:22:38 +0100 Subject: [PATCH 118/137] Add new APPING3 for TC --- hooks/gl-pre-git | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/gl-pre-git b/hooks/gl-pre-git index cc47188..ea1f206 100755 --- a/hooks/gl-pre-git +++ b/hooks/gl-pre-git @@ -20,7 +20,7 @@ my $promo = qx(git config hooks.promo); my $id_project = qx(git config hooks.idproject); my $repo_login = qx(git config hooks.repologin); -my @apping3 = qw(saadi_n lucas_e jawhar_s france_b roux_m bamba_m boudje_s gillot_l le-pen_m gimene_a nguye_d marin_c); +my @apping3 = qw(saadi_n lucas_e jawhar_s france_b roux_m bamba_m boudje_s gillot_l le-pen_m gimene_a nguye_d marin_c piedno_j salmon_b); my @habitent_loin = qw(amed_m bellev_m freima_m ikouna_l simon_j faure_n abdelm_a habri_z trang_d henrie_p verbec_y molini_v marti_o colin_j); # First, check if the repository is in the YYYY/ directory From 5b1382fc716f0e7d7a6ec24bfe8631b6388d8efc Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 19 Dec 2013 09:04:57 +0100 Subject: [PATCH 119/137] pizzin_a allowed to push erlear --- hooks/submissions.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hooks/submissions.pl b/hooks/submissions.pl index 2f75b12..e3a5dbf 100755 --- a/hooks/submissions.pl +++ b/hooks/submissions.pl @@ -134,10 +134,10 @@ sub check_submission_date my $close = DateTime::Format::ISO8601->parse_datetime($rendu->{period}{end}); # if ($id_project eq "atelier-cpp-j4" && grep { $_ eq $repo_login } @apping) - if ($id_project eq "raytracer" && "dubois_d" eq $repo_login) + if (($id_project eq "bistromathique" || $id_project eq "pthl") && "pizzin_a" eq $repo_login) { -# $open = DateTime::Format::ISO8601->parse_datetime("2013-12-06T00:00:00"); - $close = DateTime::Format::ISO8601->parse_datetime("2013-12-08T18:42:00"); + $open = DateTime::Format::ISO8601->parse_datetime("2013-12-19T18:00:00"); +# $close = DateTime::Format::ISO8601->parse_datetime("2013-12-08T18:42:00"); } say "Date courante : ", $glts->strftime("%d/%m/%Y %H:%M:%S"); From c6352b889704c9bf2a4c474ba73998f217763276 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Fri, 20 Dec 2013 17:35:22 +0100 Subject: [PATCH 120/137] Set a default ID on eval without id --- ACU/Trace.pm | 2 +- process/files/intradata_get.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ACU/Trace.pm b/ACU/Trace.pm index 9e08935..97f3edf 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -354,7 +354,7 @@ sub new ($$;$) { my $class = shift; my $self = { - id => shift, + id => shift // "", type => shift // "test", values => {}, logs => {}, diff --git a/process/files/intradata_get.pl b/process/files/intradata_get.pl index 649674d..7869a11 100644 --- a/process/files/intradata_get.pl +++ b/process/files/intradata_get.pl @@ -105,7 +105,7 @@ sub grades_generate log DEBUG, "Generating grades for $login"; for my $dir (@trace_dirs) { - log DEBUG, "Fetching identifiers from $dir"; + log DEBUG, "Will fetch identifiers from $dir"; # Looking for a group traces first for my $grp (@{ $groups->{groups} }) From ea711bc7bc990f87be8f7e5b94c7e2a0ddf556bd Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 22 Dec 2013 11:44:22 +0100 Subject: [PATCH 121/137] Ticket #22238 --- hooks/submissions.pl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hooks/submissions.pl b/hooks/submissions.pl index e3a5dbf..9bd0b40 100755 --- a/hooks/submissions.pl +++ b/hooks/submissions.pl @@ -24,6 +24,7 @@ my $id_project; my $repo_login; my @apping = qw(zinger_a zebard_w zanell_a yao_p vinois_a sraka_y soupam_j seck_a ngomsi_s morin_h milis_e menkar_m eusebe_r crief_a chhum_s boumra_n blemus_a bengan_l amasho_a); +my @expcep = qw(azerno_t baudry_v dechen_g drouin_n dupuis_a fenech_a hamdao_y lanclu_j langre_m manuel_c palson_c trang_d wajntr_a); my @salonD = qw(aniss_i bogalh_j boulea_b cloare_l elhach_h gabrie_j kaplan_p manuel_c palson_c pizzin_a wajntr_a); my @salonS = qw(allio_a cadet_l digius_p drouin_n dubois_d dupuis_a langre_m lim_j); @@ -133,11 +134,11 @@ sub check_submission_date my $open = DateTime::Format::ISO8601->parse_datetime($rendu->{period}{begin}); my $close = DateTime::Format::ISO8601->parse_datetime($rendu->{period}{end}); -# if ($id_project eq "atelier-cpp-j4" && grep { $_ eq $repo_login } @apping) - if (($id_project eq "bistromathique" || $id_project eq "pthl") && "pizzin_a" eq $repo_login) + if (($id_project eq "bistromathique" || $id_project eq "pthl") && grep { $_ eq $repo_login } @expcep) +# if (($id_project eq "bistromathique" || $id_project eq "pthl") && "pizzin_a" eq $repo_login) { - $open = DateTime::Format::ISO8601->parse_datetime("2013-12-19T18:00:00"); -# $close = DateTime::Format::ISO8601->parse_datetime("2013-12-08T18:42:00"); +# $open = DateTime::Format::ISO8601->parse_datetime("2013-12-19T18:00:00"); + $close = DateTime::Format::ISO8601->parse_datetime("2013-12-22T19:42:00"); } say "Date courante : ", $glts->strftime("%d/%m/%Y %H:%M:%S"); From f5ff3c83b3890c746f2fdd2c026cfa8659bb9e43 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 9 Jan 2014 18:00:29 +0100 Subject: [PATCH 122/137] Grades from defenses are now the same for the group --- ACU/Trace.pm | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/ACU/Trace.pm b/ACU/Trace.pm index 97f3edf..865449b 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -133,14 +133,23 @@ sub getIds { my $self = shift; my $login = shift; + my $onlyNonZero = shift // 0; my %ids; foreach my $group (@{ $self->{groups} }) { - my %tmp = $group->getIds($login); + my %tmp; + if ($self->{type} eq "defense") + { + # For a defense, we consider that this is a group grade, so don't consider login filtering + %tmp = $group->getIds(); + } else { + %tmp = $group->getIds($login); + } + while (my ($key, $value) = each %tmp) { - $ids{$key} = $value; + $ids{$key} = $value if !$onlyNonZero || $value; } } return \%ids; @@ -148,19 +157,7 @@ sub getIds sub getNonZeroIds { - my $self = shift; - my $login = shift; - - my %ids; - foreach my $group (@{ $self->{groups} }) - { - my %tmp = $group->getIds($login); - while (my ($key, $value) = each %tmp) - { - $ids{$key} = $value if $value; - } - } - return \%ids; + return getIds($_[0], $_[1], 1); } sub getValue From 8170216edc7402973635a205667e0d1ce753f153 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 9 Jan 2014 21:44:47 +0100 Subject: [PATCH 123/137] Add debug --- ACU/Grading.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/ACU/Grading.pm b/ACU/Grading.pm index f473289..d27d480 100644 --- a/ACU/Grading.pm +++ b/ACU/Grading.pm @@ -355,6 +355,7 @@ sub compute ($$$;$$$) $value += $ids->{ $r }; } $ids->{ $ref } = $value if ($value); + log DEBUG, "New globbing identifier caculated $ref: $value"; } }; if ($@) { From 5e174fc053efd110278773a43399d40048ee0f16 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 12 Jan 2014 05:00:24 +0100 Subject: [PATCH 124/137] New moulette command: can set max_memory variable --- commands/moulette/set_max_memory.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 commands/moulette/set_max_memory.sh diff --git a/commands/moulette/set_max_memory.sh b/commands/moulette/set_max_memory.sh new file mode 100644 index 0000000..48ccf1c --- /dev/null +++ b/commands/moulette/set_max_memory.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +if [ -z "$1" ] +then + echo "Usage: $0 " + exit 1 +fi + +if ! which gearman > /dev/null 2> /dev/null +then + echo "gearman isn't installed on this machine. Please try another one." + exit 1 +fi + +cat < + + set_memory + $1 + +EOF + +echo From 1a250697269cbdc621d97f3fad50e38c55535a9d Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 12 Jan 2014 05:00:57 +0100 Subject: [PATCH 125/137] New moulette command: can send a tarball (e.g.: for exam) --- commands/moulette/send_tarball.sh | 83 +++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100755 commands/moulette/send_tarball.sh diff --git a/commands/moulette/send_tarball.sh b/commands/moulette/send_tarball.sh new file mode 100755 index 0000000..77f0ec7 --- /dev/null +++ b/commands/moulette/send_tarball.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +usage() +{ + echo "Usage: $0 [-d] [year] " +} + +if [ -z "$4" ] +then + usage + exit 1 +fi + +if ! which gearman > /dev/null 2> /dev/null +then + echo "gearman isn't installed on this machine. Please try another one." + exit 1 +fi + +if [ "x$1" = "x-d" ] +then + BACKGROUD= + shift +else + BACKGROUD="-b" +fi + +if [ "x${1:0:2}" = "x20" ] +then + YEAR=" $1" + shift +else + YEAR= +fi +PROJECT_ID=$1 +RENDU=$2 +LOGIN=$3 + +if ! [ -f "$4" ] +then + usage + exit 2 +fi + +MIME=`file -b -i "$4" | cut -d ';' -f 1` + +if [ "$MIME" = "application/x-bzip2" ] +then + FILE=`bzip2 --decompress --stdout "$4" | gzip --stdout | base64` + +elif [ "$MIME" = "application/x-gzip" ] +then + FILE=`gzip --decompress --stdout "$4" | gzip --stdout | base64` + +elif [ "$MIME" = "application/x-xz" ] +then + FILE=`xz --decompress --stdout "$4" | gzip --stdout | base64` + +elif [ "$MIME" = "application/x-tar" ] +then + FILE=`tar cz "$4" | base64` + +elif [ "$MIME" = "inode/directory" ] +then + FILE=`tar xf "$4" | tar cz | base64` + +else + echo "I don't know how to treat $4" >&2 + exit 3 +fi + +cat < + + std +$YEAR + $PROJECT_ID + $RENDU + $LOGIN + rendu.tgz + $FILE + +EOF From 6dca90348ab7aa29757af1ada249157b7db3d2d9 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 12 Jan 2014 05:01:29 +0100 Subject: [PATCH 126/137] New git_str format: allow moulettes to push tags begining by ACU- --- commands/project/gen_git_str.pl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/commands/project/gen_git_str.pl b/commands/project/gen_git_str.pl index f3f07fe..e825048 100644 --- a/commands/project/gen_git_str.pl +++ b/commands/project/gen_git_str.pl @@ -31,8 +31,10 @@ map { } say "repo $year/$projid/$chief->{login}"; - say " - ACU-moulette = ", join(" ", @members); - say ' RW+ = @admins ', join(" ", @members); - say ' RW ACU-moulette = @moulettes'; - say " R = \@chefs \@resp-$year-$projid \@soutenance-$year-$projid \@moulettes intradmin-hamano"; + say " - ACU-moulette = ", join(" ", @members); + say " - refs/tags/ACU- = ", join(" ", @members); + say ' RW+ = @admins ', join(" ", @members); + say ' RW ACU-moulette = @moulettes'; + say ' RW+ refs/tags/ACU- = @moulettes'; + say " R = \@chefs \@resp-$year-$projid \@soutenance-$year-$projid \@moulettes intradmin-hamano"; } @{ $res->{groups} }; From cb9bf00da4221cbcd3b055eb6e5f459d2738a03c Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 12 Jan 2014 05:02:00 +0100 Subject: [PATCH 127/137] check_ssh_key: now check file content before type validity --- process/ldap/check_ssh_key.pl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/process/ldap/check_ssh_key.pl b/process/ldap/check_ssh_key.pl index 99584a1..4295e53 100644 --- a/process/ldap/check_ssh_key.pl +++ b/process/ldap/check_ssh_key.pl @@ -17,8 +17,16 @@ use ACU::Log; sub check_key($) { my $filename = shift; + + # Check file content format + open my $fh, "<", $filename; + my $fcnt = <$fh>; + close $fh; + chomp($fcnt); + # Call ssh-keygen - if (`ssh-keygen -l -f $filename 2> /dev/null` =~ /^([0-9]+) +[0-9a-f:]+ +.+ +\(([A-Z]+)\)$/) + if ($fcnt =~ /^(ssh|ecdsa)-[a-z0-9-]+ [a-zA-Z0-9+=\/]+( .*)?$/ && + `ssh-keygen -l -f $filename 2> /dev/null` =~ /^([0-9]+) +[0-9a-f:]+ +.+ +\(([A-Z]+)\)$/) { log INFO, "Receive valid key: type $2, size $1"; if ($2 eq "RSA") { From e9ea5fc3a5929058ec1efa4f127c80f9b45c01b1 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 12 Jan 2014 05:54:35 +0100 Subject: [PATCH 128/137] Solve #22243 --- ACU/Defense.pm | 8 ++++---- hooks/subjects.pl | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ACU/Defense.pm b/ACU/Defense.pm index d286567..b481a19 100644 --- a/ACU/Defense.pm +++ b/ACU/Defense.pm @@ -134,10 +134,10 @@ sub genIds ($;$) for my $group (@{ $self->{groups} }) { my $cur_gid; - if (! $group->{id} || grep { /^\Q$group->{id}\E$/ } @ids) + if (! $group->{id} || grep { $_ == $group->{id} } @ids) { do { - $cur_gid = "def".$def_i."g".$grp_i; + $cur_gid = "def_".$def_i."g".$grp_i; $grp_i += 1; } while (grep {$_ eq $cur_gid} @ids); $group->{id} = $cur_gid; @@ -151,7 +151,7 @@ sub genIds ($;$) for my $question (@{ $group->{questions_list} }) { my $cur_qid; - if (! $question->{id} || grep { /^\Q$question->{id}\E$/ } @ids) + if (! $question->{id} || grep { $_ == $question->{id} } @ids) { do { $cur_qid = $cur_gid."q".$qst_i; @@ -167,7 +167,7 @@ sub genIds ($;$) my $ans_i = 0; for my $answer (@{ $question->{answers} }) { - if (! $answer->{id} || grep { /^\Q$answer->{id}\E$/ } @ids) + if (! $answer->{id} || grep { $_ == $answer->{id} } @ids) { my $cur_aid; do { diff --git a/hooks/subjects.pl b/hooks/subjects.pl index 220272a..03ba63b 100755 --- a/hooks/subjects.pl +++ b/hooks/subjects.pl @@ -168,7 +168,7 @@ sub tag_defense # Generate questions and answer id my $defense = Defense->new(\$content); - $defense->genIds(); + $defense->genIds($defense_id); # Send data to intradata log INFO, "Attente d'un processus de publication..."; From 6e70dc24ff5b4710ef12e1007b087fe7363a5544 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Sun, 12 Jan 2014 06:27:12 +0100 Subject: [PATCH 129/137] lpt: new command account add to import account information from passwd like file. Closes #22244 --- utils/lpt | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/utils/lpt b/utils/lpt index 06eff09..1042983 100755 --- a/utils/lpt +++ b/utils/lpt @@ -73,6 +73,7 @@ my %cmds = my %cmds_account = ( + "add" => \&cmd_account_add, "alias" => \&cmd_account_alias, "close" => \&cmd_account_close, "cn" => \&cmd_account_cn, @@ -250,6 +251,45 @@ sub cmd_account_cn($@) return cmd_account_vieworchange('cn', 'name', @_); } +sub cmd_account_add($@) +{ + my $login = shift; + my $passwd_path = shift // "./passwd"; + + if (! -f $passwd_path) + { + log(USAGE, "lpt account add [./passwd] [nopass|passgen|password]"); + return 1; + } + + open my $fh, "<", $passwd_path; + my @passwd_cnt = <$fh>; + close($fh); + + for my $line (grep { /^$login:x/ } @passwd_cnt) + { + if ($line =~ /^$login:x:([0-9]+):([0-9]+):([^ :]+) ?([^:]*):/) + { + my $uid = $1; + my $gid = $2; + my $firstname = ucfirst $3; + my $lastname = ucfirst $4; + + if (! $noconfirm) + { + say "Add user: ", YELLOW, BOLD, "$login", RESET, ":\n\tFirstname: ", BOLD, $firstname, RESET, "\n\tLastname: ", BOLD, $lastname, RESET, "\n\tUID:\t", BOLD, $uid, RESET, "\n\tGroup:\t", BOLD, $gid, RESET; + + print "Would you like to add this user? [", GREEN, "y", RESET, "/", RED, "N", RESET, "] "; + my $go = ; + chomp $go; + next if ($go ne "y" and $go ne "yes"); + } + + cmd_account_create($login, $gid, $uid, $firstname, $lastname, @_); + } + } +} + sub cmd_account_create($@) { my $login = shift; @@ -299,7 +339,7 @@ sub cmd_account_create($@) if ($mesg->code == 0) { log(INFO, "Account added: $login"); - my $pass = shift; + my $pass = shift // "nopass"; return cmd_account($login, $pass, @_) if ($pass ne "nopass"); return 0; } @@ -1950,6 +1990,12 @@ B [I [I [I [...]]]] If are given, display only those attributes. +B I [./passwd] [nopass|password|passgen] + + This is used to create a new Epita account, base for intra and/or lab account. + + This will use the passwd file given in argument to import information about the login. + B I [nopass|password|passgen] This is used to create a new Epita account, base for intra and/or lab account. From aa3b69f5b3b5eb27515d1d4636167d567c886ab3 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Tue, 14 Jan 2014 00:58:44 +0100 Subject: [PATCH 130/137] Grades: fix globing exponentiation --- ACU/Grading.pm | 2 +- commands/project/create.pl | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ACU/Grading.pm b/ACU/Grading.pm index d27d480..479258f 100644 --- a/ACU/Grading.pm +++ b/ACU/Grading.pm @@ -352,7 +352,7 @@ sub compute ($$$;$$$) { my $value = 0; for my $r (grep { match_glob($ref, $_); } keys %$ids) { - $value += $ids->{ $r }; + $value += $ids->{ $r } if ($ref != $r); } $ids->{ $ref } = $value if ($value); log DEBUG, "New globbing identifier caculated $ref: $value"; diff --git a/commands/project/create.pl b/commands/project/create.pl index 8407a7e..6dd50c9 100644 --- a/commands/project/create.pl +++ b/commands/project/create.pl @@ -4,15 +4,13 @@ use v5.10.1; use strict; use warnings; -use lib "../../"; - use ACU::API::Base; use ACU::API::Projects; if ($#ARGV == 0) { - API::Projects::add($ARGV[0]); + API::Projects::add($ARGV[0], ""); } else { From b38f15b0b632cfb5eabb0e063b4c08dd507d0b90 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 15 Jan 2014 00:40:41 +0100 Subject: [PATCH 131/137] Allow negative bonus --- process/files/intradata_get.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/files/intradata_get.pl b/process/files/intradata_get.pl index 7869a11..d4243dc 100644 --- a/process/files/intradata_get.pl +++ b/process/files/intradata_get.pl @@ -203,7 +203,7 @@ sub grades_new_bonus for my $line (@lines) { - if ($line =~ /^([a-z0-9_-]+)(?:\s*:\s*([0-9.]+))?$/) + if ($line =~ /^([a-z0-9_-]+)(?:\s*:\s*(-?[0-9.]+))?$/) { my $login = $1; my $tvalue = $2 // $value; From 4877749a765d1189d513db088be3a2598aa8e6df Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Wed, 15 Jan 2014 19:43:22 +0100 Subject: [PATCH 132/137] Implement delId method for traces --- ACU/Trace.pm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ACU/Trace.pm b/ACU/Trace.pm index 865449b..402d79c 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -120,7 +120,7 @@ sub delId { if (!$value || $value == $group->getValue()) { - #$self->{groups} = \{ grep { ! } @{ $self->{groups} } }; + $self->{groups} = \{ grep { $_->{id} ne $key } @{ $self->{groups} } }; } last; } @@ -255,8 +255,18 @@ sub delId my $key = shift; my $value = shift; - foreach my $item (@{ $self->{groups} }) + foreach my $group (@{ $self->{groups} }) { + if ($group->{id} eq $key) + { + if (!$value || $value == $group->getValue()) + { + $self->{groups} = \{ grep { $_->{id} ne $key } @{ $self->{groups} } }; + } + last; + } + + $group->delId($key, $value); } } @@ -404,6 +414,11 @@ sub parseEval } } +sub delId +{ + # Do nothing here, just an abstract method +} + sub getIds { my $self = shift; From 24df9247e746c41eeb4df9cc230fb3e32e26330c Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 16 Jan 2014 23:25:03 +0100 Subject: [PATCH 133/137] Bonus/malus are now individual by default --- ACU/Trace.pm | 18 +++++++++++++++++- process/files/intradata_get.pl | 3 ++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ACU/Trace.pm b/ACU/Trace.pm index 402d79c..43507b6 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -10,6 +10,8 @@ use utf8; use open qw(:encoding(UTF-8) :std); use XML::LibXML; +use ACU::Log; + sub new { my $class = shift; @@ -106,6 +108,8 @@ sub addId my $e = Trace::Eval->new($key); $e->addValue(undef, $value); push @{ $self->{groups} }, $e; + + return $e; } sub delId @@ -120,7 +124,7 @@ sub delId { if (!$value || $value == $group->getValue()) { - $self->{groups} = \{ grep { $_->{id} ne $key } @{ $self->{groups} } }; + $self->{groups} = [ grep { $_->{id} ne $key } @{ $self->{groups} } ]; } last; } @@ -228,6 +232,8 @@ use strict; use warnings; use Carp; +use ACU::Log; + sub new ($$) { my $class = shift; @@ -419,6 +425,16 @@ sub delId # Do nothing here, just an abstract method } +sub changeWho +{ + my $self = shift; + + $self->{who} = { + login => shift, + type => shift // "login" + }; +} + sub getIds { my $self = shift; diff --git a/process/files/intradata_get.pl b/process/files/intradata_get.pl index d4243dc..e68f333 100644 --- a/process/files/intradata_get.pl +++ b/process/files/intradata_get.pl @@ -235,7 +235,8 @@ sub grades_new_bonus $trace->delId($kbonus); } } else { - $trace->addId($kbonus, $tvalue); + my $e = $trace->addId($kbonus, $tvalue); + $e->changeWho($login, "login"); } log DEBUG, "Updating $basedir/$year/$project_id/traces/bonus/$login.xml"; From 767a4f9be249b08b850ecd93431a9ff97c438eaf Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 16 Jan 2014 23:32:52 +0100 Subject: [PATCH 134/137] Trace printer handles tags --- ACU/Trace.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ACU/Trace.pm b/ACU/Trace.pm index 43507b6..e8e8a43 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -498,6 +498,14 @@ sub toString($$) $e->setAttribute("id", $self->{id}); $e->setAttribute("type", $self->{type}); + if (defined $self->{who}) + { + my $w = $doc->createElement("who"); + $w->setAttribute("login", $self->{who}{login}); + $w->setAttribute("type", $self->{who}{type}) if (defined $self->{who}{type}); + $e->appendChild( $w ); + } + for my $k (keys %{ $self->{values} }) { my $v = $doc->createElement("value"); From 8ddca7c49aef970dc39e7c15bda6a5c14ad90657 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Fri, 17 Jan 2014 00:05:44 +0100 Subject: [PATCH 135/137] Fix format of who tags --- ACU/Trace.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACU/Trace.pm b/ACU/Trace.pm index e8e8a43..8abed90 100644 --- a/ACU/Trace.pm +++ b/ACU/Trace.pm @@ -501,8 +501,8 @@ sub toString($$) if (defined $self->{who}) { my $w = $doc->createElement("who"); - $w->setAttribute("login", $self->{who}{login}); $w->setAttribute("type", $self->{who}{type}) if (defined $self->{who}{type}); + $w->appendTextNode( $self->{who}{login} ); $e->appendChild( $w ); } From 2e5b2af4d830d36c278983f3e80721e6d7c93c5e Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Fri, 17 Jan 2014 01:52:20 +0100 Subject: [PATCH 136/137] Multi-thread grades generation --- process/files/intradata_get.pl | 36 +++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/process/files/intradata_get.pl b/process/files/intradata_get.pl index e68f333..6ca8ca3 100644 --- a/process/files/intradata_get.pl +++ b/process/files/intradata_get.pl @@ -2,6 +2,7 @@ use v5.10.1; use strict; +use threads; use warnings; use Carp; use Pod::Usage; @@ -98,7 +99,38 @@ sub grades_generate my @trace_dirs = grep { ( ! /^\./ ) && -d "$basedir/$year/$project_id/traces/$_" } readdir($dh); closedir $dh; - for my $login (@logins) + my @ths; + my $max_ths = 4; + my $login_by_threads = @logins / $max_ths; + + for (my $i = 0; $i < $max_ths; $i++) + { + my @partlogin = @logins[($i*$login_by_threads) .. (($i+1)*$login_by_threads - 1)]; + push @ths, threads->create(\&do_grade_generation, $grading, $year, $project_id, $groups, \@trace_dirs, @partlogin); + } + + if ($login_by_threads * $max_ths < @logins) + { + my @partlogin = @logins[$login_by_threads * $max_ths .. $#logins]; + push @ths, threads->create(\&do_grade_generation, $grading, $year, $project_id, $groups, \@trace_dirs, @partlogin); + } + + for my $th (@ths) { + $th->join(); + } + + return 1; +} + +sub do_grade_generation +{ + my $grading = shift; + my $year = shift; + my $project_id = shift; + my $groups = shift; + my @trace_dirs = @{ shift() }; + + for my $login (@_) { my @files; @@ -157,8 +189,6 @@ sub grades_generate $grading->reset(); } - - return 1; } sub grades_new_bonus From b8d4ff1a588133cec26a2522f0c54cf6d703a77c Mon Sep 17 00:00:00 2001 From: Charlie Noyce Root Date: Fri, 17 Jan 2014 02:17:41 +0100 Subject: [PATCH 137/137] Revert "Multi-thread grades generation" This reverts commit 2e5b2af4d830d36c278983f3e80721e6d7c93c5e. --- process/files/intradata_get.pl | 36 +++------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/process/files/intradata_get.pl b/process/files/intradata_get.pl index 6ca8ca3..e68f333 100644 --- a/process/files/intradata_get.pl +++ b/process/files/intradata_get.pl @@ -2,7 +2,6 @@ use v5.10.1; use strict; -use threads; use warnings; use Carp; use Pod::Usage; @@ -99,38 +98,7 @@ sub grades_generate my @trace_dirs = grep { ( ! /^\./ ) && -d "$basedir/$year/$project_id/traces/$_" } readdir($dh); closedir $dh; - my @ths; - my $max_ths = 4; - my $login_by_threads = @logins / $max_ths; - - for (my $i = 0; $i < $max_ths; $i++) - { - my @partlogin = @logins[($i*$login_by_threads) .. (($i+1)*$login_by_threads - 1)]; - push @ths, threads->create(\&do_grade_generation, $grading, $year, $project_id, $groups, \@trace_dirs, @partlogin); - } - - if ($login_by_threads * $max_ths < @logins) - { - my @partlogin = @logins[$login_by_threads * $max_ths .. $#logins]; - push @ths, threads->create(\&do_grade_generation, $grading, $year, $project_id, $groups, \@trace_dirs, @partlogin); - } - - for my $th (@ths) { - $th->join(); - } - - return 1; -} - -sub do_grade_generation -{ - my $grading = shift; - my $year = shift; - my $project_id = shift; - my $groups = shift; - my @trace_dirs = @{ shift() }; - - for my $login (@_) + for my $login (@logins) { my @files; @@ -189,6 +157,8 @@ sub do_grade_generation $grading->reset(); } + + return 1; } sub grades_new_bonus