/[d-i]/trunk/scripts/aggregator.pl
ViewVC logotype

Contents of /trunk/scripts/aggregator.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 24126 - (show annotations) (download)
Wed Dec 1 23:50:28 2004 UTC (8 years, 5 months ago) by joeyh
File MIME type: text/plain
File size: 1930 byte(s)
add totals
1 #!/usr/bin/perl
2 # Perl module used by the aggregator programs.
3
4 use warnings;
5 use strict;
6
7 sub aggregate {
8 my $success=0;
9 my $failed=0;
10 my $total=0;
11 my $old=0;
12
13 foreach my $log (@_) {
14 print "<li><a href=\"".$log->{url}."\">".$log->{description}."</a><br>\n";
15 my $logurl=$log->{logurl}."overview".$log->{logext}."\n";
16 if ($logurl=~m#.*://#) {
17 if (! open (LOG, "wget --tries=3 --timeout=5 --quiet -O - $logurl |")) {
18 print "<b>wget error</b>\n";
19 }
20 }
21 else {
22 open (LOG, $logurl) || print "<b>cannot open $logurl</b>\n";
23 }
24 my @lines=<LOG>;
25 if (! close LOG) {
26 print "<b>failed</b> to download <a href=\"$logurl\">summary log</a>";
27 next;
28 }
29 if (! @lines) {
30 print "<b>empty</b> <a href=\"$logurl\">log</a>";
31 }
32 else {
33 print "<ul>\n";
34 }
35 foreach my $line (@lines) {
36 chomp $line;
37 my ($arch, $date, $builder, $ident, $status, $notes) =
38 $line =~ /^(.*?)\s+\((.*?)\)\s+(.*?)\s+(.*?)\s+(.*?)(?:\s+(.*))?$/;
39 if (! defined $status) {
40 print "<li><b>unparsable</b> entry:</i> $line\n";
41 }
42 else {
43 $date=~s/[^A-Za-z0-9: ]//g; # untrusted string
44 my $shortdate=`TZ=GMT LANG=C date -d '$date' '+%b %d %H:%M'`;
45 chomp $shortdate;
46 if (! length $shortdate) {
47 $shortdate=$date;
48 }
49 my $unixdate=`TZ=GMT LANG=C date -d '$date' '+%s'`;
50 if (length $unixdate &&
51 (time - $unixdate) > ($log->{frequency}+1) * 60*60*24) {
52 $shortdate="<b>$shortdate</b>";
53 $old++;
54 }
55 if ($status eq 'failed') {
56 $status='<b>failed</b>';
57 $failed++;
58 }
59 elsif ($status eq 'success') {
60 $success++;
61 }
62 $total++;
63 if (defined $notes && length $notes) {
64 $notes="($notes)";
65 }
66 else {
67 $notes="";
68 }
69 print "<li>$arch $shortdate $builder <a href=\"".$log->{logurl}."$ident".$log->{logext}."\">$status</a> $ident $notes\n";
70 }
71 }
72 print "</ul>\n";
73 }
74
75 return ($total, $failed, $success, $old);
76 }
77
78 1

  ViewVC Help
Powered by ViewVC 1.1.5