From: Andrew Ruthven Date: Wed, 28 May 2008 20:57:11 +0000 (+1200) Subject: It turns out that secondary backends don't return total diskspace. X-Git-Tag: 0.8.0~5 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=766e74d1f811a8b5f77ff0b5d987fe67e4156b60;p=mythtv-status.git It turns out that secondary backends don't return total diskspace. Handle that in a nicer manner. Thank you Steve Gunther for letting me know. --- diff --git a/ChangeLog b/ChangeLog index cc0e745..b0cdf5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-05-28 Andrew Ruthven + It turns out that secondary backends don't return total diskspace, + handle that in a nicer manner. Thank you Steve Gunther for letting + me know. + 2008-05-23 Andrew Ruthven Add a timeout for the HTTP request to the backend. diff --git a/bin/mythtv-status b/bin/mythtv-status index 1ef59df..3427286 100755 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@ -37,7 +37,7 @@ my $recording_in_warn = 60 * 60; # When is the next recording considered critica my $return_code_only = 0; -my $VERSION = '0.7.4'; +my $VERSION = '0.7.5'; # Some display blocks are disabled by default: $display{'Shows due to Auto Expire'} = 0; @@ -241,6 +241,7 @@ my @blocks = ( 'commify' => [ qw/_total_total _total_used/ ], 'template' => "Total space is ___total_total__ MB, with ___total_used__ MB used (__percent__)", 'format' => 'one line', + 'optional' => 1, 'subs' => { 'percent' => sub { calc_disk_space_percentage($_[0]->{'_total_used'}, $_[0]->{'_total_total'}) @@ -259,6 +260,7 @@ my @blocks = ( 'commify' => [ qw/drive_total_total drive_total_used/ ], 'template' => "Total space is __drive_total_total__ MB, with __drive_total_used__ MB used (__percent__)", 'format' => 'one line', + 'optional' => 1, 'subs' => { 'percent' => sub { calc_disk_space_percentage($_[0]->{'drive_total_used'}, $_[0]->{'drive_total_total'}) @@ -276,6 +278,7 @@ my @blocks = ( 'commify' => [ qw/total used/ ], 'template' => "Total space is __total__ MB, with __used__ MB used (__percent__)", 'format' => 'one line', + 'optional' => 1, 'subs' => { 'percent' => sub { calc_disk_space_percentage($_[0]->{'used'}, $_[0]->{'total'}) @@ -421,6 +424,7 @@ $output .= '=' x length($title) . "\n"; for my $block (@blocks) { $block->{'format'} ||= 'multi line'; + $block->{'optional'} ||= 0; warn "Considering: $block->{'name'}\n" if $verbose; @@ -772,8 +776,14 @@ sub substitute_vars { my ($key, $value); while (($key, $value) = (each %{ $vars })) { if (! defined $value) { - warn "Unable to find any value for $key while looking at $block->{'name'}\n"; - next; + if ($block->{'optional'}) { + warn "Unable to find any value for $key while at $block->{'name'}, marked as optional, skipping block.\n" + if $verbose; + return undef; + } else { + warn "Unable to find any value for $key while looking at $block->{'name'}\n"; + next; + } } $value = wrap(' ', ' ', $value) diff --git a/testing/xml/secondary-backend.xml b/testing/xml/secondary-backend.xml new file mode 100644 index 0000000..246918a --- /dev/null +++ b/testing/xml/secondary-backend.xml @@ -0,0 +1,298 @@ + + + + + + + + + + + Some say pigs are as smart as 3-year-old +humans; turning pigs into bacon, ham, ribs and sausage; boar semen +collection; the use of pig organs in medicine. + + + + + + The latest world and national +news. + + + Brian's keen sense +of smell gets him a job with the police department. + + + The latest world and national +news. + + + + + + + + + + + + Wealthy +people invade the humble town of South Park. + + + A gambler (George C. Scott) stakes pool shark +"Fast Eddie" Felson (Paul Newman) in a smoke-filled marathon +against Minnesota Fats (Jackie Gleason). + + + + + Bogus miracles and +duping gullible believers. + + + + 4 commercial break(s)On a visit +to Alcatraz, Phoebe sees the ghost of a serial killer escape from the +island to exact revenge on those responsible for his trip to the gas +chamber. + + + + Autodetect: 3.2 GB => 1.9 GBOn a visit +to Alcatraz, Phoebe sees the ghost of a serial killer escape from the +island to exact revenge on those responsible for his trip to the gas +chamber. + + + + 5 commercial break(s)Piper +switches powers with Leo (Brian Krause) to try to save his life, but +her spell changes her sisters' powers too. + + + + Autodetect: 3.2 GB => 2.0 GBPiper +switches powers with Leo (Brian Krause) to try to save his life, but +her spell changes her sisters' powers too. + + + + 3 commercial break(s)Teams try to guess five-letter words. + + + + 71% Completed @ 26.6586 fps.Teams try to guess five-letter words. + + + + + + + + Your + subscription expires on 06/19/08 22:36:41 + +