From 6fdd156fa3ee4714168eab6c3c565f7dc86f9b61 Mon Sep 17 00:00:00 2001 From: 1e9abhi1e10 <2311abhiptdr@gmail.com> Date: Wed, 21 Aug 2024 01:06:50 +0530 Subject: [PATCH] Added upgraderun in rpc/luxminer --- pyasic/miners/backends/luxminer.py | 20 +++++--------------- pyasic/rpc/luxminer.py | 9 +++++++++ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/pyasic/miners/backends/luxminer.py b/pyasic/miners/backends/luxminer.py index 73b7a508..1afdfea3 100644 --- a/pyasic/miners/backends/luxminer.py +++ b/pyasic/miners/backends/luxminer.py @@ -152,25 +152,15 @@ class LUXMiner(LuxOSFirmware): Upgrade the firmware on a LuxOS miner by calling the 'updaterun' API command. Returns: Result of the upgrade process. - """ - command = "updaterun" - try: - response = await self.rpc.send_command(command=command) + response = await self.rpc.upgraderun() - if not response: - raise ValueError("No response received during the firmware upgrade process.") + logging.info(f"{self.ip}: Firmware upgrade initiated successfully.") + return response - if response.get("status") == "success": - logging.info(f"{self.ip}: Firmware upgrade initiated successfully.") - return "Firmware upgrade completed successfully." - else: - logging.error(f"{self.ip}: Firmware upgrade failed. Response: {response}") - raise ValueError(f"Firmware upgrade failed. Response: {response}") - - except Exception as e: - logging.error(f"An error occurred during the firmware upgrade process: {e}", exc_info=True) + except APIError as e: + logging.error(f"{self.ip}: Firmware upgrade failed: {e}") raise ################################################## diff --git a/pyasic/rpc/luxminer.py b/pyasic/rpc/luxminer.py index cb58cab3..37bfb0be 100644 --- a/pyasic/rpc/luxminer.py +++ b/pyasic/rpc/luxminer.py @@ -749,3 +749,12 @@ class LUXMinerRPCAPI(BaseMinerRPCAPI): """ return await self.send_command("wakeup", parameters=session_id) + + async def upgraderun(self): + """ + Send the 'updaterun' command to the miner. + + Returns: + The response from the miner after sending the 'updaterun' command. + """ + return await self.send_command("updaterun") \ No newline at end of file