added config loader
This commit is contained in:
3
main.py
3
main.py
@@ -1,4 +1,5 @@
|
||||
from network import MinerNetwork
|
||||
from miners.bosminer import BOSminer
|
||||
import asyncio
|
||||
|
||||
|
||||
@@ -6,6 +7,8 @@ async def main():
|
||||
miner_network = MinerNetwork('192.168.1.1')
|
||||
data = await miner_network.scan_network_for_miners()
|
||||
print(data)
|
||||
config = await asyncio.gather(*[miner.get_config() for miner in data if isinstance(miner, BOSminer)])
|
||||
print(config)
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.get_event_loop().run_until_complete(main())
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user