fully implemented fault light command

This commit is contained in:
UpstreamData
2022-05-06 11:36:57 -06:00
parent 725b14e583
commit a2b071af4f
6 changed files with 102 additions and 45 deletions

View File

@@ -55,6 +55,12 @@ class BaseMiner:
# logging.warning(f"{self} raised an exception: {e}")
raise e
async def fault_light_on(self) -> bool:
return False
async def fault_light_off(self) -> bool:
return False
async def send_file(self, src, dest):
async with (await self._get_ssh_connection()) as conn:
await asyncssh.scp(src, (conn, dest))

View File

@@ -42,21 +42,27 @@ class BOSMiner(BaseMiner):
return
continue
# return the result, either command output or None
return result
return str(result)
async def fault_light_on(self) -> None:
async def fault_light_on(self) -> bool:
"""Sends command to turn on fault light on the miner."""
logging.debug(f"{self}: Sending fault_light on command.")
self.light = True
await self.send_ssh_command("miner fault_light on")
_ret = await self.send_ssh_command("miner fault_light on")
logging.debug(f"{self}: fault_light on command completed.")
if isinstance(_ret, str):
return True
return False
async def fault_light_off(self) -> None:
async def fault_light_off(self) -> bool:
"""Sends command to turn off fault light on the miner."""
logging.debug(f"{self}: Sending fault_light off command.")
self.light = False
await self.send_ssh_command("miner fault_light off")
_ret = await self.send_ssh_command("miner fault_light off")
logging.debug(f"{self}: fault_light off command completed.")
if isinstance(_ret, str):
return True
return False
async def restart_backend(self) -> None:
await self.restart_bosminer()

View File

@@ -77,8 +77,10 @@ class MinerFactory(metaclass=Singleton):
for miner in scanned:
yield await miner
async def get_miner(self, ip: ipaddress.ip_address):
async def get_miner(self, ip: ipaddress.ip_address or str):
"""Decide a miner type using the IP address of the miner."""
if isinstance(ip, str):
ip = ipaddress.ip_address(ip)
# check if the miner already exists in cache
if ip in self.miners:
return self.miners[ip]