comm_mgmt: expect error on config_read

pull/1898/head
mwojcik 2022-05-19 15:54:05 +08:00 committed by Sébastien Bourdeauducq
parent d24a36a02a
commit cf8e583847
1 changed files with 6 additions and 1 deletions

View File

@ -160,7 +160,12 @@ class CommMgmt:
def config_read(self, key):
self._write_header(Request.ConfigRead)
self._write_string(key)
self._read_expect(Reply.ConfigData)
ty = self._read_header()
if ty == Reply.Error:
raise IOError("Device failed to read config. The key may not exist.")
elif ty != Reply.ConfigData:
raise IOError("Incorrect reply from device: {} (expected {})".
format(ty, Reply.ConfigData))
return self._read_string()
def config_write(self, key, value):