refactor: rename API to rpc, and classes from {X}API to {X}RPCAPI to clarify naming.
This commit is contained in:
@@ -4,24 +4,24 @@ Each miner has a unique API that is used to communicate with it.
|
|||||||
Each of these API types has commands that differ between them, and some commands have data that others do not.
|
Each of these API types has commands that differ between them, and some commands have data that others do not.
|
||||||
Each miner that is a subclass of [`BaseMiner`][pyasic.miners.BaseMiner] should have an API linked to it as `Miner.api`.
|
Each miner that is a subclass of [`BaseMiner`][pyasic.miners.BaseMiner] should have an API linked to it as `Miner.api`.
|
||||||
|
|
||||||
All API implementations inherit from [`BaseMinerAPI`][pyasic.API.BaseMinerAPI], which implements the basic communications protocols.
|
All API implementations inherit from [`BaseMinerRPCAPI`][pyasic.API.BaseMinerRPCAPI], which implements the basic communications protocols.
|
||||||
|
|
||||||
[`BaseMinerAPI`][pyasic.API.BaseMinerAPI] should never be used unless inheriting to create a new miner API class for a new type of miner (which should be exceedingly rare).
|
[`BaseMinerRPCAPI`][pyasic.API.BaseMinerRPCAPI] should never be used unless inheriting to create a new miner API class for a new type of miner (which should be exceedingly rare).
|
||||||
[`BaseMinerAPI`][pyasic.API.BaseMinerAPI] cannot be instantiated directly, it will raise a `TypeError`.
|
[`BaseMinerRPCAPI`][pyasic.API.BaseMinerRPCAPI] cannot be instantiated directly, it will raise a `TypeError`.
|
||||||
Use these instead -
|
Use these instead -
|
||||||
|
|
||||||
#### [BFGMiner API][pyasic.API.bfgminer.BFGMinerAPI]
|
#### [BFGMiner API][pyasic.API.bfgminer.BFGMinerRPCAPI]
|
||||||
#### [BMMiner API][pyasic.API.bmminer.BMMinerAPI]
|
#### [BMMiner API][pyasic.API.bmminer.BMMinerRPCAPI]
|
||||||
#### [BOSMiner API][pyasic.API.bosminer.BOSMinerAPI]
|
#### [BOSMiner API][pyasic.API.bosminer.BOSMinerRPCAPI]
|
||||||
#### [BTMiner API][pyasic.API.btminer.BTMinerAPI]
|
#### [BTMiner API][pyasic.API.btminer.BTMinerRPCAPI]
|
||||||
#### [CGMiner API][pyasic.API.cgminer.CGMinerAPI]
|
#### [CGMiner API][pyasic.API.cgminer.CGMinerRPCAPI]
|
||||||
#### [LUXMiner API][pyasic.API.luxminer.LUXMinerAPI]
|
#### [LUXMiner API][pyasic.API.luxminer.LUXMinerRPCAPI]
|
||||||
#### [Unknown API][pyasic.API.unknown.UnknownAPI]
|
#### [Unknown API][pyasic.API.unknown.UnknownRPCAPI]
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## BaseMinerAPI
|
## BaseMinerRPCAPI
|
||||||
::: pyasic.API.BaseMinerAPI
|
::: pyasic.API.BaseMinerRPCAPI
|
||||||
handler: python
|
handler: python
|
||||||
options:
|
options:
|
||||||
heading_level: 4
|
heading_level: 4
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# pyasic
|
# pyasic
|
||||||
## BFGMinerAPI
|
## BFGMinerRPCAPI
|
||||||
::: pyasic.API.bfgminer.BFGMinerAPI
|
::: pyasic.API.bfgminer.BFGMinerRPCAPI
|
||||||
handler: python
|
handler: python
|
||||||
options:
|
options:
|
||||||
show_root_heading: false
|
show_root_heading: false
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# pyasic
|
# pyasic
|
||||||
## BMMinerAPI
|
## BMMinerRPCAPI
|
||||||
::: pyasic.API.bmminer.BMMinerAPI
|
::: pyasic.API.bmminer.BMMinerRPCAPI
|
||||||
handler: python
|
handler: python
|
||||||
options:
|
options:
|
||||||
show_root_heading: false
|
show_root_heading: false
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# pyasic
|
# pyasic
|
||||||
## BOSMinerAPI
|
## BOSMinerRPCAPI
|
||||||
::: pyasic.API.bosminer.BOSMinerAPI
|
::: pyasic.API.bosminer.BOSMinerRPCAPI
|
||||||
handler: python
|
handler: python
|
||||||
options:
|
options:
|
||||||
show_root_heading: false
|
show_root_heading: false
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# pyasic
|
# pyasic
|
||||||
## BTMinerAPI
|
## BTMinerRPCAPI
|
||||||
::: pyasic.API.btminer.BTMinerAPI
|
::: pyasic.API.btminer.BTMinerRPCAPI
|
||||||
handler: python
|
handler: python
|
||||||
options:
|
options:
|
||||||
show_root_heading: false
|
show_root_heading: false
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# pyasic
|
# pyasic
|
||||||
## CGMinerAPI
|
## CGMinerRPCAPI
|
||||||
::: pyasic.API.cgminer.CGMinerAPI
|
::: pyasic.API.cgminer.CGMinerRPCAPI
|
||||||
handler: python
|
handler: python
|
||||||
options:
|
options:
|
||||||
show_root_heading: false
|
show_root_heading: false
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# pyasic
|
# pyasic
|
||||||
## LUXMinerAPI
|
## LUXMinerRPCAPI
|
||||||
::: pyasic.API.luxminer.LUXMinerAPI
|
::: pyasic.API.luxminer.LUXMinerRPCAPI
|
||||||
handler: python
|
handler: python
|
||||||
options:
|
options:
|
||||||
show_root_heading: false
|
show_root_heading: false
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# pyasic
|
# pyasic
|
||||||
## UnknownAPI
|
## UnknownRPCAPI
|
||||||
::: pyasic.API.unknown.UnknownAPI
|
::: pyasic.API.unknown.UnknownRPCAPI
|
||||||
handler: python
|
handler: python
|
||||||
options:
|
options:
|
||||||
show_root_heading: false
|
show_root_heading: false
|
||||||
|
|||||||
@@ -14,11 +14,6 @@
|
|||||||
# limitations under the License. -
|
# limitations under the License. -
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
from pyasic import settings
|
from pyasic import settings
|
||||||
from pyasic.API.bmminer import BMMinerAPI
|
|
||||||
from pyasic.API.bosminer import BOSMinerAPI
|
|
||||||
from pyasic.API.btminer import BTMinerAPI
|
|
||||||
from pyasic.API.cgminer import CGMinerAPI
|
|
||||||
from pyasic.API.unknown import UnknownAPI
|
|
||||||
from pyasic.config import MinerConfig
|
from pyasic.config import MinerConfig
|
||||||
from pyasic.data import (
|
from pyasic.data import (
|
||||||
BraiinsOSError,
|
BraiinsOSError,
|
||||||
@@ -33,13 +28,18 @@ from pyasic.miners.base import AnyMiner, DataOptions
|
|||||||
from pyasic.miners.miner_factory import MinerFactory, miner_factory
|
from pyasic.miners.miner_factory import MinerFactory, miner_factory
|
||||||
from pyasic.miners.miner_listener import MinerListener
|
from pyasic.miners.miner_listener import MinerListener
|
||||||
from pyasic.network import MinerNetwork
|
from pyasic.network import MinerNetwork
|
||||||
|
from pyasic.rpc.bmminer import BMMinerRPCAPI
|
||||||
|
from pyasic.rpc.bosminer import BOSMinerRPCAPI
|
||||||
|
from pyasic.rpc.btminer import BTMinerRPCAPI
|
||||||
|
from pyasic.rpc.cgminer import CGMinerRPCAPI
|
||||||
|
from pyasic.rpc.unknown import UnknownRPCAPI
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"BMMinerAPI",
|
"BMMinerRPCAPI",
|
||||||
"BOSMinerAPI",
|
"BOSMinerRPCAPI",
|
||||||
"BTMinerAPI",
|
"BTMinerRPCAPI",
|
||||||
"CGMinerAPI",
|
"CGMinerRPCAPI",
|
||||||
"UnknownAPI",
|
"UnknownRPCAPI",
|
||||||
"MinerConfig",
|
"MinerConfig",
|
||||||
"MinerData",
|
"MinerData",
|
||||||
"BraiinsOSError",
|
"BraiinsOSError",
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
from typing import List, Optional, Union
|
from typing import List, Optional, Union
|
||||||
|
|
||||||
from pyasic.API import APIError
|
|
||||||
from pyasic.config import MinerConfig, MiningModeConfig
|
from pyasic.config import MinerConfig, MiningModeConfig
|
||||||
from pyasic.data import Fan, HashBoard
|
from pyasic.data import Fan, HashBoard
|
||||||
from pyasic.data.error_codes import MinerErrorData, X19Error
|
from pyasic.data.error_codes import MinerErrorData, X19Error
|
||||||
@@ -29,6 +28,7 @@ from pyasic.miners.base import (
|
|||||||
RPCAPICommand,
|
RPCAPICommand,
|
||||||
WebAPICommand,
|
WebAPICommand,
|
||||||
)
|
)
|
||||||
|
from pyasic.rpc import APIError
|
||||||
from pyasic.web.antminer import AntminerModernWebAPI, AntminerOldWebAPI
|
from pyasic.web.antminer import AntminerModernWebAPI, AntminerOldWebAPI
|
||||||
|
|
||||||
ANTMINER_MODERN_DATA_LOC = DataLocations(
|
ANTMINER_MODERN_DATA_LOC = DataLocations(
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from pyasic.API.bfgminer import BFGMinerAPI
|
|
||||||
from pyasic.config import MinerConfig
|
from pyasic.config import MinerConfig
|
||||||
from pyasic.data import Fan, HashBoard
|
from pyasic.data import Fan, HashBoard
|
||||||
from pyasic.data.error_codes import MinerErrorData
|
from pyasic.data.error_codes import MinerErrorData
|
||||||
@@ -28,6 +27,7 @@ from pyasic.miners.base import (
|
|||||||
DataOptions,
|
DataOptions,
|
||||||
RPCAPICommand,
|
RPCAPICommand,
|
||||||
)
|
)
|
||||||
|
from pyasic.rpc.bfgminer import BFGMinerRPCAPI
|
||||||
|
|
||||||
BFGMINER_DATA_LOC = DataLocations(
|
BFGMINER_DATA_LOC = DataLocations(
|
||||||
**{
|
**{
|
||||||
@@ -70,7 +70,7 @@ class BFGMiner(BaseMiner):
|
|||||||
def __init__(self, ip: str, api_ver: str = "0.0.0") -> None:
|
def __init__(self, ip: str, api_ver: str = "0.0.0") -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
# interfaces
|
# interfaces
|
||||||
self.api = BFGMinerAPI(ip, api_ver)
|
self.api = BFGMinerRPCAPI(ip, api_ver)
|
||||||
|
|
||||||
# static data
|
# static data
|
||||||
self.api_type = "BFGMiner"
|
self.api_type = "BFGMiner"
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
import logging
|
import logging
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from pyasic.API.bmminer import BMMinerAPI
|
|
||||||
from pyasic.config import MinerConfig
|
from pyasic.config import MinerConfig
|
||||||
from pyasic.data import Fan, HashBoard
|
from pyasic.data import Fan, HashBoard
|
||||||
from pyasic.data.error_codes import MinerErrorData
|
from pyasic.data.error_codes import MinerErrorData
|
||||||
@@ -29,6 +28,7 @@ from pyasic.miners.base import (
|
|||||||
DataOptions,
|
DataOptions,
|
||||||
RPCAPICommand,
|
RPCAPICommand,
|
||||||
)
|
)
|
||||||
|
from pyasic.rpc.bmminer import BMMinerRPCAPI
|
||||||
|
|
||||||
BMMINER_DATA_LOC = DataLocations(
|
BMMINER_DATA_LOC = DataLocations(
|
||||||
**{
|
**{
|
||||||
@@ -73,7 +73,7 @@ class BMMiner(BaseMiner):
|
|||||||
def __init__(self, ip: str, api_ver: str = "0.0.0") -> None:
|
def __init__(self, ip: str, api_ver: str = "0.0.0") -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
# interfaces
|
# interfaces
|
||||||
self.api = BMMinerAPI(ip, api_ver)
|
self.api = BMMinerRPCAPI(ip, api_ver)
|
||||||
|
|
||||||
# static data
|
# static data
|
||||||
self.api_type = "BMMiner"
|
self.api_type = "BMMiner"
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ from typing import List, Optional, Union
|
|||||||
|
|
||||||
import toml
|
import toml
|
||||||
|
|
||||||
from pyasic.API.bosminer import BOSMinerAPI
|
|
||||||
from pyasic.config import MinerConfig
|
from pyasic.config import MinerConfig
|
||||||
from pyasic.config.mining import MiningModePowerTune
|
from pyasic.config.mining import MiningModePowerTune
|
||||||
from pyasic.data import Fan, HashBoard
|
from pyasic.data import Fan, HashBoard
|
||||||
@@ -35,6 +34,7 @@ from pyasic.miners.base import (
|
|||||||
RPCAPICommand,
|
RPCAPICommand,
|
||||||
WebAPICommand,
|
WebAPICommand,
|
||||||
)
|
)
|
||||||
|
from pyasic.rpc.bosminer import BOSMinerRPCAPI
|
||||||
from pyasic.web.braiins_os import BOSerWebAPI, BOSMinerWebAPI
|
from pyasic.web.braiins_os import BOSerWebAPI, BOSMinerWebAPI
|
||||||
|
|
||||||
BOSMINER_DATA_LOC = DataLocations(
|
BOSMINER_DATA_LOC = DataLocations(
|
||||||
@@ -99,7 +99,7 @@ class BOSMiner(BaseMiner):
|
|||||||
def __init__(self, ip: str, api_ver: str = "0.0.0") -> None:
|
def __init__(self, ip: str, api_ver: str = "0.0.0") -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
# interfaces
|
# interfaces
|
||||||
self.api = BOSMinerAPI(ip, api_ver)
|
self.api = BOSMinerRPCAPI(ip, api_ver)
|
||||||
self.web = BOSMinerWebAPI(ip)
|
self.web = BOSMinerWebAPI(ip)
|
||||||
|
|
||||||
# static data
|
# static data
|
||||||
@@ -715,7 +715,7 @@ class BOSer(BaseMiner):
|
|||||||
def __init__(self, ip: str, api_ver: str = "0.0.0") -> None:
|
def __init__(self, ip: str, api_ver: str = "0.0.0") -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
# interfaces
|
# interfaces
|
||||||
self.api = BOSMinerAPI(ip, api_ver)
|
self.api = BOSMinerRPCAPI(ip, api_ver)
|
||||||
self.web = BOSerWebAPI(ip)
|
self.web = BOSerWebAPI(ip)
|
||||||
|
|
||||||
# static data
|
# static data
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
import logging
|
import logging
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from pyasic.API.btminer import BTMinerAPI
|
|
||||||
from pyasic.config import MinerConfig, MiningModeConfig
|
from pyasic.config import MinerConfig, MiningModeConfig
|
||||||
from pyasic.data import Fan, HashBoard
|
from pyasic.data import Fan, HashBoard
|
||||||
from pyasic.data.error_codes import MinerErrorData, WhatsminerError
|
from pyasic.data.error_codes import MinerErrorData, WhatsminerError
|
||||||
@@ -29,6 +28,7 @@ from pyasic.miners.base import (
|
|||||||
DataOptions,
|
DataOptions,
|
||||||
RPCAPICommand,
|
RPCAPICommand,
|
||||||
)
|
)
|
||||||
|
from pyasic.rpc.btminer import BTMinerRPCAPI
|
||||||
|
|
||||||
BTMINER_DATA_LOC = DataLocations(
|
BTMINER_DATA_LOC = DataLocations(
|
||||||
**{
|
**{
|
||||||
@@ -110,7 +110,7 @@ class BTMiner(BaseMiner):
|
|||||||
def __init__(self, ip: str, api_ver: str = "0.0.0") -> None:
|
def __init__(self, ip: str, api_ver: str = "0.0.0") -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
# interfaces
|
# interfaces
|
||||||
self.api = BTMinerAPI(ip, api_ver)
|
self.api = BTMinerRPCAPI(ip, api_ver)
|
||||||
|
|
||||||
# static data
|
# static data
|
||||||
self.api_type = "BTMiner"
|
self.api_type = "BTMiner"
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
import logging
|
import logging
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from pyasic.API.cgminer import CGMinerAPI
|
|
||||||
from pyasic.config import MinerConfig
|
from pyasic.config import MinerConfig
|
||||||
from pyasic.data import Fan, HashBoard
|
from pyasic.data import Fan, HashBoard
|
||||||
from pyasic.data.error_codes import MinerErrorData
|
from pyasic.data.error_codes import MinerErrorData
|
||||||
@@ -29,6 +28,7 @@ from pyasic.miners.base import (
|
|||||||
DataOptions,
|
DataOptions,
|
||||||
RPCAPICommand,
|
RPCAPICommand,
|
||||||
)
|
)
|
||||||
|
from pyasic.rpc.cgminer import CGMinerRPCAPI
|
||||||
|
|
||||||
CGMINER_DATA_LOC = DataLocations(
|
CGMINER_DATA_LOC = DataLocations(
|
||||||
**{
|
**{
|
||||||
@@ -71,7 +71,7 @@ class CGMiner(BaseMiner):
|
|||||||
def __init__(self, ip: str, api_ver: str = "0.0.0") -> None:
|
def __init__(self, ip: str, api_ver: str = "0.0.0") -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
# interfaces
|
# interfaces
|
||||||
self.api = CGMinerAPI(ip, api_ver)
|
self.api = CGMinerRPCAPI(ip, api_ver)
|
||||||
|
|
||||||
# static data
|
# static data
|
||||||
self.api_type = "CGMiner"
|
self.api_type = "CGMiner"
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
from typing import List, Optional, Tuple, Union
|
from typing import List, Optional, Tuple, Union
|
||||||
|
|
||||||
from pyasic.API.luxminer import LUXMinerAPI
|
|
||||||
from pyasic.config import MinerConfig
|
from pyasic.config import MinerConfig
|
||||||
from pyasic.data import Fan, HashBoard
|
from pyasic.data import Fan, HashBoard
|
||||||
from pyasic.data.error_codes import MinerErrorData
|
from pyasic.data.error_codes import MinerErrorData
|
||||||
@@ -27,6 +26,7 @@ from pyasic.miners.base import (
|
|||||||
DataOptions,
|
DataOptions,
|
||||||
RPCAPICommand,
|
RPCAPICommand,
|
||||||
)
|
)
|
||||||
|
from pyasic.rpc.luxminer import LUXMinerRPCAPI
|
||||||
|
|
||||||
LUXMINER_DATA_LOC = DataLocations(
|
LUXMINER_DATA_LOC = DataLocations(
|
||||||
**{
|
**{
|
||||||
@@ -69,7 +69,7 @@ class LUXMiner(BaseMiner):
|
|||||||
def __init__(self, ip: str, api_ver: str = "0.0.0") -> None:
|
def __init__(self, ip: str, api_ver: str = "0.0.0") -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
# interfaces
|
# interfaces
|
||||||
self.api = LUXMinerAPI(ip, api_ver)
|
self.api = LUXMinerRPCAPI(ip, api_ver)
|
||||||
# self.web = BOSMinerWebAPI(ip)
|
# self.web = BOSMinerWebAPI(ip)
|
||||||
|
|
||||||
# static data
|
# static data
|
||||||
|
|||||||
@@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
from typing import List, Optional, Tuple
|
from typing import List, Optional, Tuple
|
||||||
|
|
||||||
from pyasic.API.unknown import UnknownAPI
|
|
||||||
from pyasic.config import MinerConfig
|
from pyasic.config import MinerConfig
|
||||||
from pyasic.data import Fan, HashBoard, MinerData
|
from pyasic.data import Fan, HashBoard, MinerData
|
||||||
from pyasic.data.error_codes import MinerErrorData
|
from pyasic.data.error_codes import MinerErrorData
|
||||||
from pyasic.miners.base import BaseMiner
|
from pyasic.miners.base import BaseMiner
|
||||||
|
from pyasic.rpc.unknown import UnknownRPCAPI
|
||||||
|
|
||||||
|
|
||||||
class UnknownMiner(BaseMiner):
|
class UnknownMiner(BaseMiner):
|
||||||
@@ -32,7 +32,7 @@ class UnknownMiner(BaseMiner):
|
|||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
self.api = UnknownAPI(ip)
|
self.api = UnknownRPCAPI(ip)
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"Unknown: {str(self.ip)}"
|
return f"Unknown: {str(self.ip)}"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
# See the License for the specific language governing permissions and -
|
# See the License for the specific language governing permissions and -
|
||||||
# limitations under the License. -
|
# limitations under the License. -
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
from pyasic.API import APIError
|
from pyasic.rpc import APIError
|
||||||
|
|
||||||
|
|
||||||
class Singleton(type):
|
class Singleton(type):
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ from typing import Union
|
|||||||
from pyasic.errors import APIError, APIWarning
|
from pyasic.errors import APIError, APIWarning
|
||||||
|
|
||||||
|
|
||||||
class BaseMinerAPI:
|
class BaseMinerRPCAPI:
|
||||||
def __init__(self, ip: str, port: int = 4028) -> None:
|
def __init__(self, ip: str, port: int = 4028) -> None:
|
||||||
# api port, should be 4028
|
# api port, should be 4028
|
||||||
self.port = port
|
self.port = port
|
||||||
@@ -35,7 +35,7 @@ class BaseMinerAPI:
|
|||||||
self.pwd = "admin"
|
self.pwd = "admin"
|
||||||
|
|
||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
if cls is BaseMinerAPI:
|
if cls is BaseMinerRPCAPI:
|
||||||
raise TypeError(f"Only children of '{cls.__name__}' may be instantiated")
|
raise TypeError(f"Only children of '{cls.__name__}' may be instantiated")
|
||||||
return object.__new__(cls)
|
return object.__new__(cls)
|
||||||
|
|
||||||
@@ -164,8 +164,8 @@ class BaseMinerAPI:
|
|||||||
func
|
func
|
||||||
not in [
|
not in [
|
||||||
func
|
func
|
||||||
for func in dir(BaseMinerAPI)
|
for func in dir(BaseMinerRPCAPI)
|
||||||
if callable(getattr(BaseMinerAPI, func))
|
if callable(getattr(BaseMinerRPCAPI, func))
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -16,10 +16,10 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pyasic.API import APIError, BaseMinerAPI
|
from pyasic.rpc import APIError, BaseMinerRPCAPI
|
||||||
|
|
||||||
|
|
||||||
class BFGMinerAPI(BaseMinerAPI):
|
class BFGMinerRPCAPI(BaseMinerRPCAPI):
|
||||||
"""An abstraction of the BFGMiner API.
|
"""An abstraction of the BFGMiner API.
|
||||||
|
|
||||||
Each method corresponds to an API command in BFGMiner.
|
Each method corresponds to an API command in BFGMiner.
|
||||||
@@ -16,10 +16,10 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pyasic.API import APIError, BaseMinerAPI
|
from pyasic.rpc import APIError, BaseMinerRPCAPI
|
||||||
|
|
||||||
|
|
||||||
class BMMinerAPI(BaseMinerAPI):
|
class BMMinerRPCAPI(BaseMinerRPCAPI):
|
||||||
"""An abstraction of the BMMiner API.
|
"""An abstraction of the BMMiner API.
|
||||||
|
|
||||||
Each method corresponds to an API command in BMMiner.
|
Each method corresponds to an API command in BMMiner.
|
||||||
@@ -14,10 +14,10 @@
|
|||||||
# limitations under the License. -
|
# limitations under the License. -
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
from pyasic.API import BaseMinerAPI
|
from pyasic.rpc import BaseMinerRPCAPI
|
||||||
|
|
||||||
|
|
||||||
class BOSMinerAPI(BaseMinerAPI):
|
class BOSMinerRPCAPI(BaseMinerRPCAPI):
|
||||||
"""An abstraction of the BOSMiner API.
|
"""An abstraction of the BOSMiner API.
|
||||||
|
|
||||||
Each method corresponds to an API command in BOSMiner.
|
Each method corresponds to an API command in BOSMiner.
|
||||||
@@ -28,9 +28,9 @@ from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
|||||||
from passlib.handlers.md5_crypt import md5_crypt
|
from passlib.handlers.md5_crypt import md5_crypt
|
||||||
|
|
||||||
from pyasic import settings
|
from pyasic import settings
|
||||||
from pyasic.API import BaseMinerAPI
|
|
||||||
from pyasic.errors import APIError
|
from pyasic.errors import APIError
|
||||||
from pyasic.misc import api_min_version
|
from pyasic.misc import api_min_version
|
||||||
|
from pyasic.rpc import BaseMinerRPCAPI
|
||||||
|
|
||||||
### IMPORTANT ###
|
### IMPORTANT ###
|
||||||
# you need to change the password of the miners using the Whatsminer
|
# you need to change the password of the miners using the Whatsminer
|
||||||
@@ -159,7 +159,7 @@ def create_privileged_cmd(token_data: dict, command: dict) -> bytes:
|
|||||||
return api_packet_str.encode("utf-8")
|
return api_packet_str.encode("utf-8")
|
||||||
|
|
||||||
|
|
||||||
class BTMinerAPI(BaseMinerAPI):
|
class BTMinerRPCAPI(BaseMinerRPCAPI):
|
||||||
"""An abstraction of the API for MicroBT Whatsminers, BTMiner.
|
"""An abstraction of the API for MicroBT Whatsminers, BTMiner.
|
||||||
|
|
||||||
Each method corresponds to an API command in BMMiner.
|
Each method corresponds to an API command in BMMiner.
|
||||||
@@ -16,10 +16,10 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pyasic.API import APIError, BaseMinerAPI
|
from pyasic.rpc import APIError, BaseMinerRPCAPI
|
||||||
|
|
||||||
|
|
||||||
class CGMinerAPI(BaseMinerAPI):
|
class CGMinerRPCAPI(BaseMinerRPCAPI):
|
||||||
"""An abstraction of the CGMiner API.
|
"""An abstraction of the CGMiner API.
|
||||||
|
|
||||||
Each method corresponds to an API command in GGMiner.
|
Each method corresponds to an API command in GGMiner.
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
|
|
||||||
from pyasic.API import BaseMinerAPI
|
from pyasic.rpc import BaseMinerRPCAPI
|
||||||
|
|
||||||
|
|
||||||
class LUXMinerAPI(BaseMinerAPI):
|
class LUXMinerRPCAPI(BaseMinerRPCAPI):
|
||||||
"""An abstraction of the LUXMiner API.
|
"""An abstraction of the LUXMiner API.
|
||||||
|
|
||||||
Each method corresponds to an API command in LUXMiner.
|
Each method corresponds to an API command in LUXMiner.
|
||||||
@@ -14,10 +14,10 @@
|
|||||||
# limitations under the License. -
|
# limitations under the License. -
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
from pyasic.API import BaseMinerAPI
|
from pyasic.rpc import BaseMinerRPCAPI
|
||||||
|
|
||||||
|
|
||||||
class UnknownAPI(BaseMinerAPI):
|
class UnknownRPCAPI(BaseMinerRPCAPI):
|
||||||
"""An abstraction of an API for a miner which is unknown.
|
"""An abstraction of an API for a miner which is unknown.
|
||||||
|
|
||||||
This class is designed to try to be an intersection of as many miner APIs
|
This class is designed to try to be an intersection of as many miner APIs
|
||||||
@@ -19,12 +19,12 @@ import unittest
|
|||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from pyasic import APIError
|
from pyasic import APIError
|
||||||
from pyasic.API.bfgminer import BFGMinerAPI
|
from pyasic.rpc.bfgminer import BFGMinerRPCAPI
|
||||||
from pyasic.API.bmminer import BMMinerAPI
|
from pyasic.rpc.bmminer import BMMinerRPCAPI
|
||||||
from pyasic.API.bosminer import BOSMinerAPI
|
from pyasic.rpc.bosminer import BOSMinerRPCAPI
|
||||||
from pyasic.API.btminer import BTMinerAPI
|
from pyasic.rpc.btminer import BTMinerRPCAPI
|
||||||
from pyasic.API.cgminer import CGMinerAPI
|
from pyasic.rpc.cgminer import CGMinerRPCAPI
|
||||||
from pyasic.API.luxminer import LUXMinerAPI
|
from pyasic.rpc.luxminer import LUXMinerRPCAPI
|
||||||
|
|
||||||
|
|
||||||
class TestAPIBase(unittest.IsolatedAsyncioTestCase):
|
class TestAPIBase(unittest.IsolatedAsyncioTestCase):
|
||||||
@@ -64,7 +64,7 @@ class TestAPIBase(unittest.IsolatedAsyncioTestCase):
|
|||||||
}
|
}
|
||||||
).encode("utf-8")
|
).encode("utf-8")
|
||||||
|
|
||||||
@patch("pyasic.API.BaseMinerAPI._send_bytes")
|
@patch("pyasic.rpc.BaseMinerRPCAPI._send_bytes")
|
||||||
async def test_command_error_raises_api_error(self, mock_send_bytes):
|
async def test_command_error_raises_api_error(self, mock_send_bytes):
|
||||||
if self.api is None:
|
if self.api is None:
|
||||||
return
|
return
|
||||||
@@ -73,7 +73,7 @@ class TestAPIBase(unittest.IsolatedAsyncioTestCase):
|
|||||||
with self.assertRaises(APIError):
|
with self.assertRaises(APIError):
|
||||||
await self.api.send_command("summary")
|
await self.api.send_command("summary")
|
||||||
|
|
||||||
@patch("pyasic.API.BaseMinerAPI._send_bytes")
|
@patch("pyasic.rpc.BaseMinerRPCAPI._send_bytes")
|
||||||
async def test_command_error_ignored_by_flag(self, mock_send_bytes):
|
async def test_command_error_ignored_by_flag(self, mock_send_bytes):
|
||||||
if self.api is None:
|
if self.api is None:
|
||||||
return
|
return
|
||||||
@@ -88,7 +88,7 @@ class TestAPIBase(unittest.IsolatedAsyncioTestCase):
|
|||||||
f"Expected ignore_errors flag to ignore error in {self.api_str} API"
|
f"Expected ignore_errors flag to ignore error in {self.api_str} API"
|
||||||
)
|
)
|
||||||
|
|
||||||
@patch("pyasic.API.BaseMinerAPI._send_bytes")
|
@patch("pyasic.rpc.BaseMinerRPCAPI._send_bytes")
|
||||||
async def test_all_read_command_success(self, mock_send_bytes):
|
async def test_all_read_command_success(self, mock_send_bytes):
|
||||||
if self.api is None:
|
if self.api is None:
|
||||||
return
|
return
|
||||||
@@ -114,37 +114,37 @@ class TestAPIBase(unittest.IsolatedAsyncioTestCase):
|
|||||||
|
|
||||||
class TestBFGMinerAPI(TestAPIBase):
|
class TestBFGMinerAPI(TestAPIBase):
|
||||||
def setUpData(self):
|
def setUpData(self):
|
||||||
self.api = BFGMinerAPI(self.ip)
|
self.api = BFGMinerRPCAPI(self.ip)
|
||||||
self.api_str = "BFGMiner"
|
self.api_str = "BFGMiner"
|
||||||
|
|
||||||
|
|
||||||
class TestBMMinerAPI(TestAPIBase):
|
class TestBMMinerAPI(TestAPIBase):
|
||||||
def setUpData(self):
|
def setUpData(self):
|
||||||
self.api = BMMinerAPI(self.ip)
|
self.api = BMMinerRPCAPI(self.ip)
|
||||||
self.api_str = "BMMiner"
|
self.api_str = "BMMiner"
|
||||||
|
|
||||||
|
|
||||||
class TestBOSMinerAPI(TestAPIBase):
|
class TestBOSMinerAPI(TestAPIBase):
|
||||||
def setUpData(self):
|
def setUpData(self):
|
||||||
self.api = BOSMinerAPI(self.ip)
|
self.api = BOSMinerRPCAPI(self.ip)
|
||||||
self.api_str = "BOSMiner"
|
self.api_str = "BOSMiner"
|
||||||
|
|
||||||
|
|
||||||
class TestBTMinerAPI(TestAPIBase):
|
class TestBTMinerAPI(TestAPIBase):
|
||||||
def setUpData(self):
|
def setUpData(self):
|
||||||
self.api = BTMinerAPI(self.ip)
|
self.api = BTMinerRPCAPI(self.ip)
|
||||||
self.api_str = "BTMiner"
|
self.api_str = "BTMiner"
|
||||||
|
|
||||||
|
|
||||||
class TestCGMinerAPI(TestAPIBase):
|
class TestCGMinerAPI(TestAPIBase):
|
||||||
def setUpData(self):
|
def setUpData(self):
|
||||||
self.api = CGMinerAPI(self.ip)
|
self.api = CGMinerRPCAPI(self.ip)
|
||||||
self.api_str = "CGMiner"
|
self.api_str = "CGMiner"
|
||||||
|
|
||||||
|
|
||||||
class TestLuxOSAPI(TestAPIBase):
|
class TestLuxOSAPI(TestAPIBase):
|
||||||
def setUpData(self):
|
def setUpData(self):
|
||||||
self.api = LUXMinerAPI(self.ip)
|
self.api = LUXMinerRPCAPI(self.ip)
|
||||||
self.api_str = "LuxOS"
|
self.api_str = "LuxOS"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user