Add keep_setting arg in miners/base.py/BaseMiner/upgrade_firmware

This commit is contained in:
1e9abhi1e10
2024-06-27 02:21:24 +05:30
parent 45e2c9a403
commit ba58e80ec3

View File

@@ -561,27 +561,18 @@ class BaseMiner(MinerProtocol):
if self._ssh_cls is not None: if self._ssh_cls is not None:
self.ssh = self._ssh_cls(ip) self.ssh = self._ssh_cls(ip)
async def upgrade_firmware(self, file: str = None, url: str = None, version: str = "latest") -> bool: async def upgrade_firmware(self, *, file: str = None, url: str = None, version: str = "latest", keep_settings: bool = True) -> bool:
"""Upgrade the firmware of the miner. """Upgrade the firmware of the miner.
Parameters: Parameters:
file: The file path to the firmware to upgrade from. file: The file path to the firmware to upgrade from.
url: The URL to download the firmware from. url: The URL to download the firmware from.
version: The version of the firmware to upgrade to. version: The version of the firmware to upgrade to.
keep_settings: Whether to keep the current settings during the upgrade.
Returns: Returns:
A boolean value of the success of the firmware upgrade. A boolean value of the success of the firmware upgrade.
""" """
try: return False
if file is not None:
await self.web.send_command("firmware-upgrade", file=file)
elif url is not None:
await self.web.send_command("firmware-upgrade", url=url)
else:
await self.web.send_command("firmware-upgrade", version=version)
return True
except Exception as e:
logging.error(f"Firmware upgrade failed: {e}")
return False
AnyMiner = TypeVar("AnyMiner", bound=BaseMiner) AnyMiner = TypeVar("AnyMiner", bound=BaseMiner)