Refactor upgrade_firmware to maintain bool return type

This commit is contained in:
1e9abhi1e10
2024-09-03 09:42:08 +05:30
parent 0965e6489b
commit 7a9ff535b4

View File

@@ -147,25 +147,21 @@ class LUXMiner(LuxOSFirmware):
async def get_config(self) -> MinerConfig: async def get_config(self) -> MinerConfig:
return self.config return self.config
async def upgrade_firmware(self) -> tuple[bool, str]: async def upgrade_firmware(self) -> bool:
""" """
Upgrade the firmware on a LuxOS miner by calling the 'updaterun' API command. Upgrade the firmware on a LuxOS miner by calling the 'updaterun' API command.
Returns: Returns:
tuple[bool, str]: A tuple containing:
bool: True if the firmware upgrade was successfully initiated, False otherwise. bool: True if the firmware upgrade was successfully initiated, False otherwise.
str: A status message describing the result of the operation.
""" """
try: try:
await self.rpc.upgraderun() await self.rpc.upgraderun()
status = f"{self.ip}: Firmware upgrade initiated successfully." logging.info(f"{self.ip}: Firmware upgrade initiated successfully.")
logging.info(status) return True
return True, status
except APIError as e: except APIError as e:
status = f"{self.ip}: Firmware upgrade failed: {e}" logging.error(f"{self.ip}: Firmware upgrade failed: {e}")
logging.error(status)
return False, status return False
################################################## ##################################################
### DATA GATHERING FUNCTIONS (get_{some_data}) ### ### DATA GATHERING FUNCTIONS (get_{some_data}) ###