added config loader

This commit is contained in:
UpstreamData
2021-10-08 15:17:47 -06:00
parent fea2e12118
commit 0811e630c8
2 changed files with 13 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
from miners import BaseMiner
from API.bosminer import BOSMinerAPI
import asyncssh
import toml
class BOSminer(BaseMiner):
@@ -18,7 +19,7 @@ class BOSminer(BaseMiner):
# return created connection
return conn
def send_ssh_command(self, cmd):
async def send_ssh_command(self, cmd):
result = None
conn = await self.get_ssh_connection('root', 'admin')
for i in range(3):
@@ -51,3 +52,11 @@ class BOSminer(BaseMiner):
async def reboot(self):
await self.send_ssh_command('/sbin/reboot')
async def get_config(self):
async with asyncssh.connect(str(self.ip), known_hosts=None, username='root', password='admin',
server_host_key_algs=['ssh-rsa']) as conn:
async with conn.start_sftp_client() as sftp:
async with sftp.open('/etc/bosminer.toml') as file:
toml_data = toml.loads(await file.read())
return toml_data