feature: create pwd and username property in miner object that sets web and api passwords and usernames.
This commit is contained in:
@@ -32,6 +32,8 @@ class BaseMinerAPI:
|
|||||||
# ip address of the miner
|
# ip address of the miner
|
||||||
self.ip = ipaddress.ip_address(ip)
|
self.ip = ipaddress.ip_address(ip)
|
||||||
|
|
||||||
|
self.pwd = "admin"
|
||||||
|
|
||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
if cls is BaseMinerAPI:
|
if cls is BaseMinerAPI:
|
||||||
raise TypeError(f"Only children of '{cls.__name__}' may be instantiated")
|
raise TypeError(f"Only children of '{cls.__name__}' may be instantiated")
|
||||||
|
|||||||
@@ -72,6 +72,52 @@ class BaseMiner(ABC):
|
|||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return ipaddress.ip_address(self.ip) == ipaddress.ip_address(other.ip)
|
return ipaddress.ip_address(self.ip) == ipaddress.ip_address(other.ip)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pwd(self): # noqa - Skip PyCharm inspection
|
||||||
|
data = []
|
||||||
|
try:
|
||||||
|
if self.web is not None:
|
||||||
|
data.append(f"web={self.web.pwd}")
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
if self.api is not None:
|
||||||
|
data.append(f"api={self.api.pwd}")
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
return ",".join(data)
|
||||||
|
|
||||||
|
@pwd.setter
|
||||||
|
def pwd(self, val):
|
||||||
|
try:
|
||||||
|
if self.web is not None:
|
||||||
|
self.web.pwd = val
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
if self.api is not None:
|
||||||
|
self.api.pwd = val
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
|
def username(self): # noqa - Skip PyCharm inspection
|
||||||
|
data = []
|
||||||
|
try:
|
||||||
|
if self.web is not None:
|
||||||
|
data.append(f"web={self.web.username}")
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
return ",".join(data)
|
||||||
|
|
||||||
|
@username.setter
|
||||||
|
def username(self, val):
|
||||||
|
try:
|
||||||
|
if self.web is not None:
|
||||||
|
self.web.username = val
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
|
||||||
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:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user