bug: fix some cases where a warning could still be passed when it was unexpected.
This commit is contained in:
@@ -83,15 +83,15 @@ class BaseMinerAPI:
|
|||||||
data = self._load_api_data(data)
|
data = self._load_api_data(data)
|
||||||
|
|
||||||
# check for if the user wants to allow errors to return
|
# check for if the user wants to allow errors to return
|
||||||
if not ignore_errors:
|
|
||||||
# validate the command succeeded
|
|
||||||
validation = self._validate_command_output(data)
|
validation = self._validate_command_output(data)
|
||||||
if not validation[0]:
|
if not validation[0]:
|
||||||
|
if not ignore_errors:
|
||||||
|
# validate the command succeeded
|
||||||
|
raise APIError(validation[1])
|
||||||
if allow_warning:
|
if allow_warning:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
f"{self.ip}: API Command Error: {command}: {validation[1]}"
|
f"{self.ip}: API Command Error: {command}: {validation[1]}"
|
||||||
)
|
)
|
||||||
raise APIError(validation[1])
|
|
||||||
|
|
||||||
logging.debug(f"{self} - (Send Command) - Received data.")
|
logging.debug(f"{self} - (Send Command) - Received data.")
|
||||||
return data
|
return data
|
||||||
@@ -118,6 +118,7 @@ class BaseMinerAPI:
|
|||||||
data = await self.send_command(command, allow_warning=allow_warning)
|
data = await self.send_command(command, allow_warning=allow_warning)
|
||||||
except APIError as e:
|
except APIError as e:
|
||||||
# try to identify the error
|
# try to identify the error
|
||||||
|
if e.message is not None:
|
||||||
if ":" in e.message:
|
if ":" in e.message:
|
||||||
err_command = e.message.split(":")[0]
|
err_command = e.message.split(":")[0]
|
||||||
if err_command in commands:
|
if err_command in commands:
|
||||||
|
|||||||
@@ -541,7 +541,7 @@ class BaseMiner(ABC):
|
|||||||
)
|
)
|
||||||
|
|
||||||
gathered_data = await self._get_data(
|
gathered_data = await self._get_data(
|
||||||
allow_warning, include=include, exclude=exclude
|
allow_warning=allow_warning, include=include, exclude=exclude
|
||||||
)
|
)
|
||||||
for item in gathered_data:
|
for item in gathered_data:
|
||||||
if gathered_data[item] is not None:
|
if gathered_data[item] is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user