From e15ddd020ca1b0f98bb1d7666064b21d3e56c9a8 Mon Sep 17 00:00:00 2001 From: Upstream Data Date: Wed, 5 Jun 2024 10:26:25 -0600 Subject: [PATCH] bug: fix missing import. --- pyasic/miners/backends/braiins_os.py | 29 +++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/pyasic/miners/backends/braiins_os.py b/pyasic/miners/backends/braiins_os.py index 6be97533..19006654 100644 --- a/pyasic/miners/backends/braiins_os.py +++ b/pyasic/miners/backends/braiins_os.py @@ -13,10 +13,13 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ +import base64 import logging import time +from pathlib import Path from typing import List, Optional, Union +import aiofiles import toml from pyasic.config import MinerConfig @@ -37,9 +40,6 @@ from pyasic.ssh.braiins_os import BOSMinerSSH from pyasic.web.braiins_os import BOSerWebAPI, BOSMinerWebAPI from pyasic.web.braiins_os.proto.braiins.bos.v1 import SaveAction -import aiofiles -import base64 - BOSMINER_DATA_LOC = DataLocations( **{ str(DataOptions.MAC): DataFunction( @@ -594,25 +594,36 @@ class BOSMiner(BraiinsOSFirmware): upgrade_contents = await f.read() # Encode the firmware contents in base64 - encoded_contents = base64.b64encode(upgrade_contents).decode('utf-8') + encoded_contents = base64.b64encode(upgrade_contents).decode("utf-8") # Upload the firmware file to the BOSMiner device self.logger.info(f"Uploading firmware file from {file} to the device.") - await self.ssh.send_command(f"echo {encoded_contents} | base64 -d > /tmp/firmware.tar && sysupgrade /tmp/firmware.tar") + await self.ssh.send_command( + f"echo {encoded_contents} | base64 -d > /tmp/firmware.tar && sysupgrade /tmp/firmware.tar" + ) self.logger.info("Firmware upgrade process completed successfully.") return "Firmware upgrade completed successfully." except FileNotFoundError as e: - self.logger.error(f"File not found during the firmware upgrade process: {e}") + self.logger.error( + f"File not found during the firmware upgrade process: {e}" + ) raise except ValueError as e: - self.logger.error(f"Validation error occurred during the firmware upgrade process: {e}") + self.logger.error( + f"Validation error occurred during the firmware upgrade process: {e}" + ) raise except OSError as e: - self.logger.error(f"OS error occurred during the firmware upgrade process: {e}") + self.logger.error( + f"OS error occurred during the firmware upgrade process: {e}" + ) raise except Exception as e: - self.logger.error(f"An unexpected error occurred during the firmware upgrade process: {e}", exc_info=True) + self.logger.error( + f"An unexpected error occurred during the firmware upgrade process: {e}", + exc_info=True, + ) raise