New importer, Nat. Geo. Wild.
[nonametv.git] / tools / nonametv-batchlog
blobabebf4b256b3f787610ecd3cb705d82032ddd86f
1 #!/usr/bin/perl -w
3 use strict;
5 use FindBin;
6 use lib "$FindBin::Bin/../lib";
8 use NonameTV;
9 use NonameTV::DataStore;
10 use NonameTV::Config qw/ReadConfig/;
12 use Getopt::Long;
13 use POSIX qw/strftime/;
14 use Template;
16 # Read configuration
17 my $conf = ReadConfig();
19 # Create Datastore
20 my $ds = NonameTV::DataStore->new( $conf->{DataStore} );
22 my $data = {
23 errors => [],
24 warnings => [],
25 files => [],
28 # Retrieve a list of all batches that have been aborted due to errors.
29 my( $res, $sth ) = $ds->sa->Sql(
30 "select * from batches where abort_message!='' order by name" );
32 while( my $d = $sth->fetchrow_hashref() ) {
33 push @{$data->{errors}}, $d;
36 $sth->finish();
38 # Retrieve a list of all batches that generated a warning.
39 ( $res, $sth ) = $ds->sa->Sql(
40 "select * from batches where message!='' order by name" );
42 while( my $d = $sth->fetchrow_hashref() )
44 push @{$data->{warnings}}, $d;
47 $sth->finish();
49 # Retrieve a list of all files with that generated a message
50 ( $res, $sth ) = $ds->sa->Sql(
51 "select * from files where message!='' order by channelid, filename" );
53 while( my $d = $sth->fetchrow_hashref() )
55 push @{$data->{files}}, $d;
58 $sth->finish();
60 GeneratePage( 'batchlog', $data );
62 sub GeneratePage {
63 my( $templatename, $data ) = @_;
65 my $config = {};
67 $config->{INCLUDE_PATH} = [ "$FindBin::Bin/../templates/" ];
68 if( defined( $NonameTV::Conf->{TemplateCountry} ) ) {
69 unshift( @{$config->{INCLUDE_PATH}},
70 "$FindBin::Bin/../templates/$NonameTV::Conf->{TemplateCountry}" );
74 # create Template object
75 my $template = Template->new($config);
77 $template->process( $templatename, $data );