format: update a bunch of formatting and remove a lot of useless imports.
This commit is contained in:
@@ -17,17 +17,16 @@
|
||||
import ipaddress
|
||||
import logging
|
||||
from collections import namedtuple
|
||||
from typing import List, Optional, Tuple, Union
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
import asyncssh
|
||||
|
||||
from pyasic.API.bmminer import BMMinerAPI
|
||||
from pyasic.config import MinerConfig
|
||||
from pyasic.data import Fan, HashBoard, MinerData
|
||||
from pyasic.data import Fan, HashBoard
|
||||
from pyasic.data.error_codes import MinerErrorData
|
||||
from pyasic.errors import APIError
|
||||
from pyasic.miners.base import BaseMiner
|
||||
from pyasic.settings import PyasicSettings
|
||||
|
||||
|
||||
class BMMiner(BaseMiner):
|
||||
|
||||
@@ -26,11 +26,10 @@ import toml
|
||||
|
||||
from pyasic.API.bosminer import BOSMinerAPI
|
||||
from pyasic.config import MinerConfig
|
||||
from pyasic.data import Fan, HashBoard, MinerData
|
||||
from pyasic.data import Fan, HashBoard
|
||||
from pyasic.data.error_codes import BraiinsOSError, MinerErrorData
|
||||
from pyasic.errors import APIError
|
||||
from pyasic.miners.base import BaseMiner
|
||||
from pyasic.settings import PyasicSettings
|
||||
|
||||
|
||||
class BOSMiner(BaseMiner):
|
||||
@@ -839,7 +838,6 @@ class BOSMiner(BaseMiner):
|
||||
api_devs = await self.api.devs()
|
||||
except APIError:
|
||||
pass
|
||||
nom_hr = 0
|
||||
|
||||
if api_devs:
|
||||
try:
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
import ipaddress
|
||||
import logging
|
||||
from collections import namedtuple
|
||||
from typing import List, Optional, Tuple, Union
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
import asyncssh
|
||||
|
||||
@@ -180,5 +179,5 @@ class BOSMinerOld(BaseMiner):
|
||||
async def get_nominal_hashrate(self) -> Optional[float]:
|
||||
return None
|
||||
|
||||
async def get_data(self, allow_warning: bool = False) -> MinerData:
|
||||
async def get_data(self, allow_warning: bool = False, **kwargs) -> MinerData:
|
||||
return MinerData(ip=str(self.ip))
|
||||
|
||||
@@ -18,15 +18,14 @@ import ipaddress
|
||||
import logging
|
||||
import warnings
|
||||
from collections import namedtuple
|
||||
from typing import List, Optional, Tuple, Union
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from pyasic.API.btminer import BTMinerAPI
|
||||
from pyasic.config import MinerConfig
|
||||
from pyasic.data import Fan, HashBoard, MinerData
|
||||
from pyasic.data import Fan, HashBoard
|
||||
from pyasic.data.error_codes import MinerErrorData, WhatsminerError
|
||||
from pyasic.errors import APIError
|
||||
from pyasic.miners.base import BaseMiner
|
||||
from pyasic.settings import PyasicSettings
|
||||
|
||||
|
||||
class BTMiner(BaseMiner):
|
||||
@@ -122,17 +121,7 @@ class BTMiner(BaseMiner):
|
||||
pools_conf = conf["pools"]
|
||||
|
||||
try:
|
||||
await self.api.update_pools(
|
||||
pools_conf[0]["url"],
|
||||
pools_conf[0]["user"],
|
||||
pools_conf[0]["pass"],
|
||||
pools_conf[1]["url"],
|
||||
pools_conf[1]["user"],
|
||||
pools_conf[1]["pass"],
|
||||
pools_conf[2]["url"],
|
||||
pools_conf[2]["user"],
|
||||
pools_conf[2]["pass"],
|
||||
)
|
||||
await self.api.update_pools(**pools_conf)
|
||||
except APIError:
|
||||
pass
|
||||
try:
|
||||
@@ -546,8 +535,6 @@ class BTMiner(BaseMiner):
|
||||
pass
|
||||
|
||||
async def get_fault_light(self, api_get_miner_info: dict = None) -> bool:
|
||||
data = None
|
||||
|
||||
if not api_get_miner_info:
|
||||
try:
|
||||
api_get_miner_info = await self.api.get_miner_info()
|
||||
|
||||
@@ -17,17 +17,16 @@
|
||||
import ipaddress
|
||||
import logging
|
||||
from collections import namedtuple
|
||||
from typing import List, Optional, Tuple, Union
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
import asyncssh
|
||||
|
||||
from pyasic.API.cgminer import CGMinerAPI
|
||||
from pyasic.config import MinerConfig
|
||||
from pyasic.data import Fan, HashBoard, MinerData
|
||||
from pyasic.data import Fan, HashBoard
|
||||
from pyasic.data.error_codes import MinerErrorData
|
||||
from pyasic.errors import APIError
|
||||
from pyasic.miners.base import BaseMiner
|
||||
from pyasic.settings import PyasicSettings
|
||||
|
||||
|
||||
class CGMiner(BaseMiner):
|
||||
|
||||
@@ -14,20 +14,15 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
import ipaddress
|
||||
import logging
|
||||
import re
|
||||
from collections import namedtuple
|
||||
from typing import List, Optional, Tuple, Union
|
||||
from typing import List, Optional
|
||||
|
||||
from pyasic.API.cgminer import CGMinerAPI
|
||||
from pyasic.config import MinerConfig
|
||||
from pyasic.data import Fan, HashBoard, MinerData
|
||||
from pyasic.data import Fan, HashBoard
|
||||
from pyasic.data.error_codes import MinerErrorData
|
||||
from pyasic.errors import APIError
|
||||
from pyasic.miners._backends import CGMiner
|
||||
from pyasic.miners.base import BaseMiner
|
||||
from pyasic.settings import PyasicSettings
|
||||
|
||||
|
||||
class CGMinerAvalon(CGMiner):
|
||||
@@ -79,7 +74,7 @@ class CGMinerAvalon(CGMiner):
|
||||
logging.debug(f"{self}: Sending config.") # noqa - This doesnt work...
|
||||
conf = config.as_avalon(user_suffix=user_suffix)
|
||||
try:
|
||||
data = await self.api.ascset(
|
||||
data = await self.api.ascset( # noqa
|
||||
0, "setpool", f"root,root,{conf}"
|
||||
) # this should work but doesn't
|
||||
except APIError:
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from pyasic.miners._backends import X19
|
||||
from pyasic.miners._backends import X19 # noqa - Ignore access to _module
|
||||
from pyasic.miners._types import S19 # noqa - Ignore access to _module
|
||||
|
||||
# noqa - Ignore access to _module
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from pyasic.miners._backends import X19
|
||||
from pyasic.miners._backends import X19 # noqa - Ignore access to _module
|
||||
from pyasic.miners._types import S19Pro # noqa - Ignore access to _module
|
||||
|
||||
# noqa - Ignore access to _module
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from pyasic.miners._backends import X19
|
||||
from pyasic.miners._backends import X19 # noqa - Ignore access to _module
|
||||
from pyasic.miners._types import S19XP # noqa - Ignore access to _module
|
||||
|
||||
# noqa - Ignore access to _module
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from pyasic.miners._backends import X19
|
||||
from pyasic.miners._backends import X19 # noqa - Ignore access to _module
|
||||
from pyasic.miners._types import S19a # noqa - Ignore access to _module
|
||||
|
||||
# noqa - Ignore access to _module
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from pyasic.miners._backends import X19
|
||||
from pyasic.miners._backends import X19 # noqa - Ignore access to _module
|
||||
from pyasic.miners._types import S19aPro # noqa - Ignore access to _module
|
||||
|
||||
# noqa - Ignore access to _module
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from pyasic.miners._backends import X19
|
||||
from pyasic.miners._backends import X19 # noqa - Ignore access to _module
|
||||
from pyasic.miners._types import S19j # noqa - Ignore access to _module
|
||||
|
||||
# noqa - Ignore access to _module
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from pyasic.miners._backends import X19
|
||||
from pyasic.miners._backends import X19 # noqa - Ignore access to _module
|
||||
from pyasic.miners._types import S19jPro # noqa - Ignore access to _module
|
||||
|
||||
# noqa - Ignore access to _module
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from pyasic.miners._backends import X19
|
||||
from pyasic.miners._backends import X19 # noqa - Ignore access to _module
|
||||
from pyasic.miners._types import T19 # noqa - Ignore access to _module
|
||||
|
||||
# noqa - Ignore access to _module
|
||||
|
||||
@@ -14,10 +14,7 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
import json
|
||||
from typing import Optional, Union
|
||||
|
||||
import httpx
|
||||
from typing import Union
|
||||
|
||||
from pyasic.miners._backends import BMMiner # noqa - Ignore access to _module
|
||||
from pyasic.miners._types import S9 # noqa - Ignore access to _module
|
||||
|
||||
@@ -18,11 +18,10 @@ from typing import List, Optional
|
||||
|
||||
import asyncssh
|
||||
|
||||
from pyasic.data import HashBoard, MinerData
|
||||
from pyasic.data import HashBoard
|
||||
from pyasic.errors import APIError
|
||||
from pyasic.miners._backends import Hiveon # noqa - Ignore access to _module
|
||||
from pyasic.miners._types import T9 # noqa - Ignore access to _module
|
||||
from pyasic.settings import PyasicSettings
|
||||
|
||||
|
||||
class HiveonT9(Hiveon, T9):
|
||||
|
||||
@@ -33,6 +33,8 @@ class BaseMiner(ABC):
|
||||
self.ip = None
|
||||
self.api = None
|
||||
self.web = None
|
||||
self.uname = None
|
||||
self.pwd = None
|
||||
self.api_type = None
|
||||
self.api_ver = None
|
||||
self.fw_ver = None
|
||||
|
||||
@@ -13,13 +13,8 @@
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
import json
|
||||
import logging
|
||||
import warnings
|
||||
from collections import namedtuple
|
||||
from typing import List, Optional, Tuple, Union
|
||||
|
||||
import httpx
|
||||
from typing import List, Optional
|
||||
|
||||
from pyasic.config import MinerConfig
|
||||
from pyasic.data import Fan, HashBoard
|
||||
@@ -27,7 +22,6 @@ from pyasic.data.error_codes import InnosiliconError, MinerErrorData
|
||||
from pyasic.errors import APIError
|
||||
from pyasic.miners._backends import CGMiner # noqa - Ignore access to _module
|
||||
from pyasic.miners._types import InnosiliconT3HPlus # noqa - Ignore access to _module
|
||||
from pyasic.settings import PyasicSettings
|
||||
from pyasic.web.Inno import InnosiliconWebAPI
|
||||
|
||||
|
||||
@@ -84,9 +78,7 @@ class CGMinerInnosiliconT3HPlus(CGMiner, InnosiliconT3HPlus):
|
||||
##################################################
|
||||
|
||||
async def get_mac(
|
||||
self,
|
||||
web_get_all: dict = None, # noqa
|
||||
web_overview: dict = None, # noqa: named this way for automatic functionality
|
||||
self, web_get_all: dict = None, web_overview: dict = None
|
||||
) -> Optional[str]:
|
||||
if not web_get_all and not web_overview:
|
||||
try:
|
||||
@@ -127,9 +119,7 @@ class CGMinerInnosiliconT3HPlus(CGMiner, InnosiliconT3HPlus):
|
||||
pass
|
||||
|
||||
async def get_hashrate(
|
||||
self,
|
||||
api_summary: dict = None,
|
||||
web_get_all: dict = None, # noqa: named this way for automatic functionality
|
||||
self, api_summary: dict = None, web_get_all: dict = None
|
||||
) -> Optional[float]:
|
||||
if not api_summary and not web_get_all:
|
||||
try:
|
||||
@@ -152,9 +142,7 @@ class CGMinerInnosiliconT3HPlus(CGMiner, InnosiliconT3HPlus):
|
||||
pass
|
||||
|
||||
async def get_hashboards(
|
||||
self,
|
||||
api_stats: dict = None,
|
||||
web_get_all: dict = None, # noqa: named this way for automatic functionality
|
||||
self, api_stats: dict = None, web_get_all: dict = None
|
||||
) -> List[HashBoard]:
|
||||
hashboards = [
|
||||
HashBoard(slot=i, expected_chips=self.nominal_chips)
|
||||
@@ -209,9 +197,7 @@ class CGMinerInnosiliconT3HPlus(CGMiner, InnosiliconT3HPlus):
|
||||
return hashboards
|
||||
|
||||
async def get_wattage(
|
||||
self,
|
||||
web_get_all: dict = None,
|
||||
api_stats: dict = None, # noqa: named this way for automatic functionality
|
||||
self, web_get_all: dict = None, api_stats: dict = None
|
||||
) -> Optional[int]:
|
||||
if not web_get_all:
|
||||
try:
|
||||
@@ -244,10 +230,7 @@ class CGMinerInnosiliconT3HPlus(CGMiner, InnosiliconT3HPlus):
|
||||
wattage = int(wattage)
|
||||
return wattage
|
||||
|
||||
async def get_fans(
|
||||
self,
|
||||
web_get_all: dict = None, # noqa: named this way for automatic functionality
|
||||
) -> List[Fan]:
|
||||
async def get_fans(self, web_get_all: dict = None) -> List[Fan]:
|
||||
if not web_get_all:
|
||||
try:
|
||||
web_get_all = await self.web.get_all()
|
||||
|
||||
@@ -27,7 +27,8 @@ class _MinerListener:
|
||||
def connection_made(self, transport):
|
||||
self.transport = transport
|
||||
|
||||
def datagram_received(self, data, _addr):
|
||||
@staticmethod
|
||||
def datagram_received(data, _addr):
|
||||
m = data.decode()
|
||||
if "," in m:
|
||||
ip, mac = m.split(",")
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from collections import namedtuple
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from pyasic.API.unknown import UnknownAPI
|
||||
@@ -26,7 +25,9 @@ from pyasic.miners.base import BaseMiner
|
||||
|
||||
|
||||
class UnknownMiner(BaseMiner):
|
||||
def __init__(self, ip: str, *args, **kwargs) -> None:
|
||||
def __init__(
|
||||
self, ip: str, *args, **kwargs
|
||||
) -> None: # noqa - ignore *args and **kwargs for signature consistency
|
||||
super().__init__()
|
||||
self.ip = ip
|
||||
self.api = UnknownAPI(ip)
|
||||
|
||||
Reference in New Issue
Block a user