failures completion
[buildfarm-server.git] / cgi-bin / show_stage_log.pl
1 #!/usr/bin/perl
2
3 =comment
4
5 Copyright (c) 2003-2010, Andrew Dunstan
6
7 See accompanying License file for license details
8
9 =cut 
10
11 use strict;
12 use DBI;
13 use Template;
14 use CGI;
15 use File::Temp qw(tempfile);
16
17 use vars qw($dbhost $dbname $dbuser $dbpass $dbport @log_file_names);
18
19
20 require "$ENV{BFConfDir}/BuildFarmWeb.pl";
21 #require "BuildFarmWeb.pl";
22
23 die "no dbname" unless $dbname;
24 die "no dbuser" unless $dbuser;
25
26 my $dsn="dbi:Pg:dbname=$dbname";
27 $dsn .= ";host=$dbhost" if $dbhost;
28 $dsn .= ";port=$dbport" if $dbport;
29
30 my $query = new CGI;
31
32 my $system = $query->param('nm'); $system =~ s/[^a-zA-Z0-9_ -]//g;
33 my $logdate = $query->param('dt');$logdate =~ s/[^a-zA-Z0-9_ -]//g;
34 my $stage = $query->param('stg');$stage =~ s/[^a-zA-Z0-9._ -]//g;
35
36 use vars qw($tgz);
37
38 if ($system && $logdate && $stage)
39 {
40     my $db = DBI->connect($dsn,$dbuser,$dbpass);
41
42     die $DBI::errstr unless $db;
43
44     my $statement = q(
45
46         select branch, log_text
47         from build_status_log
48         where sysname = ? and snapshot = ? and log_stage = ? || '.log'
49
50         );
51
52
53     
54     my $sth=$db->prepare($statement);
55     $sth->execute($system,$logdate,$stage);
56     my $row=$sth->fetchrow_arrayref;
57     my ($branch, $logtext) = ("unknown","no log text found");
58     if ($row)
59     {
60         $branch = $row->[0];
61         $logtext =$row->[1];
62     }
63     $sth->finish;
64     $db->disconnect;
65
66     print "Content-Type: text/plain\n\n", $logtext,
67
68     "-------------------------------------------------\n\n",
69     "Hosting for the PostgreSQL Buildfarm is generously ",
70     "provided by: CommandPrompt, The PostgreSQL Company";
71
72 }
73
74 else 
75 {
76     print "Status: 460 bad parameters\n",
77     "Content-Type: text/plain\n\n";
78 }
79