From b2abe52208d30ab1a041731dcc09467c3cb2ed7d Mon Sep 17 00:00:00 2001
From: Andrew Ruthven <andrew@etc.gen.nz>
Date: Fri, 7 Dec 2007 07:09:47 +1300
Subject: [PATCH] Better suppress warnings from the API by using our own
 warning signal handler.

---
 ChangeLog         | 4 ++++
 bin/mythtv-status | 9 +++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

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;
-- 
2.30.2