From c171750908af3d7a424fbebbe3a4f1d6dea838a7 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Thu, 13 Dec 2007 08:44:03 +1300 Subject: [PATCH] Add support for reporting on how much guide data is present. --- ChangeLog | 6 +++ bin/mythtv-status | 67 ++++++++++++++++++++++++++++-- testing/xml/guide-data-1-day.xml | 71 ++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 testing/xml/guide-data-1-day.xml diff --git a/ChangeLog b/ChangeLog index 4ce4b74..2b01696 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-12-13 Andre Ruthven + Warn if there isn't enough guide data present. + +2007-12-12 Andrew Ruthven + Release version 0.6.0 + 2007-12-08 Andrew Ruthven Allow using my new xmlVer attribute in the XML. If using my XML patches against MythTV show the disk space details. diff --git a/bin/mythtv-status b/bin/mythtv-status index db72a53..3e8d23c 100755 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@ -30,6 +30,7 @@ my $help = undef; my $xml_file = undef; my $verbose = 0; my $disk_space_warn = 95; # Percent to warn at. +my $guide_days_warn = 2; # How many days we require. my $VERSION = '0.6'; @@ -43,6 +44,7 @@ GetOptions( 'email=s@' => \@email, 'email-only-on-conflict|email-only-on-alert' => \$email_only_on_alert, 'disk-space-warn=i' => \$disk_space_warn, + 'guide-days-warn=i' => \$guide_days_warn, 'status!' => \$display{'Status'}, 'encoders!' => \$display{'Encoders'}, @@ -52,6 +54,7 @@ GetOptions( 'next-recording!' => \$display{'Next Recording In'}, 'total-disk-space!' => \$display{'Total Disk Space'}, 'disk-space!' => \$display{'Disk Space'}, + 'guide-data!' => \$display{'Guide Data'}, 'file=s' => \$xml_file, @@ -298,6 +301,51 @@ my @blocks = ( } }, + # Check how much Guide data we have + { + 'name' => 'Guide Data', + 'format' => 'one line', + 'type' => 'xpath', + 'xpath' => '//Status/MachineInfo/Guide[@guideDays]', + 'attrs' => [qw/guideDays status guideThru/], + 'template' => 'There is __guideDays__ days worth of data, through to __guideThru__', + 'filter' => { + 'guideDays' => sub { + if ($_[0] > $guide_days_warn) { + return + (defined $display{'Guide Data'} && ! $display{'Guide Data'}) || 1; + } else { + push @alerts, "GUIDE DATA"; + return 0; + } + }, + }, + 'rewrite' => { + '&guideDays' => sub { + if ($_[0] <= $guide_days_warn) { + return "$warning$_[0]$normal"; + } else { + return "$safe$_[0]$normal"; + } + }, + '/guideThru/' => { 'T\d+:\d+:\d+' => ' ' }, + '&guideThru' => sub { + if ($_[1]->{'guideDays'} <= $guide_days_warn) { + return "$warning$_[0]$normal"; + } else { + return "$safe$_[0]$normal"; + } + }, + }, + }, + + { + 'name' => 'Guide Data', + 'format' => 'one line', + 'type' => 'xpath', + 'xpath' => '//Status/MachineInfo/Guide[@status=""]', + 'template' => "${warning}No guide data!${normal}", + }, ); ### @@ -603,8 +651,10 @@ sub substitute_vars { while (($search, $replace) = each %{ $block->{'rewrite'}{"/$key/"} } ) { $value =~ s/$search/$replace/g; } - } elsif (defined $block->{'rewrite'}{"&$key"}) { - $value = &{ $block->{'rewrite'}{"&$key"} }($value); + } + + if (defined $block->{'rewrite'}{"&$key"}) { + $value = &{ $block->{'rewrite'}{"&$key"} }($value, $vars); } $value = commify($value) @@ -722,11 +772,16 @@ Display help. Load XML from the file specified instead of querying a MythTV backend. Handy for debugging things. +=item B<< --guide-data-warn >> + +Warn if the number of days of guide data present is equal to or below +this level. Default is 2 days. + =item B<-h HOST, --host=HOST> The host to check, defaults to localhost. -=item B<--nostatus>, B<--noencoders>, B<--norecording-now>, B<--noscheduled-recordings>, B<--noschedule-conflicts>, B<--nonext-recording>, B<--nototal-disk-space>, B<--nodisk-space> +=item B<--nostatus>, B<--noencoders>, B<--norecording-now>, B<--noscheduled-recordings>, B<--noschedule-conflicts>, B<--nonext-recording>, B<--nototal-disk-space>, B<--nodisk-space>, B<--noguide-data> Suppress displaying blocks of the output if they would normally be displayed. @@ -756,6 +811,12 @@ The output of this script is broken up into several chunks they are: Some general info about the backend, currently just the timestamp of when this program was run. +=item Guide Data + +The number of days of guide data is present. By default it is only shown +if the number of days is below the warning level. To show it regardless +of the warning level use --guide-data. + =item Encoders Each encoder that the backend knows about are listed, with the hostname diff --git a/testing/xml/guide-data-1-day.xml b/testing/xml/guide-data-1-day.xml new file mode 100644 index 0000000..6f0df31 --- /dev/null +++ b/testing/xml/guide-data-1-day.xml @@ -0,0 +1,71 @@ + + + + + 3 News + + + + + + + Grace's pride won't let her admit it was her poor credit rating that led to the bank's refusal to extend their overdraft. She has to learn to work with Kate when they're taken hostage by a distraught + + + Named Best New Comedy by American TV Guide + + + 3 News + + + A gripping drama series starring Emmy Award-winners James Spader and William Shatner along with a stellar support cast including Rhona Mitra + + + The teams must create a 60-second promotional video for new Microsoft software, with execs from the technology giant as the final judges. With only two people left on each team, the stakes are high. + + + 3 News + + + Grand Designs + + + 3 News + + + Two friends take the property-coaching route to riches; and a young couple mortgages their home to the hilt and goes without, to make their fortune. + + + + + Two teams take on the challenge to construct a super fast monster machine at least 5 metres long and weighing at least 5.5 tonnes. + + + + Classic car nuts, the Beasts of Bodmin, take on Essex forklift trio, The Powerlifters in one of the hardest challenges to date: making cars that can clamber over boulders. + + + + A collection of favourite clips from the engineering entertainment show that pits teams of madcap mechanics against each other. + + + + Adam and Jamie try to beat a heat-detecting alarm sensor, attempt to crack a door guarded by fingerprint technology and crack a safe only opened by an underwater explosion. + + + + Jamie and Adam play with high-speed wind and find out whether the wind in a hurricane can get strong enough to blow a piece of straw through a palm tree trunk and blow the feathers off a chicken. + + + + Jamie and Adam try to prove that a cable snapping at high tension can slice a person in half, while the others explore the theory that pottery contains sounds that can be played back like a record. + + + + + + + + + + -- 2.30.2