refactor some classes into their own files and fill base __init__.py with imports
This commit is contained in:
@@ -22,7 +22,7 @@ import toml
|
||||
|
||||
from pyasic.miners.base import BaseMiner
|
||||
from pyasic.API.bosminer import BOSMinerAPI
|
||||
from pyasic.API import APIError
|
||||
from pyasic.errors import APIError
|
||||
|
||||
from pyasic.data.error_codes import BraiinsOSError
|
||||
from pyasic.data import MinerData
|
||||
|
||||
@@ -19,7 +19,7 @@ from typing import Union
|
||||
|
||||
from pyasic.API.btminer import BTMinerAPI
|
||||
from pyasic.miners.base import BaseMiner
|
||||
from pyasic.API import APIError
|
||||
from pyasic.errors import APIError
|
||||
|
||||
from pyasic.data import MinerData
|
||||
from pyasic.data.error_codes import WhatsminerError
|
||||
|
||||
@@ -19,7 +19,7 @@ from typing import Union
|
||||
|
||||
from pyasic.API.cgminer import CGMinerAPI
|
||||
from pyasic.miners.base import BaseMiner
|
||||
from pyasic.API import APIError
|
||||
from pyasic.errors import APIError
|
||||
from pyasic.config import MinerConfig
|
||||
|
||||
from pyasic.data import MinerData
|
||||
|
||||
@@ -13,3 +13,4 @@
|
||||
# limitations under the License.
|
||||
|
||||
from .S9 import CGMinerS9
|
||||
from .T9 import CGMinerT9
|
||||
|
||||
@@ -91,18 +91,10 @@ class BaseMiner(ABC):
|
||||
async def fault_light_off(self) -> bool:
|
||||
pass
|
||||
|
||||
# async def send_file(self, src, dest):
|
||||
# async with (await self._get_ssh_connection()) as conn:
|
||||
# await asyncssh.scp(src, (conn, dest))
|
||||
|
||||
@abstractmethod
|
||||
async def check_light(self) -> bool:
|
||||
pass
|
||||
|
||||
# @abstractmethod
|
||||
async def get_board_info(self):
|
||||
return None
|
||||
|
||||
@abstractmethod
|
||||
async def get_config(self) -> MinerConfig:
|
||||
pass
|
||||
|
||||
@@ -18,7 +18,7 @@ from pyasic.data import MinerData
|
||||
from pyasic.data.error_codes import InnosiliconError
|
||||
from pyasic.settings import PyasicSettings
|
||||
from pyasic.config import MinerConfig
|
||||
from pyasic.API import APIError
|
||||
from pyasic.errors import APIError
|
||||
|
||||
import httpx
|
||||
import warnings
|
||||
|
||||
@@ -32,7 +32,9 @@ from pyasic.miners._backends.bosminer_old import ( # noqa - Ignore _module impo
|
||||
|
||||
from pyasic.miners.unknown import UnknownMiner
|
||||
|
||||
from pyasic.API import APIError
|
||||
from pyasic.errors import APIError
|
||||
|
||||
from pyasic.misc import Singleton
|
||||
|
||||
import asyncio
|
||||
import ipaddress
|
||||
@@ -59,6 +61,7 @@ MINER_CLASSES = {
|
||||
"Default": BMMinerT9,
|
||||
"BMMiner": BMMinerT9,
|
||||
"Hiveon": HiveonT9,
|
||||
"CGMiner": CGMinerT9,
|
||||
},
|
||||
"ANTMINER S17": {
|
||||
"Default": BMMinerS17,
|
||||
@@ -252,15 +255,6 @@ MINER_CLASSES = {
|
||||
}
|
||||
|
||||
|
||||
class Singleton(type):
|
||||
_instances = {}
|
||||
|
||||
def __call__(cls, *args, **kwargs):
|
||||
if cls not in cls._instances:
|
||||
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
|
||||
return cls._instances[cls]
|
||||
|
||||
|
||||
class MinerFactory(metaclass=Singleton):
|
||||
"""A factory to handle identification and selection of the proper class of miner"""
|
||||
|
||||
@@ -637,9 +631,7 @@ class MinerFactory(metaclass=Singleton):
|
||||
else:
|
||||
# make sure the command succeeded
|
||||
if data["STATUS"][0]["STATUS"] not in ("S", "I"):
|
||||
# this is an error
|
||||
if data["STATUS"][0]["STATUS"] not in ("S", "I"):
|
||||
return False, data["STATUS"][0]["Msg"]
|
||||
return False, data["STATUS"][0]["Msg"]
|
||||
return True, None
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -14,14 +14,7 @@
|
||||
|
||||
import asyncio
|
||||
|
||||
|
||||
class Singleton(type):
|
||||
_instances = {}
|
||||
|
||||
def __call__(cls, *args, **kwargs):
|
||||
if cls not in cls._instances:
|
||||
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
|
||||
return cls._instances[cls]
|
||||
from pyasic.misc import Singleton
|
||||
|
||||
|
||||
class _MinerListener:
|
||||
|
||||
Reference in New Issue
Block a user