improved format and readability
This commit is contained in:
@@ -18,18 +18,25 @@ class APIError(Exception):
|
||||
|
||||
|
||||
class BaseMinerAPI:
|
||||
def __init__(self, ip: str, port: int):
|
||||
def __init__(self, ip: str, port: int) -> None:
|
||||
self.port = port
|
||||
self.ip = ipaddress.ip_address(ip)
|
||||
|
||||
def get_commands(self):
|
||||
return [func for func in dir(self) if callable(getattr(self, func)) and not func.startswith("__") and func not in [func for func in dir(BaseMinerAPI) if callable(getattr(BaseMinerAPI, func))]]
|
||||
def get_commands(self) -> list:
|
||||
return [func for func in
|
||||
dir(self) if callable(getattr(self, func)) and
|
||||
not func.startswith("__") and
|
||||
func not in
|
||||
[func for func in
|
||||
dir(BaseMinerAPI) if callable(getattr(BaseMinerAPI, func))
|
||||
]
|
||||
]
|
||||
|
||||
async def multicommand(self, *commands: str) -> dict:
|
||||
command = "+".join(commands)
|
||||
return await self.send_command(command)
|
||||
|
||||
async def send_command(self, command: str, parameters: str = None) -> dict:
|
||||
async def send_command(self, command: str, parameters: str or int or bool = None) -> dict:
|
||||
try:
|
||||
# get reader and writer streams
|
||||
reader, writer = await asyncio.open_connection(str(self.ip), self.port)
|
||||
|
||||
Reference in New Issue
Block a user