From 53eff6b60caca0dd78a31705f0d77fe848141eaa Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sun, 24 Jun 2012 21:42:54 +1200 Subject: [PATCH] Add a --save-file option to save the XML received from the backend. --- bin/mythtv-status | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/bin/mythtv-status b/bin/mythtv-status index 3cc498d..f1e458f 100755 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@ -52,12 +52,13 @@ $c->{'colour'} ||= 0; # my @email; $c->{'email_only_on_alert'} ||= 0; my $help = 0; -$c->{'xml_file'} ||= undef; my $verbose = 0; $c->{'disk_space_warn'} ||= 95; # Percent to warn at. $c->{'guide_days_warn'} ||= 2; # How many days we require. -$c->{'auto_expire_count'} ||= 10; # How many auto expire shows to display. +$c->{'auto_expire_count'} ||= 10; # How many auto expire shows to display. $c->{'recording_in_warn'} ||= 60 * 60; # When is the next recording considered critical? (seconds) +$c->{'save_file'} ||= undef; # File to save the XML from the BE to. +$c->{'xml_file'} ||= undef; # Load the BE XML from this file. # We allow a hack for MS Outlook which normally recognises the # oneliners block as a paragraph and wraps it. If it sees "bullets" @@ -84,7 +85,7 @@ my @size_thresholds = ( my $return_code_only = 0; -my $VERSION = '0.10.1'; +my $VERSION = '0.10.2'; # Some display blocks are disabled by default: $c->{'display'}{'Shows due to Auto Expire'} = 0; @@ -121,6 +122,7 @@ GetOptions( 'return-code-only' => \$return_code_only, 'file=s' => \$c->{'xml_file'}, + 's|save-file=s' => \$c->{'save_file'}, 'verbose' => \$verbose, 'help|?' => \$help, @@ -672,6 +674,13 @@ sub load_xml { ($charset) = ($content_type =~ /charset="(\S+?)"/); } + if (defined $c->{'save_file'}) { + open(OUT, "> $c->{'save_file'}") + || die "Failed to open " . $c->{'save_file'} . " for writing: $!\n"; + print OUT $status; + close OUT; + } + # Parse the XML my $parser = XML::LibXML->new(); @@ -683,7 +692,7 @@ sub load_xml { clean_xml(\$status); - # Try and hide any error messages thar XML::LibXML insists on printing out. + # Try and hide any error messages that XML::LibXML insists on printing out. open my $olderr, ">&STDERR"; open(STDERR, "> /dev/null") || die "Can't redirect stderr to /dev/null: $!"; @@ -1213,6 +1222,11 @@ Display help. Load XML from the file specified instead of querying a MythTV backend. Handy for debugging things. +=item B<< --save-file >> + +Save the XML we received from the MythTV backend. +Handy for debugging things. + =item B<< --guide-days-warn >> Warn if the number of days of guide data present is equal to or below -- 2.30.2