From 446390a8d1a3fa6f644178ca2403f99630c8025d Mon Sep 17 00:00:00 2001 From: Johann Kellerman Date: Tue, 27 Feb 2018 02:08:37 +0200 Subject: [PATCH] AsusWRT log exceptions (#12668) * logexception * Improve err message #2978 * not quiet * tests --- homeassistant/components/device_tracker/asuswrt.py | 10 +++++----- tests/components/device_tracker/test_asuswrt.py | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/device_tracker/asuswrt.py b/homeassistant/components/device_tracker/asuswrt.py index 1956e42cb78..14aea561c8e 100644 --- a/homeassistant/components/device_tracker/asuswrt.py +++ b/homeassistant/components/device_tracker/asuswrt.py @@ -283,15 +283,15 @@ class SshConnection(_Connection): lines = self._ssh.before.split(b'\n')[1:-1] return [line.decode('utf-8') for line in lines] except exceptions.EOF as err: - _LOGGER.error("Connection refused. SSH enabled?") + _LOGGER.error("Connection refused. %s", self._ssh.before) self.disconnect() return None except pxssh.ExceptionPxssh as err: - _LOGGER.error("Unexpected SSH error: %s", str(err)) + _LOGGER.error("Unexpected SSH error: %s", err) self.disconnect() return None except AssertionError as err: - _LOGGER.error("Connection to router unavailable: %s", str(err)) + _LOGGER.error("Connection to router unavailable: %s", err) self.disconnect() return None @@ -301,10 +301,10 @@ class SshConnection(_Connection): self._ssh = pxssh.pxssh() if self._ssh_key: - self._ssh.login(self._host, self._username, + self._ssh.login(self._host, self._username, quiet=False, ssh_key=self._ssh_key, port=self._port) else: - self._ssh.login(self._host, self._username, + self._ssh.login(self._host, self._username, quiet=False, password=self._password, port=self._port) super().connect() diff --git a/tests/components/device_tracker/test_asuswrt.py b/tests/components/device_tracker/test_asuswrt.py index 48ddf1d3692..f1f3d9c5224 100644 --- a/tests/components/device_tracker/test_asuswrt.py +++ b/tests/components/device_tracker/test_asuswrt.py @@ -32,8 +32,7 @@ VALID_CONFIG_ROUTER_SSH = {DOMAIN: { CONF_PROTOCOL: 'ssh', CONF_MODE: 'router', CONF_PORT: '22' -} -} +}} WL_DATA = [ 'assoclist 01:02:03:04:06:08\r', @@ -249,7 +248,7 @@ class TestComponentsDeviceTrackerASUSWRT(unittest.TestCase): self.assertEqual(ssh.login.call_count, 1) self.assertEqual( ssh.login.call_args, - mock.call('fake_host', 'fake_user', + mock.call('fake_host', 'fake_user', quiet=False, ssh_key=FAKEFILE, port=22) ) @@ -275,7 +274,7 @@ class TestComponentsDeviceTrackerASUSWRT(unittest.TestCase): self.assertEqual(ssh.login.call_count, 1) self.assertEqual( ssh.login.call_args, - mock.call('fake_host', 'fake_user', + mock.call('fake_host', 'fake_user', quiet=False, password='fake_pass', port=22) )