From b125514655e8769842ab20f2c32e3fae7d2336a3 Mon Sep 17 00:00:00 2001 From: Jeff Irion Date: Fri, 22 Mar 2019 05:47:06 -0700 Subject: [PATCH] Improved exception handling and logging (#22268) Catch RuntimeError exceptions. Don't log ADB command output if there isn't any. --- homeassistant/components/androidtv/media_player.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/androidtv/media_player.py b/homeassistant/components/androidtv/media_player.py index 5ec4ef325f0..1d186484f40 100644 --- a/homeassistant/components/androidtv/media_player.py +++ b/homeassistant/components/androidtv/media_player.py @@ -163,7 +163,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): output = target_device.adb_command(cmd) # log the output if there is any - if output: + if output and (not isinstance(output, str) or output.strip()): _LOGGER.info("Output of command '%s' from '%s': %s", cmd, target_device.entity_id, repr(output)) @@ -223,7 +223,7 @@ class ADBDevice(MediaPlayerDevice): TcpTimeoutException) else: # Using "pure-python-adb" (communicate with ADB server) - self.exceptions = (ConnectionResetError,) + self.exceptions = (ConnectionResetError, RuntimeError) # Property attributes self._available = self.aftv.available