Compare commits

...

45 Commits

Author SHA1 Message Date
UpstreamData
418c62b40d version: bump version number 2022-11-14 13:50:28 -07:00
UpstreamData
198a480c35 bug: fix bug with read timeout not being caught when sending graphql query 2022-11-14 13:49:57 -07:00
UpstreamData
2d4bf4e847 version: bump version number 2022-11-14 11:20:54 -07:00
UpstreamData
774e3d1a62 bug: fix wattage not setting correctly for some BOS+ miners with issues. 2022-11-14 11:20:27 -07:00
UpstreamData
ade3cd6fee version: bump version number 2022-11-14 09:56:18 -07:00
UpstreamData
28dc3ccb84 version: bump version number 2022-11-14 09:51:34 -07:00
UpstreamData
6ca8582ec3 bug: improve robustness of identifying new versions of bosminer running BOSer. 2022-11-14 09:49:19 -07:00
UpstreamData
74b4aeb44a version: bump version number 2022-11-14 09:14:28 -07:00
UpstreamData
9c7ab5ac57 bug: fix support for new miners that return a BOSer string in version data. 2022-11-14 09:10:18 -07:00
Upstream Data
65ecf1fea2 version: bump version number 2022-11-13 19:36:25 -07:00
Upstream Data
44142c658b format: remove print statements 2022-11-13 19:36:07 -07:00
Upstream Data
25a205ce6c version: bump version number 2022-11-13 19:27:55 -07:00
Upstream Data
25094084cf bug: clarify uppercasing data from __get_model_from_graphql() 2022-11-13 19:27:32 -07:00
Upstream Data
4eac601153 version: bump version number 2022-11-13 19:17:43 -07:00
Upstream Data
f0d8d66b9b bug: fix not handling errors in send_graphql_query 2022-11-13 19:16:48 -07:00
Upstream Data
cfa550f8c0 version: bump version number 2022-11-13 19:07:56 -07:00
Arceris
91f6a5bf41 bug: catch TypeError on temps 2022-11-13 19:06:52 -07:00
Upstream Data
464bd6be65 version: bump version number. 2022-11-13 18:58:31 -07:00
Upstream Data
031d7e2186 bug: fix missing catching IndexError 2022-11-13 18:58:05 -07:00
Upstream Data
126b0d124c version: bump version number 2022-11-13 18:54:46 -07:00
Upstream Data
81c84a3e8f bug: fix a bug with no try except blocks on pools. 2022-11-13 18:54:26 -07:00
Upstream Data
406d5bd549 version: bump version number 2022-11-13 18:21:18 -07:00
Upstream Data
cd5fe09fd9 bug: fix wrong formatting for multiple error handling 2022-11-13 18:20:15 -07:00
Upstream Data
766fc4efed bug: fix check light not responding properly from graphQL. 2022-11-13 17:06:35 -07:00
Upstream Data
b70fed40c8 bug: add try except statements to get_data to fix bugs with getting data from graphql. 2022-11-13 17:03:41 -07:00
Upstream Data
255d98fd08 bug: fix some issues with validating data from graphql properly 2022-11-13 16:48:22 -07:00
Upstream Data
78304631f7 bug: fix errors not registering properly on braiins OS miners 2022-11-13 16:34:26 -07:00
Upstream Data
ab230844fc bug: fix an issue with chip count not receiving properly in some cases. 2022-11-13 16:31:41 -07:00
Upstream Data
8a58cb9fd3 format: remove extra print 2022-11-13 16:28:36 -07:00
Upstream Data
70b6ed73dc bug: fix manual return from __get_devdetails_and_version 2022-11-13 16:27:42 -07:00
Upstream Data
d2400bf44e bug: fix identifying stock as bosminer. 2022-11-13 16:22:57 -07:00
Upstream Data
db780fe876 version: bump version number 2022-11-13 15:14:16 -07:00
Upstream Data
cd84ae828a bug: fix a bug with some missing temperatures in graphql. 2022-11-13 15:13:56 -07:00
Upstream Data
970d5d1031 version: bump version number 2022-11-13 14:39:23 -07:00
Upstream Data
da0e327ec7 feature: add support for graphQL for BOS miners which may be having API issues, such as BBB. 2022-11-13 14:38:44 -07:00
Upstream Data
4c84a8d572 bug: ensure bosminer check_light backwards compatibility 2022-11-13 11:06:28 -07:00
Upstream Data
1cfd895deb feature: improve speed of bosminer check_light by 10x using graphql. 2022-11-13 11:01:22 -07:00
Upstream Data
d0da08eb10 version: bump version number 2022-11-12 14:51:30 -07:00
Upstream Data
ee4f2cd87d bug: fix win error check not being cross platform 2022-11-12 14:51:10 -07:00
UpstreamData
8a6577c8aa docs: Update README.md. 2022-11-10 14:20:41 -07:00
UpstreamData
ed5eae4187 format: add isort to dev requirements. 2022-11-10 14:17:31 -07:00
UpstreamData
f3b25027ad format: add isort to pre-commit and sort imports. 2022-11-10 14:15:45 -07:00
UpstreamData
228daecbbf version: bump version number 2022-11-08 15:09:32 -07:00
UpstreamData
81aa569d07 feature: rework whatsminer error codes to be able to allow an arbitrary slot number to be returned from the BTMiner API. 2022-11-08 15:08:47 -07:00
upstreamdata
aba8d7b8b9 bug: fix an issue with get data on unknown miners. 2022-11-08 13:38:19 -07:00
85 changed files with 642 additions and 400 deletions

View File

@@ -9,6 +9,12 @@ repos:
rev: 22.6.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
- repo: local
hooks:
- id: unittest

View File

@@ -18,6 +18,10 @@ You can install pyasic directly from pip with the command `pip install pyasic`.
For those of you who aren't comfortable with code and developer tools, there are windows builds of GUI applications that use this library [here](https://drive.google.com/drive/folders/1DjR8UOS_g0ehfiJcgmrV0FFoqFvE9akW?usp=sharing).
## Developer Setup
It is highly reccommended that you contribute to this project through [`pyasic-super`](https://github.com/UpstreamData/pyasic-super) using its submodules. This allows testing in conjunction with other `pyasic` related programs.
<br>
This repo uses poetry for dependencies, which can be installed by following the guide on their website [here](https://python-poetry.org/docs/#installation).
After you have poetry installed, run `poetry install --with dev`, or `poetry install --with dev,docs` if you want to include packages required for documentation.

View File

@@ -13,12 +13,12 @@
# limitations under the License.
import asyncio
import json
import ipaddress
import warnings
import json
import logging
from typing import Union
import re
import warnings
from typing import Union
from pyasic.errors import APIError, APIWarning
@@ -98,7 +98,7 @@ If you are sure you want to use this command please use API.send_command("{comma
reader, writer = await asyncio.open_connection(str(self.ip), self.port)
# handle OSError 121
except OSError as e:
if e.winerror == "121":
if getattr(e, "winerror") == "121":
logging.warning("Semaphore Timeout has Expired.")
return b"{}"

View File

@@ -13,8 +13,7 @@
# limitations under the License.
import logging
from pyasic.API import BaseMinerAPI
from pyasic.API import APIError
from pyasic.API import APIError, BaseMinerAPI
class BMMinerAPI(BaseMinerAPI):

View File

@@ -13,22 +13,21 @@
# limitations under the License.
import asyncio
import re
import json
import hashlib
import binascii
import base64
import binascii
import hashlib
import json
import logging
import re
from typing import Union
from passlib.handlers.md5_crypt import md5_crypt
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from passlib.handlers.md5_crypt import md5_crypt
from pyasic.errors import APIError
from pyasic.API import BaseMinerAPI
from pyasic.errors import APIError
from pyasic.settings import PyasicSettings
### IMPORTANT ###
# you need to change the password of the miners using the Whatsminer
# tool, then you can set them back to admin with this tool, but they

View File

@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from pyasic.API import BaseMinerAPI, APIError
import logging
from pyasic.API import APIError, BaseMinerAPI
class CGMinerAPI(BaseMinerAPI):
"""An abstraction of the CGMiner API.

View File

@@ -16,26 +16,20 @@ 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.data import (
MinerData,
BraiinsOSError,
InnosiliconError,
MinerData,
WhatsminerError,
X19Error,
)
from pyasic.errors import APIError, APIWarning
from pyasic.miners import get_miner
from pyasic.miners.base import AnyMiner
from pyasic.miners.miner_factory import MinerFactory
from pyasic.miners.miner_listener import MinerListener
from pyasic.network import MinerNetwork
from pyasic.settings import PyasicSettings
__all__ = [

View File

@@ -12,15 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from dataclasses import dataclass, asdict, fields
from typing import Literal, List
import json
import random
import string
import time
from dataclasses import asdict, dataclass, fields
from typing import List, Literal
import toml
import yaml
import json
import time
@dataclass

View File

@@ -12,15 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Union, List
from dataclasses import dataclass, field, asdict, fields
import copy
import json
import time
from dataclasses import asdict, dataclass, field, fields
from datetime import datetime, timezone
from functools import reduce
import time
import json
import copy
from typing import List, Union
from .error_codes import X19Error, WhatsminerError, BraiinsOSError, InnosiliconError
from .error_codes import BraiinsOSError, InnosiliconError, WhatsminerError, X19Error
@dataclass

View File

@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from dataclasses import dataclass, asdict, fields
from dataclasses import asdict, dataclass, fields
@dataclass

View File

@@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .whatsminer import WhatsminerError
from .bos import BraiinsOSError
from .X19 import X19Error
from .innosilicon import InnosiliconError
from typing import TypeVar
from .bos import BraiinsOSError
from .innosilicon import InnosiliconError
from .whatsminer import WhatsminerError
from .X19 import X19Error
MinerErrorData = TypeVar(
"MinerErrorData", WhatsminerError, BraiinsOSError, X19Error, InnosiliconError
)

View File

@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from dataclasses import dataclass, asdict, fields
from dataclasses import asdict, dataclass, fields
@dataclass

View File

@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from dataclasses import dataclass, field, asdict, fields
from dataclasses import asdict, dataclass, field, fields
@dataclass

View File

@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from dataclasses import dataclass, field, asdict, fields
from dataclasses import asdict, dataclass, field, fields
@dataclass
@@ -27,16 +27,25 @@ class WhatsminerError:
error_code: int
error_message: str = field(init=False)
@classmethod
def fields(cls):
return fields(cls)
@property
def error_message(self): # noqa - Skip PyCharm inspection
if self.error_code in ERROR_CODES:
return ERROR_CODES[self.error_code]
return "Unknown error type."
err_type = int(str(self.error_code)[:-2])
err_subtype = int(str(self.error_code)[-2:-1])
err_value = int(str(self.error_code)[-1:])
try:
select_err_subtype = ERROR_CODES[err_type][err_subtype]
if err_value in select_err_subtype:
return select_err_subtype[err_value]
elif "n" in select_err_subtype:
return select_err_subtype["n"].replace("{n}", str(err_value)) # noqa: picks up `select_err_subtype["n"]` as not being numeric?
else:
return "Unknown error type."
except KeyError:
return "Unknown error type."
@error_message.setter
def error_message(self, val):
@@ -47,131 +56,158 @@ class WhatsminerError:
ERROR_CODES = {
110: "Intake fan speed error.",
111: "Exhaust fan speed error.",
120: "Intake fan speed error. Fan speed deviates by more than 2000.",
121: "Exhaust fan speed error. Fan speed deviates by more than 2000.",
130: "Intake fan speed error. Fan speed deviates by more than 3000.",
131: "Exhaust fan speed error. Fan speed deviates by more than 3000.",
140: "Fan speed too high.",
200: "Power probing error. No power found.",
201: "Power supply and configuration file don't match.",
202: "Power output voltage error.",
203: "Power protecting due to high environment temperature.",
204: "Power current protecting due to high environment temperature.",
205: "Power current error.",
206: "Power input low voltage error.",
207: "Power input current protecting due to bad power input.",
210: "Power error.",
213: "Power input voltage and current do not match power output.",
216: "Power remained unchanged for a long time.",
217: "Power set enable error.",
218: "Power input voltage is lower than 230V for high power mode.",
233: "Power output high temperature protection error.",
234: "Power output high temperature protection error.",
235: "Power output high temperature protection error.",
236: "Power output high current protection error.",
237: "Power output high current protection error.",
238: "Power output high current protection error.",
239: "Power output high voltage protection error.",
240: "Power output low voltage protection error.",
241: "Power output current imbalance error.",
243: "Power input high temperature protection error.",
244: "Power input high temperature protection error.",
245: "Power input high temperature protection error.",
246: "Power input high voltage protection error.",
247: "Power input high voltage protection error.",
248: "Power input high current protection error.",
249: "Power input high current protection error.",
250: "Power input low voltage protection error.",
251: "Power input low voltage protection error.",
253: "Power supply fan error.",
254: "Power supply fan error.",
255: "Power output high power protection error.",
256: "Power output high power protection error.",
257: "Input over current protection of power supply on primary side.",
263: "Power communication warning.",
264: "Power communication error.",
267: "Power watchdog protection.",
268: "Power output high current protection.",
269: "Power input high current protection.",
270: "Power input high voltage protection.",
271: "Power input low voltage protection.",
272: "Excessive power supply output warning.",
273: "Power input too high warning.",
274: "Power fan warning.",
275: "Power high temperature warning.",
300: "Right board temperature sensor detection error.",
301: "Center board temperature sensor detection error.",
302: "Left board temperature sensor detection error.",
320: "Right board temperature reading error.",
321: "Center board temperature reading error.",
322: "Left board temperature reading error.",
329: "Control board temperature sensor communication error.",
350: "Right board temperature protecting.",
351: "Center board temperature protecting.",
352: "Left board temperature protecting.",
360: "Hashboard high temperature error.",
410: "Right board eeprom detection error.",
411: "Center board eeprom detection error.",
412: "Left board eeprom detection error.",
420: "Right board eeprom parsing error.",
421: "Center board eeprom parsing error.",
422: "Left board eeprom parsing error.",
430: "Right board chip bin type error.",
431: "Center board chip bin type error.",
432: "Left board chip bin type error.",
440: "Right board eeprom chip number X error.",
441: "Center board eeprom chip number X error.",
442: "Left board eeprom chip number X error.",
450: "Right board eeprom xfer error.",
451: "Center board eeprom xfer error.",
452: "Left board eeprom xfer error.",
510: "Right board miner type error.",
511: "Center board miner type error.",
512: "Left board miner type error.",
520: "Right board bin type error.",
521: "Center board bin type error.",
522: "Left board bin type error.",
530: "Right board not found.",
531: "Center board not found.",
532: "Left board not found.",
540: "Right board error reading chip id.",
541: "Center board error reading chip id.",
542: "Left board error reading chip id.",
550: "Right board has bad chips.",
551: "Center board has bad chips.",
552: "Left board has bad chips.",
560: "Right board loss of balance error.",
561: "Center board loss of balance error.",
562: "Left board loss of balance error.",
600: "Environment temperature is too high.",
610: "Environment temperature is too high for high performance mode.",
701: "Control board no support chip.",
710: "Control board rebooted as an exception.",
712: "Control board rebooted as an exception.",
800: "CGMiner checksum error.",
801: "System monitor checksum error.",
802: "Remote daemon checksum error.",
2010: "All pools are disabled.",
2020: "Pool 0 connection failed.",
2021: "Pool 1 connection failed.",
2022: "Pool 2 connection failed.",
2023: "Pool 3 connection failed.",
2030: "High rejection rate on pool.",
2040: "The pool does not support asicboost mode.",
2310: "Hashrate is too low.",
2320: "Hashrate is too low.",
2340: "Hashrate loss is too high.",
2350: "Hashrate loss is too high.",
5070: "Right hashboard water velocity is abnormal.",
5071: "Center hashboard water velocity is abnormal.",
5072: "Left hashboard water velocity is abnormal.",
5110: "Right hashboard frequency up timeout.",
5111: "Center hashboard frequency up timeout.",
5112: "Left hashboard frequency up timeout.",
8410: "Software version error.",
100001: "/antiv/signature illegal.",
100002: "/antiv/dig/init.d illegal.",
100003: "/antiv/dig/pf_partial.dig illegal.",
1: { # Fan error
1: { # Fan speed error of 1000+
0: "Intake fan speed error.",
1: "Exhaust fan speed error.",
},
2: { # Fan speed error of 2000+
0: "Intake fan speed error. Fan speed deviates by more than 2000.",
1: "Exhaust fan speed error. Fan speed deviates by more than 2000.",
},
3: { # Fan speed error of 3000+
0: "Intake fan speed error. Fan speed deviates by more than 3000.",
1: "Exhaust fan speed error. Fan speed deviates by more than 3000.",
},
4: {0: "Fan speed too high."}, # High speed
},
2: { # Power error
0: {
0: "Power probing error. No power found.",
1: "Power supply and configuration file don't match.",
2: "Power output voltage error.",
3: "Power protecting due to high environment temperature.",
4: "Power current protecting due to high environment temperature.",
5: "Power current error.",
6: "Power input low voltage error.",
7: "Power input current protecting due to bad power input.",
},
1: {
0: "Power error.",
3: "Power input voltage and current do not match power output.",
6: "Power remained unchanged for a long time.",
7: "Power set enable error.",
8: "Power input voltage is lower than 230V for high power mode.",
},
3: {
3: "Power output high temperature protection error.",
4: "Power output high temperature protection error.",
5: "Power output high temperature protection error.",
6: "Power output high current protection error.",
7: "Power output high current protection error.",
8: "Power output high current protection error.",
9: "Power output high voltage protection error.",
},
4: {
0: "Power output low voltage protection error.",
1: "Power output current imbalance error.",
3: "Power input high temperature protection error.",
4: "Power input high temperature protection error.",
5: "Power input high temperature protection error.",
6: "Power input high voltage protection error.",
7: "Power input high voltage protection error.",
8: "Power input high current protection error.",
9: "Power input high current protection error.",
},
5: {
0: "Power input low voltage protection error.",
1: "Power input low voltage protection error.",
3: "Power supply fan error.",
4: "Power supply fan error.",
5: "Power output high power protection error.",
6: "Power output high power protection error.",
7: "Input over current protection of power supply on primary side.",
},
6: {
3: "Power communication warning.",
4: "Power communication error.",
7: "Power watchdog protection.",
8: "Power output high current protection.",
9: "Power input high current protection.",
},
7: {
0: "Power input high voltage protection.",
1: "Power input low voltage protection.",
2: "Excessive power supply output warning.",
3: "Power input too high warning.",
4: "Power fan warning.",
5: "Power high temperature warning.",
},
},
3: { # temperature error
0: { # sensor detection error
"n": "Slot {n} temperature sensor detection error."
},
2: { # temperature reading error
"n": "Slot {n} temperature reading error.",
9: "Control board temperature sensor communication error.",
},
5: {"n": "Slot {n} temperature protecting."}, # temperature protection
6: {0: "Hashboard high temperature error."}, # high temp
},
4: { # EEPROM error
1: {"n": "Slot {n} eeprom detection error."}, # EEPROM detection error
2: {"n": "Slot {n} eeprom parsing error."}, # EEPROM parsing error
3: {"n": "Slot {n} chip bin type error."}, # chip bin error
4: {"n": "Slot {n} eeprom chip number X error."}, # EEPROM chip number error
5: {"n": "Slot {n} eeprom xfer error."}, # EEPROM xfer error
},
5: { # hashboard error
1: {"n": "Slot {n} miner type error."}, # board miner type error
2: {"n": "Slot {n} bin type error."}, # chip bin type error
3: {"n": "Slot {n} not found."}, # board not found error
4: {"n": "Slot {n} error reading chip id."}, # reading chip id error
5: {"n": "Slot {n} has bad chips."}, # board has bad chips error
6: {"n": "Slot {n} loss of balance error."}, # loss of balance error
},
6: { # env temp error
0: {0: "Environment temperature is too high."}, # normal env temp error
1: { # high power env temp error
0: "Environment temperature is too high for high performance mode."
},
},
7: { # control board error
0: {1: "Control board no support chip."},
1: {
0: "Control board rebooted as an exception.",
2: "Control board rebooted as an exception.",
},
},
8: { # checksum error
0: {
0: "CGMiner checksum error.",
1: "System monitor checksum error.",
2: "Remote daemon checksum error.",
}
},
20: { # pool error
1: {0: "All pools are disabled."}, # all disabled error
2: {"n": "Pool {n} connection failed."}, # pool connection failed error
3: {0: "High rejection rate on pool."}, # rejection rate error
4: { # asicboost not supported error
0: "The pool does not support asicboost mode."
},
},
23: { # hashrate error
1: {0: "Hashrate is too low."},
2: {0: "Hashrate is too low."},
3: {0: "Hashrate loss is too high."},
4: {0: "Hashrate loss is too high."},
},
50: { # water velocity error
7: {"n": "Slot {n} water velocity is abnormal."}, # abnormal water velocity
},
51: { # frequency error
7: {"n": "Slot {n} frequency up timeout."}, # frequency up timeout
},
84: {
1: {0: "Software version error."},
},
1000: {
0: {
1: "/antiv/signature illegal.",
2: "/antiv/dig/init.d illegal.",
3: "/antiv/dig/pf_partial.dig illegal.",
},
},
}

View File

@@ -13,6 +13,7 @@
# limitations under the License.
import logging
from pyasic.settings import PyasicSettings

View File

@@ -15,9 +15,10 @@
import ipaddress
from typing import Union
from pyasic.miners.base import BaseMiner, AnyMiner
from pyasic.miners.base import AnyMiner, BaseMiner
from pyasic.miners.miner_factory import MinerFactory
# 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)

View File

@@ -14,16 +14,13 @@
import ipaddress
import logging
from typing import Union, List
from typing import List, Union
from pyasic.API.bmminer import BMMinerAPI
from pyasic.miners.base import BaseMiner
from pyasic.data import MinerData, HashBoard
from pyasic.config import MinerConfig
from pyasic.data import HashBoard, MinerData
from pyasic.data.error_codes import MinerErrorData
from pyasic.miners.base import BaseMiner
from pyasic.settings import PyasicSettings

View File

@@ -13,22 +13,19 @@
# limitations under the License.
import ipaddress
import logging
import json
from typing import Union, List
import logging
from typing import List, Union
import toml
import httpx
from pyasic.miners.base import BaseMiner
from pyasic.API.bosminer import BOSMinerAPI
from pyasic.errors import APIError
from pyasic.data.error_codes import BraiinsOSError, MinerErrorData
from pyasic.data import MinerData, HashBoard
from pyasic.config import MinerConfig
from pyasic.data import HashBoard, MinerData
from pyasic.data.error_codes import BraiinsOSError, MinerErrorData
from pyasic.errors import APIError
from pyasic.miners.base import BaseMiner
from pyasic.settings import PyasicSettings
@@ -69,6 +66,27 @@ class BOSMiner(BaseMiner):
# return the result, either command output or None
return str(result)
async def send_graphql_query(self, query) -> Union[dict, None]:
url = f"http://{self.ip}/graphql"
try:
async with httpx.AsyncClient() as client:
_auth = await client.post(
url,
json={
"query": 'mutation{auth{login(username:"'
+ self.uname
+ '", password:"'
+ self.pwd
+ '"){__typename}}}'
},
)
d = await client.post(url, json={"query": query})
if d.status_code == 200:
return d.json()
except (httpx.ReadError, httpx.ReadTimeout):
return None
return None
async def fault_light_on(self) -> bool:
"""Sends command to turn on fault light on the miner."""
logging.debug(f"{self}: Sending fault_light on command.")
@@ -152,6 +170,11 @@ class BOSMiner(BaseMiner):
"""
if self.hostname:
return self.hostname
# get hostname through GraphQL
if data := await self.send_graphql_query("{bos {hostname}}"):
self.hostname = data["data"]["bos"]["hostname"]
return self.hostname
try:
async with (await self._get_ssh_connection()) as conn:
if conn is not None:
@@ -215,9 +238,15 @@ class BOSMiner(BaseMiner):
if self.version:
logging.debug(f"Found version for {self.ip}: {self.version}")
return self.version
version_data = None
# try to get data from graphql
data = await self.send_graphql_query("{bos{info{version{full}}}}")
if data:
version_data = data["bos"]["info"]["version"]["full"]
# get output of bos version file
version_data = await self.send_ssh_command("cat /etc/bos_version")
if not version_data:
# try version data file
version_data = await self.send_ssh_command("cat /etc/bos_version")
# if we get the version data, parse it
if version_data:
@@ -248,6 +277,15 @@ class BOSMiner(BaseMiner):
async def check_light(self) -> bool:
if self.light:
return self.light
# get light through GraphQL
if data := await self.send_graphql_query("{bos {faultLight}}"):
try:
self.light = data["data"]["bos"]["faultLight"]
return self.light
except (TypeError, KeyError, ValueError, IndexError):
pass
# get light via ssh if that fails (10x slower)
data = (
await self.send_ssh_command("cat /sys/class/leds/'Red LED'/delay_off")
).strip()
@@ -289,6 +327,7 @@ class BOSMiner(BaseMiner):
if board["Status"] not in [
"Stable",
"Testing performance profile",
"Tuning individual chips"
]:
_error = board["Status"].split(" {")[0]
_error = _error[0].lower() + _error[1:]
@@ -303,6 +342,10 @@ class BOSMiner(BaseMiner):
Returns:
A [`MinerData`][pyasic.data.MinerData] instance containing the miners data.
"""
d = await self._graphql_get_data()
if d:
return d
data = MinerData(
ip=str(self.ip),
ideal_chips=self.nominal_chips * self.ideal_hashboards,
@@ -342,7 +385,7 @@ class BOSMiner(BaseMiner):
"devdetails",
"fans",
"devs",
allow_warning=allow_warning
allow_warning=allow_warning,
)
except APIError as e:
if str(e.message) == "Not ready":
@@ -441,7 +484,7 @@ class BOSMiner(BaseMiner):
wattage_limit = tuner[0].get("PowerLimit")
if wattage_limit:
data.wattage_limit = wattage_limit
if wattage:
if wattage is not None:
data.wattage = wattage
chain_status = tuner[0].get("TunerChainStatus")
@@ -493,6 +536,139 @@ class BOSMiner(BaseMiner):
data.hashboards[_id].hashrate = hashrate
return data
async def _graphql_get_data(self) -> Union[MinerData, None]:
data = MinerData(
ip=str(self.ip),
ideal_chips=self.nominal_chips * self.ideal_hashboards,
ideal_hashboards=self.ideal_hashboards,
hashboards=[
HashBoard(slot=i, expected_chips=self.nominal_chips, missing=True)
for i in range(self.ideal_hashboards)
],
)
query = "{bos {hostname}, bosminer{config{... on BosminerConfig{groups{pools{url, user}, strategy{... on QuotaStrategy {quota}}}}}, info{fans{name, rpm}, workSolver{realHashrate{mhs1M}, temperatures{degreesC}, power{limitW, approxConsumptionW}, childSolvers{name, realHashrate{mhs1M}, hwDetails{chips}, tuner{statusMessages}, temperatures{degreesC}}}}}}"
query_data = await self.send_graphql_query(query)
if not query_data:
return None
query_data = query_data["data"]
data.mac = await self.get_mac()
data.model = await self.get_model()
if query_data.get("bos"):
if query_data["bos"].get("hostname"):
data.hostname = query_data["bos"]["hostname"]
try:
if query_data["bosminer"]["info"]["workSolver"]["realHashrate"].get("mhs1M"):
data.hashrate = round(
query_data["bosminer"]["info"]["workSolver"]["realHashrate"]["mhs1M"]
/ 1000000,
2,
)
except (TypeError, KeyError, ValueError, IndexError):
pass
boards = None
if query_data.get("bosminer"):
if query_data["bosminer"].get("info"):
if query_data["bosminer"]["info"].get("workSolver"):
boards = query_data["bosminer"]["info"]["workSolver"].get("childSolvers")
if boards:
offset = 6 if int(boards[0]["name"]) in [6, 7, 8] else int(boards[0]["name"])
for hb in boards:
_id = int(hb["name"]) - offset
board = data.hashboards[_id]
board.hashrate = round(hb["realHashrate"]["mhs1M"] / 1000000, 2)
temps = hb["temperatures"]
try:
if len(temps) > 0:
board.temp = round(hb["temperatures"][0]["degreesC"])
if len(temps) > 1:
board.chip_temp = round(hb["temperatures"][1]["degreesC"])
except (TypeError, KeyError, ValueError, IndexError):
pass
details = hb.get("hwDetails")
if details:
if chips := details["chips"]:
board.chips = chips
board.missing = False
tuner = hb.get("tuner")
if tuner:
if msg := tuner.get("statusMessages"):
if len(msg) > 0:
if hb["tuner"]["statusMessages"][0] not in [
"Stable",
"Testing performance profile",
"Tuning individual chips"
]:
data.errors.append(
BraiinsOSError(f"Slot {_id} {hb['tuner']['statusMessages'][0]}")
)
try:
data.wattage = query_data["bosminer"]["info"]["workSolver"]["power"]["approxConsumptionW"]
except (TypeError, KeyError, ValueError, IndexError):
data.wattage = 0
try:
data.wattage_limit = query_data["bosminer"]["info"]["workSolver"]["power"]["limitW"]
except (TypeError, KeyError, ValueError, IndexError):
pass
for n in range(self.fan_count):
try:
setattr(data, f"fan_{n + 1}", query_data["bosminer"]["info"]["fans"][n]["rpm"])
except (TypeError, KeyError, ValueError, IndexError):
pass
groups = None
if query_data.get("bosminer"):
if query_data["bosminer"].get("config"):
groups = query_data["bosminer"]["config"].get("groups")
if groups:
if len(groups) == 1:
try:
data.pool_1_user = groups[0]["pools"][0]["user"]
except (TypeError, KeyError, ValueError, IndexError):
pass
try:
data.pool_1_url = groups[0]["pools"][0]["url"]
except (TypeError, KeyError, ValueError, IndexError):
pass
try:
data.pool_2_user = groups[0]["pools"][1]["user"]
except (TypeError, KeyError, ValueError, IndexError):
pass
try:
data.pool_2_url = groups[0]["pools"][1]["url"]
except (TypeError, KeyError, ValueError, IndexError):
pass
data.quota = 0
else:
try:
data.pool_1_user = groups[0]["pools"][0]["user"]
except (TypeError, KeyError, ValueError, IndexError):
pass
try:
data.pool_1_url = groups[0]["pools"][0]["url"]
except (TypeError, KeyError, ValueError, IndexError):
pass
try:
data.pool_2_user = groups[1]["pools"][0]["user"]
except (TypeError, KeyError, ValueError, IndexError):
pass
try:
data.pool_2_url = groups[1]["pools"][0]["url"]
except (TypeError, KeyError, ValueError, IndexError):
pass
if groups[0]["strategy"].get("quota"):
data.quota = groups[0]["strategy"]["quota"] + "/" + groups[1]["strategy"]["quota"]
data.fault_light = await self.check_light()
return data
async def get_mac(self):
result = await self.send_ssh_command("cat /sys/class/net/eth0/address")
return result.upper().strip()

View File

@@ -12,16 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import ipaddress
from typing import Union, List
import logging
from typing import List, Union
from pyasic.API.bosminer import BOSMinerAPI
from pyasic.miners.base import BaseMiner
from pyasic.config import MinerConfig
from pyasic.data import MinerData
from pyasic.data.error_codes import MinerErrorData
from pyasic.miners.base import BaseMiner
class BOSMinerOld(BaseMiner):

View File

@@ -14,17 +14,14 @@
import ipaddress
import logging
from typing import Union, List
from typing import List, Union
from pyasic.API.btminer import BTMinerAPI
from pyasic.miners.base import BaseMiner
from pyasic.errors import APIError
from pyasic.data import MinerData, HashBoard
from pyasic.data.error_codes import WhatsminerError, MinerErrorData
from pyasic.config import MinerConfig
from pyasic.data import HashBoard, MinerData
from pyasic.data.error_codes import MinerErrorData, WhatsminerError
from pyasic.errors import APIError
from pyasic.miners.base import BaseMiner
from pyasic.settings import PyasicSettings

View File

@@ -14,17 +14,14 @@
import ipaddress
import logging
from typing import Union, List
from typing import List, Union
from pyasic.API.cgminer import CGMinerAPI
from pyasic.miners.base import BaseMiner
from pyasic.errors import APIError
from pyasic.config import MinerConfig
from pyasic.data import MinerData, HashBoard
from pyasic.data import HashBoard, MinerData
from pyasic.data.error_codes import MinerErrorData
from pyasic.errors import APIError
from pyasic.miners.base import BaseMiner
from pyasic.settings import PyasicSettings

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from pyasic.miners._backends import BMMiner
import ipaddress
from pyasic.miners._backends import BMMiner
class Hiveon(BMMiner):
def __init__(self, ip: str) -> None:

View File

@@ -14,5 +14,5 @@
from .antminer import *
from .avalonminer import *
from .whatsminer import *
from .innosilicon import *
from .whatsminer import *

View File

@@ -16,7 +16,6 @@ from .S17 import S17
from .S17_Plus import S17Plus
from .S17_Pro import S17Pro
from .S17e import S17e
from .T17 import T17
from .T17_Plus import T17Plus
from .T17e import T17e

View File

@@ -14,12 +14,8 @@
from .S19 import S19
from .S19_Pro import S19Pro
from .S19_XP import S19XP
from .S19a import S19a
from .S19j import S19j
from .S19j_Pro import S19jPro
from .S19_XP import S19XP
from .S19a import S19a
from .T19 import T19

View File

@@ -15,7 +15,6 @@
from .M20 import M20, M20V10
from .M20S import M20S, M20SV10, M20SV20
from .M20S_Plus import M20SPlus
from .M21 import M21
from .M21S import M21S, M21SV20, M21SV60
from .M21S_Plus import M21SPlus

View File

@@ -12,26 +12,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .M30S import M30S, M30SVE10, M30SVE20, M30SVG20, M30SV50
from .M30S_Plus import M30SPlus, M30SPlusVG60, M30SPlusVE40, M30SPlusVF20
from .M30S import M30S, M30SV50, M30SVE10, M30SVE20, M30SVG20
from .M30S_Plus import M30SPlus, M30SPlusVE40, M30SPlusVF20, M30SPlusVG60
from .M30S_Plus_Plus import (
M30SPlusPlus,
M30SPlusPlusVG30,
M30SPlusPlusVG40,
M30SPlusPlusVH60,
)
from .M31S import M31S
from .M31S_Plus import (
M31SPlus,
M31SPlusVE20,
M31SPlusV30,
M31SPlusV40,
M31SPlusV80,
M31SPlusV60,
M31SPlusV80,
M31SPlusV90,
M31SPlusVE20,
)
from .M32 import M32, M32V20
from .M32S import M32S
from .M34S_Plus import M34SPlus, M34SPlusVE10

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .X17 import BMMinerX17
from pyasic.miners._types import S17 # noqa - Ignore access to _module
from .X17 import BMMinerX17
class BMMinerS17(BMMinerX17, S17):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .X17 import BMMinerX17
from pyasic.miners._types import S17Plus # noqa - Ignore access to _module
from .X17 import BMMinerX17
class BMMinerS17Plus(BMMinerX17, S17Plus):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .X17 import BMMinerX17
from pyasic.miners._types import S17Pro # noqa - Ignore access to _module
from .X17 import BMMinerX17
class BMMinerS17Pro(BMMinerX17, S17Pro):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .X17 import BMMinerX17
from pyasic.miners._types import S17e # noqa - Ignore access to _module
from .X17 import BMMinerX17
class BMMinerS17e(BMMinerX17, S17e):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .X17 import BMMinerX17
from pyasic.miners._types import T17 # noqa - Ignore access to _module
from .X17 import BMMinerX17
class BMMinerT17(BMMinerX17, T17):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .X17 import BMMinerX17
from pyasic.miners._types import T17Plus # noqa - Ignore access to _module
from .X17 import BMMinerX17
class BMMinerT17Plus(BMMinerX17, T17Plus):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .X17 import BMMinerX17
from pyasic.miners._types import T17e # noqa - Ignore access to _module
from .X17 import BMMinerX17
class BMMinerT17e(BMMinerX17, T17e):
def __init__(self, ip: str) -> None:

View File

@@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from pyasic.miners._backends import BMMiner # noqa - Ignore access to _module
from pyasic.settings import PyasicSettings
from typing import Union
import httpx
from typing import Union
from pyasic.miners._backends import BMMiner # noqa - Ignore access to _module
from pyasic.settings import PyasicSettings
class BMMinerX17(BMMiner):

View File

@@ -16,7 +16,6 @@ from .S17 import BMMinerS17
from .S17_Plus import BMMinerS17Plus
from .S17_Pro import BMMinerS17Pro
from .S17e import BMMinerS17e
from .T17 import BMMinerT17
from .T17_Plus import BMMinerT17Plus
from .T17e import BMMinerT17e

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .X19 import BMMinerX19
from pyasic.miners._types import S19 # noqa - Ignore access to _module
from .X19 import BMMinerX19
class BMMinerS19(BMMinerX19, S19):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .X19 import BMMinerX19
from pyasic.miners._types import S19Pro # noqa - Ignore access to _module
from .X19 import BMMinerX19
class BMMinerS19Pro(BMMinerX19, S19Pro):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .X19 import BMMinerX19
from pyasic.miners._types import S19XP # noqa - Ignore access to _module
from .X19 import BMMinerX19
class BMMinerS19XP(BMMinerX19, S19XP):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .X19 import BMMinerX19
from pyasic.miners._types import S19a # noqa - Ignore access to _module
from .X19 import BMMinerX19
class BMMinerS19a(BMMinerX19, S19a):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .X19 import BMMinerX19
from pyasic.miners._types import S19j # noqa - Ignore access to _module
from .X19 import BMMinerX19
class BMMinerS19j(BMMinerX19, S19j):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .X19 import BMMinerX19
from pyasic.miners._types import S19jPro # noqa - Ignore access to _module
from .X19 import BMMinerX19
class BMMinerS19jPro(BMMinerX19, S19jPro):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .X19 import BMMinerX19
from pyasic.miners._types import T19 # noqa - Ignore access to _module
from .X19 import BMMinerX19
class BMMinerT19(BMMinerX19, T19):
def __init__(self, ip: str) -> None:

View File

@@ -12,16 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from pyasic.miners._backends import BMMiner # noqa - Ignore access to _module
from pyasic.config import MinerConfig
from pyasic.data.error_codes import X19Error, MinerErrorData
from pyasic.settings import PyasicSettings
import asyncio
import json
from typing import List, Union
import httpx
import json
import asyncio
from typing import Union, List
from pyasic.config import MinerConfig
from pyasic.data.error_codes import MinerErrorData, X19Error
from pyasic.miners._backends import BMMiner # noqa - Ignore access to _module
from pyasic.settings import PyasicSettings
class BMMinerX19(BMMiner):

View File

@@ -14,12 +14,8 @@
from .S19 import BMMinerS19
from .S19_Pro import BMMinerS19Pro
from .S19_XP import BMMinerS19XP
from .S19a import BMMinerS19a
from .S19j import BMMinerS19j
from .S19j_Pro import BMMinerS19jPro
from .S19_XP import BMMinerS19XP
from .S19a import BMMinerS19a
from .T19 import BMMinerT19

View File

@@ -16,7 +16,6 @@ from .S17 import BOSMinerS17
from .S17_Plus import BOSMinerS17Plus
from .S17_Pro import BOSMinerS17Pro
from .S17e import BOSMinerS17e
from .T17 import BOSMinerT17
from .T17_Plus import BOSMinerT17Plus
from .T17e import BOSMinerT17e

View File

@@ -14,8 +14,6 @@
from .S19 import BOSMinerS19
from .S19_Pro import BOSMinerS19Pro
from .S19j import BOSMinerS19j
from .S19j_Pro import BOSMinerS19jPro
from .T19 import BOSMinerT19

View File

@@ -16,7 +16,6 @@ from .S17 import CGMinerS17
from .S17_Plus import CGMinerS17Plus
from .S17_Pro import CGMinerS17Pro
from .S17e import CGMinerS17e
from .T17 import CGMinerT17
from .T17_Plus import CGMinerT17Plus
from .T17e import CGMinerT17e

View File

@@ -14,8 +14,6 @@
from .S19 import CGMinerS19
from .S19_Pro import CGMinerS19Pro
from .S19j import CGMinerS19j
from .S19j_Pro import CGMinerS19jPro
from .T19 import CGMinerT19

View File

@@ -12,10 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from pyasic.data import HashBoard, MinerData
from pyasic.miners._backends import Hiveon # noqa - Ignore access to _module
from pyasic.miners._types import T9 # noqa - Ignore access to _module
from pyasic.data import MinerData, HashBoard
from pyasic.settings import PyasicSettings

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .A10X import CGMinerA10X
from pyasic.miners._types import Avalon1026 # noqa - Ignore access to _module
from .A10X import CGMinerA10X
class CGMinerAvalon1026(CGMinerA10X, Avalon1026):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .A10X import CGMinerA10X
from pyasic.miners._types import Avalon1047 # noqa - Ignore access to _module
from .A10X import CGMinerA10X
class CGMinerAvalon1047(CGMinerA10X, Avalon1047):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .A10X import CGMinerA10X
from pyasic.miners._types import Avalon1066 # noqa - Ignore access to _module
from .A10X import CGMinerA10X
class CGMinerAvalon1066(CGMinerA10X, Avalon1066):
def __init__(self, ip: str) -> None:

View File

@@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from pyasic.miners._backends import CGMiner # noqa - Ignore access to _module
from pyasic.data import MinerData, HashBoard
from pyasic.settings import PyasicSettings
import re
from pyasic.config import MinerConfig
import logging
import re
from pyasic.config import MinerConfig
from pyasic.data import HashBoard, MinerData
from pyasic.miners._backends import CGMiner # noqa - Ignore access to _module
from pyasic.settings import PyasicSettings
class CGMinerA10X(CGMiner):

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .A7X import CGMinerA7X # noqa - Ignore access to _module
from pyasic.miners._types import Avalon721 # noqa - Ignore access to _module
from .A7X import CGMinerA7X # noqa - Ignore access to _module
class CGMinerAvalon721(CGMinerA7X, Avalon721):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .A7X import CGMinerA7X # noqa - Ignore access to _module
from pyasic.miners._types import Avalon741 # noqa - Ignore access to _module
from .A7X import CGMinerA7X # noqa - Ignore access to _module
class CGMinerAvalon741(CGMinerA7X, Avalon741):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .A7X import CGMinerA7X # noqa - Ignore access to _module
from pyasic.miners._types import Avalon761 # noqa - Ignore access to _module
from .A7X import CGMinerA7X # noqa - Ignore access to _module
class CGMinerAvalon761(CGMinerA7X, Avalon761):
def __init__(self, ip: str) -> None:

View File

@@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from pyasic.miners._backends import CGMiner # noqa - Ignore access to _module
from pyasic.data import MinerData, HashBoard
from pyasic.settings import PyasicSettings
import re
from pyasic.config import MinerConfig
import logging
import re
from pyasic.config import MinerConfig
from pyasic.data import HashBoard, MinerData
from pyasic.miners._backends import CGMiner # noqa - Ignore access to _module
from pyasic.settings import PyasicSettings
class CGMinerA7X(CGMiner):

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .A8X import CGMinerA8X # noqa - Ignore access to _module
from pyasic.miners._types import Avalon821 # noqa - Ignore access to _module
from .A8X import CGMinerA8X # noqa - Ignore access to _module
class CGMinerAvalon821(CGMinerA8X, Avalon821):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .A8X import CGMinerA8X # noqa - Ignore access to _module
from pyasic.miners._types import Avalon841 # noqa - Ignore access to _module
from .A8X import CGMinerA8X # noqa - Ignore access to _module
class CGMinerAvalon841(CGMinerA8X, Avalon841):
def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .A8X import CGMinerA8X # noqa - Ignore access to _module
from pyasic.miners._types import Avalon851 # noqa - Ignore access to _module
from .A8X import CGMinerA8X # noqa - Ignore access to _module
class CGMinerAvalon851(CGMinerA8X, Avalon851):
def __init__(self, ip: str) -> None:

View File

@@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from pyasic.miners._backends import CGMiner # noqa - Ignore access to _module
from pyasic.data import MinerData, HashBoard
from pyasic.settings import PyasicSettings
import re
from pyasic.config import MinerConfig
import logging
import re
from pyasic.config import MinerConfig
from pyasic.data import HashBoard, MinerData
from pyasic.miners._backends import CGMiner # noqa - Ignore access to _module
from pyasic.settings import PyasicSettings
class CGMinerA8X(CGMiner):

View File

@@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import re
from pyasic.config import MinerConfig
from pyasic.data import HashBoard, MinerData
from pyasic.miners._backends import CGMiner # noqa - Ignore access to _module
from pyasic.miners._types import Avalon921 # noqa - Ignore access to _module
from pyasic.data import MinerData, HashBoard
from pyasic.settings import PyasicSettings
import re
from pyasic.config import MinerConfig
import logging
class CGMinerAvalon921(CGMiner, Avalon921):

View File

@@ -12,20 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import asyncssh
import logging
import ipaddress
import logging
from abc import ABC, abstractmethod
from typing import TypeVar, List, Union
from typing import List, TypeVar, Union
import asyncssh
from pyasic.data import MinerData
from pyasic.config import MinerConfig
from pyasic.data import MinerData
from pyasic.data.error_codes import (
WhatsminerError,
BraiinsOSError,
InnosiliconError,
X19Error,
MinerErrorData,
WhatsminerError,
X19Error,
)
@@ -51,7 +52,7 @@ class BaseMiner(ABC):
return object.__new__(cls)
def __repr__(self):
return f"{'' if not self.api_type else self.api_type} {'' if not self.model else self.model}: {str(self.ip)}"
return f"{'' if not self.api_type else self.api_type}{'' if not self.model else ' ' + self.model}: {str(self.ip)}"
def __lt__(self, other):
return ipaddress.ip_address(self.ip) < ipaddress.ip_address(other.ip)

View File

@@ -12,18 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from pyasic.miners._backends import CGMiner # noqa - Ignore access to _module
from pyasic.miners._types import InnosiliconT3HPlus # noqa - Ignore access to _module
from pyasic.data import MinerData, HashBoard
from pyasic.data.error_codes import InnosiliconError, MinerErrorData
from pyasic.settings import PyasicSettings
from pyasic.config import MinerConfig
from pyasic.errors import APIError
import logging
import warnings
from typing import List, Union
import httpx
import warnings
from typing import Union, List
import logging
from pyasic.config import MinerConfig
from pyasic.data import HashBoard, MinerData
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
class CGMinerInnosiliconT3HPlus(CGMiner, InnosiliconT3HPlus):

View File

@@ -12,38 +12,32 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Tuple, List, Union
from collections.abc import AsyncIterable
from pyasic.miners.base import AnyMiner
import httpx
from pyasic.miners.antminer import *
from pyasic.miners.avalonminer import *
from pyasic.miners.whatsminer import *
from pyasic.miners.innosilicon import *
from pyasic.miners._backends.cgminer import CGMiner # noqa - Ignore _module import
from pyasic.miners._backends.bmminer import BMMiner # noqa - Ignore _module import
from pyasic.miners._backends.bosminer import BOSMiner # noqa - Ignore _module import
from pyasic.miners._backends.btminer import BTMiner # noqa - Ignore _module import
from pyasic.miners._backends.bosminer_old import ( # noqa - Ignore _module import
BOSMinerOld,
)
from pyasic.miners.unknown import UnknownMiner
from pyasic.errors import APIError
from pyasic.misc import Singleton
import asyncio
import ipaddress
import json
import logging
from pyasic.settings import PyasicSettings
from collections.abc import AsyncIterable
from typing import List, Tuple, Union
import asyncssh
import httpx
from pyasic.errors import APIError
from pyasic.miners._backends.bmminer import BMMiner # noqa - Ignore _module import
from pyasic.miners._backends.bosminer import BOSMiner # noqa - Ignore _module import
from pyasic.miners._backends.bosminer_old import ( # noqa - Ignore _module import
BOSMinerOld,
)
from pyasic.miners._backends.btminer import BTMiner # noqa - Ignore _module import
from pyasic.miners._backends.cgminer import CGMiner # noqa - Ignore _module import
from pyasic.miners.antminer import *
from pyasic.miners.avalonminer import *
from pyasic.miners.base import AnyMiner
from pyasic.miners.innosilicon import *
from pyasic.miners.unknown import UnknownMiner
from pyasic.miners.whatsminer import *
from pyasic.misc import Singleton
from pyasic.settings import PyasicSettings
MINER_CLASSES = {
"ANTMINER S9": {
@@ -343,7 +337,6 @@ class MinerFactory(metaclass=Singleton):
break
except asyncio.TimeoutError:
logging.warning(f"{ip}: Get Miner Timed Out")
miner = self._select_miner_from_classes(ip, model, api, ver)
# save the miner to the cache at its IP if its not unknown
@@ -418,7 +411,9 @@ class MinerFactory(metaclass=Singleton):
# miner refused connection on API port, we wont be able to get data this way
# try ssh
try:
_model = await self.__get_model_from_ssh(ip)
_model = await self.__get_model_from_graphql(ip)
if not _model:
_model = await self.__get_model_from_ssh(ip)
if _model:
model = _model
api = "BOSMiner+"
@@ -446,15 +441,42 @@ class MinerFactory(metaclass=Singleton):
break
except KeyError:
continue
try:
if devdetails[0]["STATUS"][0]["Msg"]:
model = await self.__get_model_from_graphql(ip)
if model:
api = "BOSMiner+"
except (KeyError, TypeError, ValueError, IndexError):
pass
if not model:
# braiins OS bug check just in case
if "s9" in devdetails["STATUS"][0]["Description"]:
model = "ANTMINER S9"
if "s17" in version["STATUS"][0]["Description"]:
model = "ANTMINER S17"
if not api:
if "boser" in version["STATUS"][0]["Description"]:
api = "BOSMiner+"
else:
try:
_model = await self.__get_model_from_graphql(ip)
if _model:
model = _model
api = "BOSMiner+"
except (KeyError, TypeError, ValueError, IndexError):
pass
# if we have version we can get API type from here
if version:
try:
if version[0]["STATUS"][0]["Msg"]:
model = await self.__get_model_from_graphql(ip)
if model:
api = "BOSMiner+"
return model, api, ver
except (KeyError, TypeError, ValueError, IndexError):
pass
if "VERSION" in version:
api_types = ["BMMiner", "CGMiner", "BTMiner"]
# check basic API types, BOSMiner needs a special check
@@ -470,6 +492,8 @@ class MinerFactory(metaclass=Singleton):
api = "BOSMiner+"
if "BOSminer+" in version["VERSION"][0]:
api = "BOSMiner+"
if any("BOSer" in string for string in version["VERSION"][0]):
api = "BOSMiner+"
# check for avalonminers
for _version_key in ["PROD", "MODEL"]:
@@ -533,7 +557,6 @@ class MinerFactory(metaclass=Singleton):
# don't need "Bitmain", just "ANTMINER XX" as model
if "BITMAIN " in model:
model = model.replace("BITMAIN ", "")
return model, api, ver
async def __get_devdetails_and_version(
@@ -546,6 +569,11 @@ class MinerFactory(metaclass=Singleton):
# validate success
validation = await self._validate_command(data)
if not validation[0]:
try:
if data["version"][0]["STATUS"][0]["Msg"] == "Disconnected":
return data["devdetails"], data["version"]
except KeyError:
pass
raise APIError(validation[1])
# copy each part of the main command to devdetails and version
devdetails = data["devdetails"][0]
@@ -593,6 +621,16 @@ class MinerFactory(metaclass=Singleton):
model = "ANTMINER S17"
return model
@staticmethod
async def __get_model_from_graphql(ip: ipaddress.ip_address) -> Union[str, None]:
model = None
url = f"http://{ip}/graphql"
async with httpx.AsyncClient() as client:
d = await client.post(url, json={"query": "{bosminer {info{modelName}}}"})
if d.status_code == 200:
model = (d.json()["data"]["bosminer"]["info"]["modelName"]).upper()
return model
@staticmethod
async def __get_system_info_from_web(ip) -> dict:
url = f"http://{ip}/cgi-bin/get_system_info.cgi"

View File

@@ -15,10 +15,10 @@
from typing import List
from pyasic.API.unknown import UnknownAPI
from pyasic.miners.base import BaseMiner
from pyasic.config import MinerConfig
from pyasic.data import MinerData
from pyasic.data.error_codes import MinerErrorData
from pyasic.miners.base import BaseMiner
class UnknownMiner(BaseMiner):
@@ -72,5 +72,5 @@ class UnknownMiner(BaseMiner):
async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None:
return None
async def get_data(self, _) -> MinerData:
async def get_data(self, allow_warning: bool = False) -> MinerData:
return MinerData(ip=str(self.ip))

View File

@@ -13,10 +13,7 @@
# limitations under the License.
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import ( # noqa - Ignore access to _module
M20,
M20V10,
)
from pyasic.miners._types import M20, M20V10 # noqa - Ignore access to _module
class BTMinerM20(BTMiner, M20):

View File

@@ -13,11 +13,11 @@
# limitations under the License.
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import (
from pyasic.miners._types import ( # noqa - Ignore access to _module
M21S,
M21SV20,
M21SV60,
) # noqa - Ignore access to _module
)
class BTMinerM21S(BTMiner, M21S):

View File

@@ -15,7 +15,6 @@
from .M20 import BTMinerM20, BTMinerM20V10
from .M20S import BTMinerM20S, BTMinerM20SV10, BTMinerM20SV20
from .M20S_Plus import BTMinerM20SPlus
from .M21 import BTMinerM21
from .M21S import BTMinerM21S, BTMinerM21SV20, BTMinerM21SV60
from .M21S_Plus import BTMinerM21SPlus

View File

@@ -13,13 +13,13 @@
# limitations under the License.
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import (
from pyasic.miners._types import ( # noqa - Ignore access to _module
M30S,
M30SV50,
M30SVG20,
M30SVE20,
M30SVE10,
) # noqa - Ignore access to _module
M30SVE20,
M30SVG20,
)
class BTMinerM30S(BTMiner, M30S):

View File

@@ -13,12 +13,12 @@
# limitations under the License.
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import (
from pyasic.miners._types import ( # noqa - Ignore access to _module
M30SPlus,
M30SPlusVE40,
M30SPlusVF20,
M30SPlusVG60,
) # noqa - Ignore access to _module
)
class BTMinerM30SPlus(BTMiner, M30SPlus):

View File

@@ -15,8 +15,8 @@
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import ( # noqa - Ignore access to _module
M30SPlusPlus,
M30SPlusPlusVG40,
M30SPlusPlusVG30,
M30SPlusPlusVG40,
M30SPlusPlusVH60,
)

View File

@@ -13,15 +13,15 @@
# limitations under the License.
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import (
from pyasic.miners._types import ( # noqa - Ignore access to _module
M31SPlus,
M31SPlusVE20,
M31SPlusV30,
M31SPlusV40,
M31SPlusV60,
M31SPlusV80,
M31SPlusV90,
) # noqa - Ignore access to _module
M31SPlusVE20,
)
class BTMinerM31SPlus(BTMiner, M31SPlus):

View File

@@ -13,9 +13,7 @@
# limitations under the License.
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import (
M32S,
) # noqa - Ignore access to _module
from pyasic.miners._types import M32S # noqa - Ignore access to _module
class BTMinerM32S(BTMiner, M32S):

View File

@@ -13,10 +13,10 @@
# limitations under the License.
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import (
from pyasic.miners._types import ( # noqa - Ignore access to _module
M34SPlus,
M34SPlusVE10,
) # noqa - Ignore access to _module
)
class BTMinerM34SPlus(BTMiner, M34SPlus):

View File

@@ -14,35 +14,33 @@
from .M30S import (
BTMinerM30S,
BTMinerM30SV50,
BTMinerM30SVE10,
BTMinerM30SVE20,
BTMinerM30SVG20,
BTMinerM30SV50,
)
from .M30S_Plus import (
BTMinerM30SPlus,
BTMinerM30SPlusVF20,
BTMinerM30SPlusVE40,
BTMinerM30SPlusVF20,
BTMinerM30SPlusVG60,
)
from .M30S_Plus_Plus import (
BTMinerM30SPlusPlus,
BTMinerM30SPlusPlusVG40,
BTMinerM30SPlusPlusVG30,
BTMinerM30SPlusPlusVG40,
BTMinerM30SPlusPlusVH60,
)
from .M31S import BTMinerM31S
from .M31S_Plus import (
BTMinerM31SPlus,
BTMinerM31SPlusVE20,
BTMinerM31SPlusV30,
BTMinerM31SPlusV40,
BTMinerM31SPlusV60,
BTMinerM31SPlusV80,
BTMinerM31SPlusV90,
BTMinerM31SPlusVE20,
)
from .M32 import BTMinerM32, BTMinerM32V20
from .M32S import BTMinerM32S
from .M34S_Plus import BTMinerM34SPlus, BTMinerM34SPlusVE10

View File

@@ -12,7 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .M50 import (
BTMinerM50,
BTMinerM50VH50,
)
from .M50 import BTMinerM50, BTMinerM50VH50

View File

@@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import ipaddress
import asyncio
import ipaddress
import logging
from typing import Union, List, AsyncIterator
from typing import AsyncIterator, List, Union
from pyasic.miners.miner_factory import AnyMiner, MinerFactory
from pyasic.network.net_range import MinerNetworkRange
from pyasic.miners.miner_factory import MinerFactory, AnyMiner
from pyasic.settings import PyasicSettings

View File

@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Union
import ipaddress
from typing import Union
class MinerNetworkRange:

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyasic"
version = "0.20.0"
version = "0.21.12"
description = "A set of modules for interfacing with many common types of ASIC bitcoin miners, using both their API and SSH."
authors = ["UpstreamData <brett@upstreamdata.ca>"]
repository = "https://github.com/UpstreamData/pyasic"
@@ -20,6 +20,7 @@ optional = true
[tool.poetry.group.dev.dependencies]
pre-commit = "^2.20.0"
isort = "^5.10.1"
[tool.poetry.group.docs]
optional = true
@@ -32,3 +33,6 @@ mkdocstrings = {extras = ["python"], version = "^0.19.0"}
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.isort]
profile = "black"

View File

@@ -13,9 +13,10 @@
# limitations under the License.
import unittest
from tests.miners_tests import MinersTest, MinerFactoryTest
from tests.network_tests import NetworkTest
from tests.config_tests import ConfigTest
from tests.miners_tests import MinerFactoryTest, MinersTest
from tests.network_tests import NetworkTest
if __name__ == "__main__":
# `coverage run --source pyasic -m unittest discover` will give code coverage data

View File

@@ -13,14 +13,15 @@
# limitations under the License.
import unittest
from pyasic.config import MinerConfig, _PoolGroup, _Pool # noqa
from tests.test_data import (
bosminer_api_pools,
bosminer_config_pools,
x19_api_pools,
x19_web_pools,
bosminer_config_pools,
)
from pyasic.config import MinerConfig, _Pool, _PoolGroup # noqa
class ConfigTest(unittest.TestCase):
def setUp(self) -> None:

View File

@@ -11,18 +11,15 @@
# 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 unittest
from pyasic.miners.miner_factory import MINER_CLASSES
from pyasic.miners.base import BaseMiner
from pyasic.miners._backends import CGMiner
from pyasic.miners.miner_factory import MinerFactory
from pyasic.miners.miner_listener import MinerListener
import asyncio
import inspect
import sys
import unittest
from pyasic.miners._backends import CGMiner
from pyasic.miners.base import BaseMiner
from pyasic.miners.miner_factory import MINER_CLASSES, MinerFactory
from pyasic.miners.miner_listener import MinerListener
class MinersTest(unittest.TestCase):

View File

@@ -15,8 +15,8 @@
import ipaddress
import unittest
from pyasic.network.net_range import MinerNetworkRange
from pyasic.network import MinerNetwork
from pyasic.network.net_range import MinerNetworkRange
class NetworkTest(unittest.TestCase):