From 697991f28fe7487562c9f00672fdd68e1cf91e54 Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Mon, 30 Oct 2023 16:33:01 -0600 Subject: [PATCH] bug: fix some cases where a warning could still be passed when it was unexpected. --- pyasic/API/__init__.py | 27 ++++++++++++++------------- pyasic/miners/base.py | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/pyasic/API/__init__.py b/pyasic/API/__init__.py index 97d8049a..c748784e 100644 --- a/pyasic/API/__init__.py +++ b/pyasic/API/__init__.py @@ -83,15 +83,15 @@ class BaseMinerAPI: data = self._load_api_data(data) # 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) - if not validation[0]: - if allow_warning: - logging.warning( - f"{self.ip}: API Command Error: {command}: {validation[1]}" - ) + validation = self._validate_command_output(data) + if not validation[0]: + if not ignore_errors: + # validate the command succeeded raise APIError(validation[1]) + if allow_warning: + logging.warning( + f"{self.ip}: API Command Error: {command}: {validation[1]}" + ) logging.debug(f"{self} - (Send Command) - Received data.") return data @@ -118,11 +118,12 @@ class BaseMinerAPI: data = await self.send_command(command, allow_warning=allow_warning) except APIError as e: # try to identify the error - if ":" in e.message: - err_command = e.message.split(":")[0] - if err_command in commands: - commands.remove(err_command) - continue + if e.message is not None: + if ":" in e.message: + err_command = e.message.split(":")[0] + if err_command in commands: + commands.remove(err_command) + continue return {command: [{}] for command in commands} logging.debug(f"{self} - (Multicommand) - Received data") data["multicommand"] = True diff --git a/pyasic/miners/base.py b/pyasic/miners/base.py index 359b9317..24e5f490 100644 --- a/pyasic/miners/base.py +++ b/pyasic/miners/base.py @@ -541,7 +541,7 @@ class BaseMiner(ABC): ) 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: if gathered_data[item] is not None: