Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62238192ce | ||
|
|
1997003643 | ||
|
|
3a81844898 | ||
|
|
0ac80fb205 | ||
|
|
9494018c12 | ||
|
|
0bc86c98c5 | ||
|
|
f0d69c9ca7 | ||
|
|
b81590bd2e | ||
|
|
a53e01df6f | ||
|
|
f63e063954 | ||
|
|
9cbaf7076a | ||
|
|
daa5ac5870 |
25
pyasic/data/error_codes/X19.py
Normal file
25
pyasic/data/error_codes/X19.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# 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 dataclasses import dataclass, asdict
|
||||
|
||||
|
||||
@dataclass
|
||||
class X19Error:
|
||||
"""A Dataclass to handle error codes of X19 miners."""
|
||||
|
||||
error_message: str
|
||||
|
||||
def asdict(self):
|
||||
return asdict(self)
|
||||
@@ -14,3 +14,4 @@
|
||||
|
||||
from .whatsminer import WhatsminerError
|
||||
from .bos import BraiinsOSError
|
||||
from .X19 import X19Error
|
||||
|
||||
@@ -112,5 +112,8 @@ class BaseMiner:
|
||||
async def get_mac(self):
|
||||
return None
|
||||
|
||||
async def get_errors(self):
|
||||
return None
|
||||
|
||||
async def get_data(self) -> MinerData:
|
||||
return MinerData(ip=str(self.ip))
|
||||
|
||||
@@ -168,6 +168,7 @@ class BMMiner(BaseMiner):
|
||||
model = await self.get_model()
|
||||
hostname = await self.get_hostname()
|
||||
mac = await self.get_mac()
|
||||
errors = await self.get_errors()
|
||||
|
||||
if model:
|
||||
data.model = model
|
||||
@@ -178,6 +179,10 @@ class BMMiner(BaseMiner):
|
||||
if mac:
|
||||
data.mac = mac
|
||||
|
||||
if errors:
|
||||
for error in errors:
|
||||
data.errors.append(error)
|
||||
|
||||
data.fault_light = await self.check_light()
|
||||
|
||||
miner_data = None
|
||||
|
||||
@@ -15,11 +15,12 @@
|
||||
from pyasic.miners._backends import BMMiner # noqa - Ignore access to _module
|
||||
|
||||
from pyasic.config import MinerConfig
|
||||
from pyasic.data.error_codes import X19Error
|
||||
|
||||
import httpx
|
||||
import json
|
||||
import asyncio
|
||||
from typing import Union
|
||||
from typing import Union, List
|
||||
|
||||
|
||||
class BMMinerX19(BMMiner):
|
||||
@@ -131,3 +132,18 @@ class BMMinerX19(BMMiner):
|
||||
if data.status_code == 200:
|
||||
return True
|
||||
return False
|
||||
|
||||
async def get_errors(self) -> List[X19Error]:
|
||||
errors = []
|
||||
url = f"http://{self.ip}/cgi-bin/summary.cgi"
|
||||
auth = httpx.DigestAuth("root", "root")
|
||||
async with httpx.AsyncClient() as client:
|
||||
data = await client.get(url, auth=auth)
|
||||
if data:
|
||||
data = data.json()
|
||||
if "SUMMARY" in data.keys():
|
||||
if "status" in data["SUMMARY"][0].keys():
|
||||
for item in data["SUMMARY"][0]["status"]:
|
||||
if not item["status"] == "s":
|
||||
errors.append(X19Error(item["msg"]))
|
||||
return errors
|
||||
|
||||
@@ -68,7 +68,7 @@ MINER_CLASSES = {
|
||||
"BMMiner": BMMinerS17Plus,
|
||||
"CGMiner": CGMinerS17Plus,
|
||||
},
|
||||
"ANTMINER S17 Pro": {
|
||||
"ANTMINER S17 PRO": {
|
||||
"Default": BMMinerS17Pro,
|
||||
"BOSMiner+": BOSMinerS17Pro,
|
||||
"BMMiner": BMMinerS17Pro,
|
||||
@@ -104,7 +104,7 @@ MINER_CLASSES = {
|
||||
"BMMiner": BMMinerS19,
|
||||
"CGMiner": CGMinerS19,
|
||||
},
|
||||
"ANTMINER S19 Pro": {
|
||||
"ANTMINER S19 PRO": {
|
||||
"Default": BMMinerS19Pro,
|
||||
"BOSMiner+": BOSMinerS19Pro,
|
||||
"BMMiner": BMMinerS19Pro,
|
||||
@@ -116,7 +116,7 @@ MINER_CLASSES = {
|
||||
"BMMiner": BMMinerS19j,
|
||||
"CGMiner": CGMinerS19j,
|
||||
},
|
||||
"ANTMINER S19J Pro": {
|
||||
"ANTMINER S19J PRO": {
|
||||
"Default": BMMinerS19jPro,
|
||||
"BOSMiner+": BOSMinerS19jPro,
|
||||
"BMMiner": BMMinerS19jPro,
|
||||
@@ -533,6 +533,19 @@ class MinerFactory(metaclass=Singleton):
|
||||
elif "am2-s17" in version["STATUS"][0]["Description"]:
|
||||
model = "ANTMINER S17"
|
||||
|
||||
if not model:
|
||||
stats = await self._send_api_command(str(ip), "stats")
|
||||
if stats:
|
||||
if "STATS" in stats.keys():
|
||||
if stats["STATS"][0].get("Type"):
|
||||
_model = stats["STATS"][0]["Type"].upper()
|
||||
if " BB" in _model:
|
||||
_model = _model.split(" BB")[0]
|
||||
if " XILINX" in _model:
|
||||
_model = _model.split(" XILINX")[0]
|
||||
if "PRO" in _model and not " PRO" in _model:
|
||||
model = _model.replace("PRO", " PRO")
|
||||
|
||||
if model:
|
||||
# whatsminer have a V in their version string (M20SV41), remove everything after it
|
||||
if "V" in model:
|
||||
@@ -541,8 +554,8 @@ class MinerFactory(metaclass=Singleton):
|
||||
ver = model.split("V")[1]
|
||||
model = model.split("V")[0]
|
||||
# don't need "Bitmain", just "ANTMINER XX" as model
|
||||
if "Bitmain " in model:
|
||||
model = model.replace("Bitmain ", "")
|
||||
if "BITMAIN " in model:
|
||||
model = model.replace("BITMAIN ", "")
|
||||
return model, api, ver
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "pyasic"
|
||||
version = "0.14.1"
|
||||
version = "0.14.7"
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user