Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb439f4dcf | ||
|
|
69f4349393 | ||
|
|
e371bb577c | ||
|
|
2500ec3869 | ||
|
|
5be3187eec | ||
|
|
be1e9127b0 |
@@ -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:
|
||||||
@@ -461,8 +507,8 @@ class BaseMiner(ABC):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
if len(pools_data) > 1:
|
if len(pools_data) > 1:
|
||||||
miner_data["pool_2_url"] = pools_data[1]["pool_2_url"]
|
miner_data["pool_2_url"] = pools_data[1]["pool_1_url"]
|
||||||
miner_data["pool_2_user"] = pools_data[1]["pool_2_user"]
|
miner_data["pool_2_user"] = pools_data[1]["pool_1_user"]
|
||||||
miner_data[
|
miner_data[
|
||||||
"pool_split"
|
"pool_split"
|
||||||
] = f"{pools_data[0]['quota']}/{pools_data[1]['quota']}"
|
] = f"{pools_data[0]['quota']}/{pools_data[1]['quota']}"
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class BOSMinerWebAPI(BaseWebAPI):
|
|||||||
|
|
||||||
async def multicommand(
|
async def multicommand(
|
||||||
self, *commands: Union[dict, str], allow_warning: bool = True
|
self, *commands: Union[dict, str], allow_warning: bool = True
|
||||||
):
|
) -> dict:
|
||||||
luci_commands = []
|
luci_commands = []
|
||||||
gql_commands = []
|
gql_commands = []
|
||||||
for cmd in commands:
|
for cmd in commands:
|
||||||
@@ -88,6 +88,11 @@ class BOSMinerWebAPI(BaseWebAPI):
|
|||||||
luci_data = await self.luci_multicommand(*luci_commands)
|
luci_data = await self.luci_multicommand(*luci_commands)
|
||||||
gql_data = await self.gql_multicommand(*gql_commands)
|
gql_data = await self.gql_multicommand(*gql_commands)
|
||||||
|
|
||||||
|
if gql_data is None:
|
||||||
|
gql_data = {}
|
||||||
|
if luci_data is None:
|
||||||
|
luci_data = {}
|
||||||
|
|
||||||
data = dict(**luci_data, **gql_data)
|
data = dict(**luci_data, **gql_data)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "pyasic"
|
name = "pyasic"
|
||||||
version = "0.36.5"
|
version = "0.36.8"
|
||||||
description = "A set of modules for interfacing with many common types of ASIC bitcoin miners, using both their API and SSH."
|
description = "A set of modules for interfacing with many common types of ASIC bitcoin miners, using both their API and SSH."
|
||||||
authors = ["UpstreamData <brett@upstreamdata.ca>"]
|
authors = ["UpstreamData <brett@upstreamdata.ca>"]
|
||||||
repository = "https://github.com/UpstreamData/pyasic"
|
repository = "https://github.com/UpstreamData/pyasic"
|
||||||
|
|||||||
Reference in New Issue
Block a user