bug: fix missing import.
This commit is contained in:
@@ -13,10 +13,13 @@
|
|||||||
# See the License for the specific language governing permissions and -
|
# See the License for the specific language governing permissions and -
|
||||||
# limitations under the License. -
|
# limitations under the License. -
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
import base64
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
from pathlib import Path
|
||||||
from typing import List, Optional, Union
|
from typing import List, Optional, Union
|
||||||
|
|
||||||
|
import aiofiles
|
||||||
import toml
|
import toml
|
||||||
|
|
||||||
from pyasic.config import MinerConfig
|
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 import BOSerWebAPI, BOSMinerWebAPI
|
||||||
from pyasic.web.braiins_os.proto.braiins.bos.v1 import SaveAction
|
from pyasic.web.braiins_os.proto.braiins.bos.v1 import SaveAction
|
||||||
|
|
||||||
import aiofiles
|
|
||||||
import base64
|
|
||||||
|
|
||||||
BOSMINER_DATA_LOC = DataLocations(
|
BOSMINER_DATA_LOC = DataLocations(
|
||||||
**{
|
**{
|
||||||
str(DataOptions.MAC): DataFunction(
|
str(DataOptions.MAC): DataFunction(
|
||||||
@@ -594,25 +594,36 @@ class BOSMiner(BraiinsOSFirmware):
|
|||||||
upgrade_contents = await f.read()
|
upgrade_contents = await f.read()
|
||||||
|
|
||||||
# Encode the firmware contents in base64
|
# 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
|
# Upload the firmware file to the BOSMiner device
|
||||||
self.logger.info(f"Uploading firmware file from {file} to the 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.")
|
self.logger.info("Firmware upgrade process completed successfully.")
|
||||||
return "Firmware upgrade completed successfully."
|
return "Firmware upgrade completed successfully."
|
||||||
except FileNotFoundError as e:
|
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
|
raise
|
||||||
except ValueError as e:
|
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
|
raise
|
||||||
except OSError as e:
|
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
|
raise
|
||||||
except Exception as e:
|
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
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user