Improve get_miner (#43)
* feature: Start refactor to new style of get_miner. Needs testing and stability fixes. * feature: refactor to aiohttp and fix a lot of bugs with factory. Still needs support for some miners. * feature: refactor miner class list to be much more readable. * bug: remove some redundant .upper() calls. * bug: remove some redundant .upper() calls. * feature: add Avalonminer support in update miner factory, and add support for A1166 and A1246. * feature: refactor get_miner to allow models to be selected as strings then selected in the top level get_miner function. * bug: fix some naming issues, and add timeout to getting miner model. * bug: fix not instantiating some web sessions properly.
This commit is contained in:
@@ -18,9 +18,9 @@ import ipaddress
|
||||
from typing import Union
|
||||
|
||||
from pyasic.miners.base import AnyMiner, BaseMiner
|
||||
from pyasic.miners.miner_factory import MinerFactory
|
||||
from pyasic.miners.miner_factory import miner_factory
|
||||
|
||||
|
||||
# abstracted version of get miner that is easier to access
|
||||
async def get_miner(ip: Union[ipaddress.ip_address, str]) -> AnyMiner:
|
||||
return await MinerFactory().get_miner(ip)
|
||||
return await miner_factory.get_miner(ip)
|
||||
|
||||
29
pyasic/miners/btc/_types/avalonminer/A11X/A1166.py
Normal file
29
pyasic/miners/btc/_types/avalonminer/A11X/A1166.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright 2022 Upstream Data Inc -
|
||||
# -
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); -
|
||||
# you may not use this file except in compliance with the License. -
|
||||
# You may obtain a copy of the License at -
|
||||
# -
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 -
|
||||
# -
|
||||
# Unless required by applicable law or agreed to in writing, software -
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, -
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
import warnings
|
||||
|
||||
from pyasic.miners.makes import AvalonMiner
|
||||
|
||||
|
||||
class Avalon1166Pro(AvalonMiner): # noqa - ignore ABC method implementation
|
||||
def __init__(self, ip: str, api_ver: str = "0.0.0"):
|
||||
super().__init__(ip, api_ver)
|
||||
self.ip = ip
|
||||
self.model = "Avalon 1166"
|
||||
warnings.warn(
|
||||
f"Unknown chip count for miner type {self.model}, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)."
|
||||
)
|
||||
self.fan_count = 4
|
||||
18
pyasic/miners/btc/_types/avalonminer/A11X/__init__.py
Normal file
18
pyasic/miners/btc/_types/avalonminer/A11X/__init__.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright 2022 Upstream Data Inc -
|
||||
# -
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); -
|
||||
# you may not use this file except in compliance with the License. -
|
||||
# You may obtain a copy of the License at -
|
||||
# -
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 -
|
||||
# -
|
||||
# Unless required by applicable law or agreed to in writing, software -
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, -
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
from .A1166 import Avalon1166Pro
|
||||
29
pyasic/miners/btc/_types/avalonminer/A12X/A1246.py
Normal file
29
pyasic/miners/btc/_types/avalonminer/A12X/A1246.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright 2022 Upstream Data Inc -
|
||||
# -
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); -
|
||||
# you may not use this file except in compliance with the License. -
|
||||
# You may obtain a copy of the License at -
|
||||
# -
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 -
|
||||
# -
|
||||
# Unless required by applicable law or agreed to in writing, software -
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, -
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
import warnings
|
||||
|
||||
from pyasic.miners.makes import AvalonMiner
|
||||
|
||||
|
||||
class Avalon1246(AvalonMiner): # noqa - ignore ABC method implementation
|
||||
def __init__(self, ip: str, api_ver: str = "0.0.0"):
|
||||
super().__init__(ip, api_ver)
|
||||
self.ip = ip
|
||||
self.model = "Avalon 1246"
|
||||
warnings.warn(
|
||||
f"Unknown chip count for miner type {self.model}, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)."
|
||||
)
|
||||
self.fan_count = 4
|
||||
@@ -13,4 +13,5 @@
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
from .E9_Pro import CGMinerE9Pro
|
||||
|
||||
from .A1246 import Avalon1246
|
||||
@@ -18,3 +18,5 @@ from .A7X import *
|
||||
from .A8X import *
|
||||
from .A9X import *
|
||||
from .A10X import *
|
||||
from .A11X import *
|
||||
from .A12X import *
|
||||
|
||||
23
pyasic/miners/btc/avalonminer/cgminer/A11X/A1166.py
Normal file
23
pyasic/miners/btc/avalonminer/cgminer/A11X/A1166.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright 2022 Upstream Data Inc -
|
||||
# -
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); -
|
||||
# you may not use this file except in compliance with the License. -
|
||||
# You may obtain a copy of the License at -
|
||||
# -
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 -
|
||||
# -
|
||||
# Unless required by applicable law or agreed to in writing, software -
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, -
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from pyasic.miners.btc._types import Avalon1166Pro # noqa
|
||||
|
||||
from .A11X import CGMinerA11X
|
||||
|
||||
|
||||
class CGMinerAvalon1166Pro(CGMinerA11X, Avalon1166Pro):
|
||||
pass
|
||||
21
pyasic/miners/btc/avalonminer/cgminer/A11X/A11X.py
Normal file
21
pyasic/miners/btc/avalonminer/cgminer/A11X/A11X.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright 2022 Upstream Data Inc -
|
||||
# -
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); -
|
||||
# you may not use this file except in compliance with the License. -
|
||||
# You may obtain a copy of the License at -
|
||||
# -
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 -
|
||||
# -
|
||||
# Unless required by applicable law or agreed to in writing, software -
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, -
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from pyasic.miners.backends import CGMinerAvalon # noqa - Ignore access to _module
|
||||
|
||||
|
||||
class CGMinerA11X(CGMinerAvalon):
|
||||
pass
|
||||
17
pyasic/miners/btc/avalonminer/cgminer/A11X/__init__.py
Normal file
17
pyasic/miners/btc/avalonminer/cgminer/A11X/__init__.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright 2022 Upstream Data Inc -
|
||||
# -
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); -
|
||||
# you may not use this file except in compliance with the License. -
|
||||
# You may obtain a copy of the License at -
|
||||
# -
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 -
|
||||
# -
|
||||
# Unless required by applicable law or agreed to in writing, software -
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, -
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from .A1166 import CGMinerAvalon1166Pro
|
||||
23
pyasic/miners/btc/avalonminer/cgminer/A12X/A1246.py
Normal file
23
pyasic/miners/btc/avalonminer/cgminer/A12X/A1246.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright 2022 Upstream Data Inc -
|
||||
# -
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); -
|
||||
# you may not use this file except in compliance with the License. -
|
||||
# You may obtain a copy of the License at -
|
||||
# -
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 -
|
||||
# -
|
||||
# Unless required by applicable law or agreed to in writing, software -
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, -
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from pyasic.miners.btc._types import Avalon1246
|
||||
|
||||
from .A12X import CGMinerA12X
|
||||
|
||||
|
||||
class CGMinerAvalon1246(CGMinerA12X, Avalon1246):
|
||||
pass
|
||||
21
pyasic/miners/btc/avalonminer/cgminer/A12X/A12X.py
Normal file
21
pyasic/miners/btc/avalonminer/cgminer/A12X/A12X.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright 2022 Upstream Data Inc -
|
||||
# -
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); -
|
||||
# you may not use this file except in compliance with the License. -
|
||||
# You may obtain a copy of the License at -
|
||||
# -
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 -
|
||||
# -
|
||||
# Unless required by applicable law or agreed to in writing, software -
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, -
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from pyasic.miners.backends import CGMinerAvalon # noqa - Ignore access to _module
|
||||
|
||||
|
||||
class CGMinerA12X(CGMinerAvalon):
|
||||
pass
|
||||
17
pyasic/miners/btc/avalonminer/cgminer/A12X/__init__.py
Normal file
17
pyasic/miners/btc/avalonminer/cgminer/A12X/__init__.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright 2022 Upstream Data Inc -
|
||||
# -
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); -
|
||||
# you may not use this file except in compliance with the License. -
|
||||
# You may obtain a copy of the License at -
|
||||
# -
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 -
|
||||
# -
|
||||
# Unless required by applicable law or agreed to in writing, software -
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, -
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from .A1246 import CGMinerAvalon1246
|
||||
@@ -18,3 +18,5 @@ from .A7X import *
|
||||
from .A8X import *
|
||||
from .A9X import *
|
||||
from .A10X import *
|
||||
from .A11X import *
|
||||
from .A12X import *
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
from .cgminer import *
|
||||
from .bmminer import *
|
||||
|
||||
@@ -18,7 +18,7 @@ from pyasic.miners.backends import AntminerModern
|
||||
from pyasic.miners.etc._types import E9Pro # noqa - Ignore access to _module
|
||||
|
||||
|
||||
class CGMinerE9Pro(AntminerModern, E9Pro):
|
||||
class BMMinerE9Pro(AntminerModern, E9Pro):
|
||||
def __init__(self, ip: str, api_ver: str = "0.0.0"):
|
||||
super().__init__(ip, api_ver)
|
||||
self.supports_shutdown = False
|
||||
16
pyasic/miners/etc/antminer/bmminer/X9/__init__.py
Normal file
16
pyasic/miners/etc/antminer/bmminer/X9/__init__.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright 2022 Upstream Data Inc -
|
||||
# -
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); -
|
||||
# you may not use this file except in compliance with the License. -
|
||||
# You may obtain a copy of the License at -
|
||||
# -
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 -
|
||||
# -
|
||||
# Unless required by applicable law or agreed to in writing, software -
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, -
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
from .E9_Pro import BMMinerE9Pro
|
||||
@@ -13,4 +13,4 @@
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
from .cgminer import *
|
||||
from .bmminer import *
|
||||
|
||||
@@ -18,7 +18,7 @@ from pyasic.miners.backends import AntminerModern
|
||||
from pyasic.miners.hns._types import HS3 # noqa - Ignore access to _module
|
||||
|
||||
|
||||
class CGMinerHS3(AntminerModern, HS3):
|
||||
class BMMinerHS3(AntminerModern, HS3):
|
||||
def __init__(self, ip: str, api_ver: str = "0.0.0"):
|
||||
super().__init__(ip, api_ver)
|
||||
self.supports_shutdown = False
|
||||
@@ -13,4 +13,4 @@
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
from .HS3 import CGMinerHS3
|
||||
from .HS3 import BMMinerHS3
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user