mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
AsusWRT log exceptions (#12668)
* logexception * Improve err message #2978 * not quiet * tests
This commit is contained in:
parent
6a665ffb84
commit
446390a8d1
@ -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()
|
||||
|
@ -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)
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user