comm_mgmt: expect error on config_read

This commit is contained in:
mwojcik 2022-05-19 15:54:05 +08:00 committed by Sébastien Bourdeauducq
parent d24a36a02a
commit cf8e583847

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):