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']) server_host_key_algs=['ssh-rsa'])
return conn return conn
except Exception as e: except Exception as e:
print(e) print("Exception raised:", self.ip)
raise e
except OSError: except OSError:
print(str(self.ip) + ": Connection refused.") print(str(self.ip) + ": Connection refused.")
return None return None
except Exception as e:
print("Exception raised:", self.ip)
raise e
async def send_ssh_command(self, cmd): async def send_ssh_command(self, cmd):
result = None result = None

View File

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

View File

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

View File

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