From: Andrew Ruthven Date: Thu, 29 Nov 2007 21:53:48 +0000 (+1300) Subject: Merge commit 'origin/release-0.5' X-Git-Tag: 0.6.0~22 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=600764534231d4aeb5f2c5872888fc60e5469466;p=mythtv-status.git Merge commit 'origin/release-0.5' Conflicts: ChangeLog Makefile bin/mythtv-status debian/changelog --- 600764534231d4aeb5f2c5872888fc60e5469466 diff --cc ChangeLog index 676abed,dd5a869..ff6b81e --- a/ChangeLog +++ b/ChangeLog @@@ -3,10 -3,7 +3,11 @@@ This includes cleaning up some invalid UTF-8 characters. Add support for reading XML from a file. Be a bit more forgiving on the XML we're receiving. + Release version 0.5.2. + Show how much disk space is used - currently only total. + Rename "Time till next recording" to "Next Recording In". + Put all the one liners together in the output and make them line + up nicely. 2007-11-23 Andrew Ruthven Don't set the background when changing the colour. diff --cc bin/mythtv-status index cdd7100,13090a1..e4a24d3 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@@ -88,7 -87,7 +88,7 @@@ if (defined $colour && scalar(@email) = my %defaults = ( 'schedule' => { 'attrs' => [ qw/title startTime NODE_TEXT subTitle/ ], -- 'template' => "__startTime__ - __title__" ++ 'template' => "__startTime__ - __title__" . (defined $episode ? " - __subTitle__" : '') . (defined $description ? "\n__NODE_TEXT__" : ''), 'filter' => { @@@ -138,8 -129,8 +138,8 @@@ my @blocks = '/state/' =>{ '^0$' => "${safe}Idle${normal}", '^1$' => "${warning}Watching LiveTV${normal}", '^2$' => "${warning}Watching Pre-recorded${normal}", -- '^3$' => "${warning}Watching Recording${normal}", -- '^4$' => "${warning}Recording${normal}" }, ++ '^3$' => "${warning}Watching Recording${normal}", ++ '^4$' => "${warning}Recording${normal}" }, } }, @@@ -168,14 -159,14 +168,14 @@@ 'hide' => 'after', 'subs' => { 'find_next' => sub { -- my $vars = shift; ++ my $vars = shift; return -- if defined $next_time && $next_time eq 'now'; ++ if defined $next_time && $next_time eq 'now'; my $date = ParseDate($vars->{'startTime'}); -- if (! defined $next_time || Date_Cmp($date, $next_time) < 0) { -- $next_time = $date -- }; ++ if (! defined $next_time || Date_Cmp($date, $next_time) < 0) { ++ $next_time = $date ++ }; } } }, @@@ -188,71 -179,23 +188,71 @@@ 'sub' => \&process_conflicts }, + # Diskspace, before storage groups + { + 'name' => 'Total Disk Space', + 'type' => 'xpath', + 'xpath' => '//Status/MachineInfo/Storage', + 'xml_version' => [ "<= 31" ], + 'attrs' => [ qw/_total_total _total_used/ ], + 'commify' => [ qw/_total_total _total_used/ ], + 'template' => "Total space is ___total_total__ GB, with ___total_used__ GB used (__percent__)", + 'format' => 'one line', + 'subs' => { + 'percent' => sub { + my $vars = shift; + my $percent = sprintf("%.1f", - $vars->{'_total_used'} / $vars->{'_total_total'} * 100); - if ($percent >= $disk_space_warn) { - return "$warning$percent\%$normal"; - } else { - return "$safe$percent\%$normal"; - } ++ $vars->{'_total_used'} / $vars->{'_total_total'} * 100); ++ if ($percent >= $disk_space_warn) { ++ return "$warning$percent\%$normal"; ++ } else { ++ return "$safe$percent\%$normal"; ++ } + } + } + }, + + # Diskspace, with storage groups + { + 'name' => 'Total Disk Space', + 'type' => 'xpath', + 'xpath' => '//Status/MachineInfo/Storage', + 'xml_version' => [ ">= 32" ], + 'attrs' => [ qw/drive_total_total drive_total_used/ ], + 'commify' => [ qw/drive_total_total drive_total_used/ ], + 'template' => "Total space is __drive_total_total__ GB, with __drive_total_used__ GB used (__percent__)", + 'format' => 'one line', + 'subs' => { + 'percent' => sub { + my $vars = shift; + my $percent = sprintf("%.1f", - $vars->{'drive_total_used'} / $vars->{'drive_total_total'} * 100); - if ($percent >= $disk_space_warn) { - return "$warning$percent\%$normal"; - } else { - return "$safe$percent\%$normal"; - } ++ $vars->{'drive_total_used'} / $vars->{'drive_total_total'} * 100); ++ if ($percent >= $disk_space_warn) { ++ return "$warning$percent\%$normal"; ++ } else { ++ return "$safe$percent\%$normal"; ++ } + } + } + }, + # How many hours till the next recording. { - 'name' => 'Time till next recording', + 'name' => 'Next Recording In', 'type' => 'sub', 'format' => 'one line', 'template' => '__next_time__', 'rewrite' => { '&next_time' => sub { return "Never" -- unless defined $next_time; ++ unless defined $next_time; my $str = Delta_Format(DateCalc('now', $next_time, undef, 1), 0, '%hh Hours, %mv Minutes'); $str =~ s/\b1 (Hour|Minute)s/1 $1/; $str =~ s/^0 Hours, (.*)$/$warning$1$normal/; $str =~ s/ 0 Minutes//; -- return $str; ++ return $str; } }, 'filter' => { @@@ -351,7 -269,7 +351,7 @@@ if (scalar(@email) == 0) To => \@email, Subject => $title . ($schedule_conflicts_present ? ' - CONFLICTS' : ''), Data => $output -- ); ++ ); $mail->send('sendmail'); } @@@ -495,7 -392,7 +495,7 @@@ sub process_conflicts if ($show->{'recstatus'} == $recstatus_conflict) { my %vars = ( -- 'title' => $show->{'title'}, ++ 'title' => $show->{'title'}, 'startTime' => strftime("%FT%T", localtime($show->{'starttime'})), 'NODE_TEXT' => $show->{'description'}, 'subTitle' => $show->{'subtitle'} @@@ -551,12 -442,9 +551,12 @@@ sub substitute_vars my ($name, $sub); while (($name, $sub) = each %{ $block->{'subs'} }) { - &$sub($vars); + $value = &$sub($vars); + + $template =~ s/__${name}__/$value/g + if defined $value; } -- ++ return defined $skip ? undef : $template; }