From: Andrew Ruthven Date: Thu, 6 Dec 2007 18:09:47 +0000 (+1300) Subject: Better suppress warnings from the API by using our own warning signal handler. X-Git-Tag: 0.6.0~16^2 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fremotes%2Forigin%2Frelease-0.5;p=mythtv-status.git Better suppress warnings from the API by using our own warning signal handler. --- diff --git a/ChangeLog b/ChangeLog index 38ad4a3..0e76a94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-12-07 Andrew Ruthven + Better suppress warnings from the MythTV Perl API if we can't access + the database. + 2007-12-06 Andrew Ruthven Be more paranoid about handling error conditions in the substitution code. diff --git a/bin/mythtv-status b/bin/mythtv-status index 0fece7d..3eb521f 100755 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@ -322,7 +322,12 @@ sub load_perl_api { my $myth = undef; eval { require MythTV }; - if (! $@) { + if ($@) { + print $@ + if $verbose; + } else { + # Surpress warnings from DBI. I tried unsetting $^W but that is ignored. + local($SIG{__WARN__}) = sub { if ($verbose) { print shift } }; eval { $myth = new MythTV() }; } @@ -371,7 +376,7 @@ sub process_conflicts { my ($block) = @_; $myth ||= load_perl_api(); - return "Unable to access MythTV Perl API." + return "Unable to access MythTV Perl API. Try with --verbose to find out why." unless defined $myth; my @lines;