fixed a bug with old bosminers not updating properly
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import asyncssh
|
import ipaddress
|
||||||
|
|
||||||
from API.bosminer import BOSMinerAPI
|
from API.bosminer import BOSMinerAPI
|
||||||
from miners import BaseMiner
|
from miners import BaseMiner
|
||||||
@@ -9,6 +9,7 @@ from miners import BaseMiner
|
|||||||
class BOSMinerOld(BaseMiner):
|
class BOSMinerOld(BaseMiner):
|
||||||
def __init__(self, ip: str) -> None:
|
def __init__(self, ip: str) -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
|
self.ip = ipaddress.ip_address(ip)
|
||||||
self.api = BOSMinerAPI(ip)
|
self.api = BOSMinerAPI(ip)
|
||||||
self.api_type = "BOSMiner"
|
self.api_type = "BOSMiner"
|
||||||
self.uname = "root"
|
self.uname = "root"
|
||||||
@@ -22,14 +23,17 @@ class BOSMinerOld(BaseMiner):
|
|||||||
result = None
|
result = None
|
||||||
|
|
||||||
# open an ssh connection
|
# open an ssh connection
|
||||||
async with await asyncssh.connect("192.168.1.11", username="root") as conn:
|
async with (await self._get_ssh_connection()) as conn:
|
||||||
# 3 retries
|
# 3 retries
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
try:
|
try:
|
||||||
# run the command and get the result
|
# run the command and get the result
|
||||||
result = await conn.run(cmd)
|
result = await conn.run(cmd)
|
||||||
|
if result.stdout:
|
||||||
result = result.stdout
|
result = result.stdout
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
if e == "SSH connection closed":
|
||||||
|
return "Update completed."
|
||||||
# if the command fails, log it
|
# if the command fails, log it
|
||||||
logging.warning(f"{self} command {cmd} error: {e}")
|
logging.warning(f"{self} command {cmd} error: {e}")
|
||||||
|
|
||||||
@@ -40,6 +44,7 @@ class BOSMinerOld(BaseMiner):
|
|||||||
# return the result, either command output or None
|
# return the result, either command output or None
|
||||||
return str(result)
|
return str(result)
|
||||||
|
|
||||||
|
|
||||||
async def update_to_plus(self):
|
async def update_to_plus(self):
|
||||||
result = await self.send_ssh_command("opkg update && opkg install bos_plus")
|
result = await self.send_ssh_command("opkg update && opkg install bos_plus")
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user