fixed some bugs in getting ssh connections

This commit is contained in:
UpstreamData
2022-02-24 14:42:34 -07:00
parent 1ec2a2a4a6
commit 5a7dcc7fcf
4 changed files with 17 additions and 6 deletions

View File

@@ -52,10 +52,15 @@ class BMMiner(BaseMiner):
server_host_key_algs=['ssh-rsa'])
return conn
except Exception as e:
print(e)
print("Exception raised:", self.ip)
raise e
except OSError:
print(str(self.ip) + ": Connection refused.")
return None
except Exception as e:
print("Exception raised:", self.ip)
raise e
async def send_ssh_command(self, cmd):
result = None

View File

@@ -20,8 +20,12 @@ class BOSMiner(BaseMiner):
async def _get_ssh_connection(self) -> asyncssh.connect:
"""Create a new asyncssh connection"""
conn = await asyncssh.connect(str(self.ip), known_hosts=None, username=self.uname, password=self.pwd,
server_host_key_algs=['ssh-rsa'])
try:
conn = await asyncssh.connect(str(self.ip), known_hosts=None, username=self.uname, password=self.pwd,
server_host_key_algs=['ssh-rsa'])
except Exception as e:
print("Exception raised:", self.ip)
raise e
# return created connection
return conn

View File

@@ -30,7 +30,6 @@ class BTMiner(BaseMiner):
except APIError:
return "?"
async def get_board_info(self) -> dict:
"""Gets data on each board and chain in the miner."""
devs = await self.api.devs()
@@ -56,4 +55,3 @@ class BTMiner(BaseMiner):
else:
print(board)
return boards

View File

@@ -56,10 +56,14 @@ class CGMiner(BaseMiner):
server_host_key_algs=['ssh-rsa'])
return conn
except Exception as e:
print(e)
print("Exception raised:", self.ip)
raise e
except OSError:
print(str(self.ip) + " Connection refused.")
return None
except Exception as e:
print("Exception raised:", self.ip)
raise e
async def send_ssh_command(self, cmd):
result = None