Compare commits

..

7 Commits

Author SHA1 Message Date
Upstream Data
74792771ec version: bump version number 2024-10-30 13:16:22 -06:00
Upstream Data
fa6e8a976d bug: fix iceriver userpanel parsing 2024-10-30 13:16:07 -06:00
James Hilliard
f20531cff5 Run pre-commit formatting on all files 2024-10-30 13:07:57 -06:00
Upstream Data
8b1cbed9ce version: bump version number. 2024-10-30 12:25:47 -06:00
Upstream Data
0194e13427 bug: update A11MX chip count 2024-10-30 12:25:32 -06:00
Upstream Data
82d71abf54 version: bump version number 2024-10-30 12:23:08 -06:00
Upstream Data
e71cfadf6e bug: add model parser into map for iceriver 2024-10-30 12:22:44 -06:00
22 changed files with 74 additions and 61 deletions

View File

@@ -23,13 +23,13 @@ from typing import Any, List, Union
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.pools import PoolMetrics
from .boards import HashBoard from .boards import HashBoard
from .device import DeviceInfo from .device import DeviceInfo
from .error_codes import BraiinsOSError, InnosiliconError, WhatsminerError, X19Error from .error_codes import BraiinsOSError, InnosiliconError, WhatsminerError, X19Error
from .fans import Fan from .fans import Fan
from .hashrate import AlgoHashRate, HashUnit from .hashrate import AlgoHashRate, HashUnit
from pyasic.data.pools import PoolMetrics
@dataclass @dataclass

View File

@@ -23,6 +23,7 @@ from .S19 import (
BMMinerS19j, BMMinerS19j,
BMMinerS19jNoPIC, BMMinerS19jNoPIC,
BMMinerS19jPro, BMMinerS19jPro,
BMMinerS19KPro,
BMMinerS19L, BMMinerS19L,
BMMinerS19Plus, BMMinerS19Plus,
BMMinerS19Pro, BMMinerS19Pro,
@@ -30,6 +31,5 @@ from .S19 import (
BMMinerS19ProPlus, BMMinerS19ProPlus,
BMMinerS19ProPlusHydro, BMMinerS19ProPlusHydro,
BMMinerS19XP, BMMinerS19XP,
BMMinerS19KPro,
) )
from .T19 import BMMinerT19 from .T19 import BMMinerT19

View File

@@ -15,7 +15,4 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from .S21 import ePICS21, ePICS21Pro from .S21 import ePICS21, ePICS21Pro
from .T21 import ePICT21
from .T21 import (
ePICT21,
)

View File

@@ -193,7 +193,14 @@ class Auradine(StockFirmware):
for key in conf.keys(): for key in conf.keys():
await self.web.send_command(command=key, **conf[key]) await self.web.send_command(command=key, **conf[key])
async def upgrade_firmware(self, *, url: str = None, version: str = "latest", keep_settings: bool = False, **kwargs) -> bool: async def upgrade_firmware(
self,
*,
url: str = None,
version: str = "latest",
keep_settings: bool = False,
**kwargs,
) -> bool:
""" """
Upgrade the firmware of the Auradine device. Upgrade the firmware of the Auradine device.
@@ -209,7 +216,9 @@ class Auradine(StockFirmware):
logging.info("Starting firmware upgrade process.") logging.info("Starting firmware upgrade process.")
if not url and not version: if not url and not version:
raise ValueError("Either URL or version must be provided for firmware upgrade.") raise ValueError(
"Either URL or version must be provided for firmware upgrade."
)
if url: if url:
result = await self.web.firmware_upgrade(url=url) result = await self.web.firmware_upgrade(url=url)
@@ -220,11 +229,15 @@ class Auradine(StockFirmware):
logging.info("Firmware upgrade process completed successfully.") logging.info("Firmware upgrade process completed successfully.")
return True return True
else: else:
logging.error(f"Firmware upgrade failed: {result.get('error', 'Unknown error')}") logging.error(
f"Firmware upgrade failed: {result.get('error', 'Unknown error')}"
)
return False return False
except Exception as e: except Exception as e:
logging.error(f"An error occurred during the firmware upgrade process: {str(e)}") logging.error(
f"An error occurred during the firmware upgrade process: {str(e)}"
)
return False return False
################################################## ##################################################

View File

@@ -18,11 +18,11 @@ from typing import List, Optional
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
from pyasic.data import AlgoHashRate, Fan, HashBoard, HashUnit from pyasic.data import AlgoHashRate, Fan, HashBoard, HashUnit
from pyasic.data.pools import PoolMetrics, PoolUrl
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
from pyasic.miners.device.firmware import StockFirmware from pyasic.miners.device.firmware import StockFirmware
from pyasic.rpc.bfgminer import BFGMinerRPCAPI from pyasic.rpc.bfgminer import BFGMinerRPCAPI
from pyasic.data.pools import PoolMetrics, PoolUrl
BFGMINER_DATA_LOC = DataLocations( BFGMINER_DATA_LOC = DataLocations(
**{ **{
@@ -263,4 +263,4 @@ class BFGMiner(StockFirmware):
expected_rate, HashUnit.SHA256.from_str(rate_unit) expected_rate, HashUnit.SHA256.from_str(rate_unit)
).into(self.algo.unit.default) ).into(self.algo.unit.default)
except LookupError: except LookupError:
pass pass

View File

@@ -23,11 +23,11 @@ import aiofiles
from pyasic.config import MinerConfig, MiningModeConfig from pyasic.config import MinerConfig, MiningModeConfig
from pyasic.data import AlgoHashRate, Fan, HashBoard, HashUnit from pyasic.data import AlgoHashRate, Fan, HashBoard, HashUnit
from pyasic.data.error_codes import MinerErrorData, WhatsminerError from pyasic.data.error_codes import MinerErrorData, WhatsminerError
from pyasic.data.pools import PoolMetrics, PoolUrl
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
from pyasic.miners.device.firmware import StockFirmware from pyasic.miners.device.firmware import StockFirmware
from pyasic.rpc.btminer import BTMinerRPCAPI from pyasic.rpc.btminer import BTMinerRPCAPI
from pyasic.data.pools import PoolMetrics, PoolUrl
BTMINER_DATA_LOC = DataLocations( BTMINER_DATA_LOC = DataLocations(
**{ **{
@@ -113,7 +113,7 @@ BTMINER_DATA_LOC = DataLocations(
str(DataOptions.POOLS): DataFunction( str(DataOptions.POOLS): DataFunction(
"_get_pools", "_get_pools",
[RPCAPICommand("rpc_pools", "pools")], [RPCAPICommand("rpc_pools", "pools")],
) ),
} }
) )

View File

@@ -14,15 +14,15 @@
# limitations under the License. - # limitations under the License. -
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from typing import Optional, List from typing import List, Optional
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
from pyasic.data import AlgoHashRate, HashUnit from pyasic.data import AlgoHashRate, HashUnit
from pyasic.data.pools import PoolMetrics, PoolUrl
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
from pyasic.miners.device.firmware import StockFirmware from pyasic.miners.device.firmware import StockFirmware
from pyasic.rpc.cgminer import CGMinerRPCAPI from pyasic.rpc.cgminer import CGMinerRPCAPI
from pyasic.data.pools import PoolMetrics, PoolUrl
CGMINER_DATA_LOC = DataLocations( CGMINER_DATA_LOC = DataLocations(
**{ **{

View File

@@ -454,8 +454,9 @@ class ePIC(ePICFirmware):
except LookupError: except LookupError:
pass pass
async def upgrade_firmware(self, file: Path | str, keep_settings: bool = True) -> bool: async def upgrade_firmware(
self, file: Path | str, keep_settings: bool = True
) -> bool:
""" """
Upgrade the firmware of the ePIC miner device. Upgrade the firmware of the ePIC miner device.
@@ -466,4 +467,4 @@ class ePIC(ePICFirmware):
Returns: Returns:
bool: Whether the firmware update succeeded. bool: Whether the firmware update succeeded.
""" """
return await self.web.system_update(file=file, keep_settings=keep_settings) return await self.web.system_update(file=file, keep_settings=keep_settings)

View File

@@ -76,7 +76,7 @@ class IceRiver(StockFirmware):
if web_userpanel is not None: if web_userpanel is not None:
try: try:
return [Fan(spd) for spd in web_userpanel["fans"]] return [Fan(spd) for spd in web_userpanel["userpanel"]["data"]["fans"]]
except (LookupError, ValueError, TypeError): except (LookupError, ValueError, TypeError):
pass pass
@@ -89,7 +89,9 @@ class IceRiver(StockFirmware):
if web_userpanel is not None: if web_userpanel is not None:
try: try:
return web_userpanel["mac"].upper().replace("-", ":") return (
web_userpanel["userpanel"]["data"]["mac"].upper().replace("-", ":")
)
except (LookupError, ValueError, TypeError): except (LookupError, ValueError, TypeError):
pass pass
@@ -102,7 +104,7 @@ class IceRiver(StockFirmware):
if web_userpanel is not None: if web_userpanel is not None:
try: try:
return web_userpanel["host"] return web_userpanel["userpanel"]["data"]["host"]
except (LookupError, ValueError, TypeError): except (LookupError, ValueError, TypeError):
pass pass
@@ -115,9 +117,13 @@ class IceRiver(StockFirmware):
if web_userpanel is not None: if web_userpanel is not None:
try: try:
base_unit = web_userpanel["unit"] base_unit = web_userpanel["userpanel"]["data"]["unit"]
return AlgoHashRate.SHA256( return AlgoHashRate.SHA256(
float(web_userpanel["rtpow"].replace(base_unit, "")), float(
web_userpanel["userpanel"]["data"]["rtpow"].replace(
base_unit, ""
)
),
unit=MinerAlgo.SHA256.unit.from_str(base_unit + "H"), unit=MinerAlgo.SHA256.unit.from_str(base_unit + "H"),
).into(MinerAlgo.SHA256.unit.default) ).into(MinerAlgo.SHA256.unit.default)
except (LookupError, ValueError, TypeError): except (LookupError, ValueError, TypeError):
@@ -132,7 +138,7 @@ class IceRiver(StockFirmware):
if web_userpanel is not None: if web_userpanel is not None:
try: try:
return web_userpanel["locate"] return web_userpanel["userpanel"]["data"]["locate"]
except (LookupError, ValueError, TypeError): except (LookupError, ValueError, TypeError):
pass pass
return False return False
@@ -146,7 +152,7 @@ class IceRiver(StockFirmware):
if web_userpanel is not None: if web_userpanel is not None:
try: try:
return web_userpanel["powstate"] return web_userpanel["userpanel"]["data"]["powstate"]
except (LookupError, ValueError, TypeError): except (LookupError, ValueError, TypeError):
pass pass
@@ -164,7 +170,7 @@ class IceRiver(StockFirmware):
if web_userpanel is not None: if web_userpanel is not None:
try: try:
for board in web_userpanel["boards"]: for board in web_userpanel["userpanel"]["data"]["boards"]:
idx = int(board["no"] - 1) idx = int(board["no"] - 1)
hb_list[idx].chip_temp = round(board["outtmp"]) hb_list[idx].chip_temp = round(board["outtmp"])
hb_list[idx].temp = round(board["intmp"]) hb_list[idx].temp = round(board["intmp"])
@@ -186,7 +192,7 @@ class IceRiver(StockFirmware):
if web_userpanel is not None: if web_userpanel is not None:
try: try:
runtime = web_userpanel["runtime"] runtime = web_userpanel["userpanel"]["data"]["runtime"]
days, hours, minutes, seconds = runtime.split(":") days, hours, minutes, seconds = runtime.split(":")
return ( return (
(int(days) * 24 * 60 * 60) (int(days) * 24 * 60 * 60)

View File

@@ -13,8 +13,8 @@
# 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 typing import List, Optional
import logging import logging
from typing import List, Optional
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
from pyasic.data import AlgoHashRate, Fan, HashBoard, HashUnit from pyasic.data import AlgoHashRate, Fan, HashBoard, HashUnit

View File

@@ -3,13 +3,13 @@ from typing import List, Optional
from pyasic import MinerConfig from pyasic import MinerConfig
from pyasic.config import MiningModeConfig from pyasic.config import MiningModeConfig
from pyasic.data import AlgoHashRate, Fan, HashBoard, HashUnit from pyasic.data import AlgoHashRate, Fan, HashBoard, HashUnit
from pyasic.data.pools import PoolMetrics, PoolUrl
from pyasic.errors import APIError from pyasic.errors import APIError
from pyasic.miners.data import DataFunction, DataLocations, DataOptions, WebAPICommand from pyasic.miners.data import DataFunction, DataLocations, DataOptions, WebAPICommand
from pyasic.miners.device.firmware import MaraFirmware from pyasic.miners.device.firmware import MaraFirmware
from pyasic.misc import merge_dicts from pyasic.misc import merge_dicts
from pyasic.rpc.marathon import MaraRPCAPI from pyasic.rpc.marathon import MaraRPCAPI
from pyasic.web.marathon import MaraWebAPI from pyasic.web.marathon import MaraWebAPI
from pyasic.data.pools import PoolMetrics, PoolUrl
MARA_DATA_LOC = DataLocations( MARA_DATA_LOC = DataLocations(
**{ **{
@@ -319,10 +319,13 @@ class MaraMiner(MaraFirmware):
return [] return []
active_pool_index = None active_pool_index = None
highest_priority = float('inf') highest_priority = float("inf")
for pool_info in web_pools: for pool_info in web_pools:
if pool_info.get("status") == "Alive" and pool_info.get("priority", float('inf')) < highest_priority: if (
pool_info.get("status") == "Alive"
and pool_info.get("priority", float("inf")) < highest_priority
):
highest_priority = pool_info.get["priority"] highest_priority = pool_info.get["priority"]
active_pool_index = pool_info["index"] active_pool_index = pool_info["index"]

View File

@@ -560,7 +560,14 @@ class BaseMiner(MinerProtocol):
if self._ssh_cls is not None: if self._ssh_cls is not None:
self.ssh = self._ssh_cls(ip) self.ssh = self._ssh_cls(ip)
async def upgrade_firmware(self, *, file: str = None, url: str = None, version: str = None, keep_settings: bool = True) -> bool: async def upgrade_firmware(
self,
*,
file: str = None,
url: str = None,
version: str = None,
keep_settings: bool = True,
) -> bool:
"""Upgrade the firmware of the miner. """Upgrade the firmware of the miner.
Parameters: Parameters:
@@ -574,4 +581,5 @@ class BaseMiner(MinerProtocol):
""" """
return False return False
AnyMiner = TypeVar("AnyMiner", bound=BaseMiner) AnyMiner = TypeVar("AnyMiner", bound=BaseMiner)

View File

@@ -14,7 +14,4 @@
# limitations under the License. - # limitations under the License. -
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from .blockminer import ( from .blockminer import ePICBlockMiner520i, ePICBlockMiner720i
ePICBlockMiner520i,
ePICBlockMiner720i,
)

View File

@@ -43,4 +43,4 @@ class LuxOSFirmware(BaseMiner):
class MaraFirmware(BaseMiner): class MaraFirmware(BaseMiner):
firmware = MinerFirmware.MARATHON firmware = MinerFirmware.MARATHON

View File

@@ -21,3 +21,4 @@ class A11MX(InnosiliconMake):
raw_model = MinerModel.INNOSILICON.A11MX raw_model = MinerModel.INNOSILICON.A11MX
expected_hashboards = 4 expected_hashboards = 4
expected_chips = 8

View File

@@ -546,6 +546,7 @@ class MinerFactory:
MinerTypes.AURADINE: self.get_miner_model_auradine, MinerTypes.AURADINE: self.get_miner_model_auradine,
MinerTypes.MARATHON: self.get_miner_model_marathon, MinerTypes.MARATHON: self.get_miner_model_marathon,
MinerTypes.BITAXE: self.get_miner_model_bitaxe, MinerTypes.BITAXE: self.get_miner_model_bitaxe,
MinerTypes.ICERIVER: self.get_miner_model_iceriver,
} }
fn = miner_model_fns.get(miner_type) fn = miner_model_fns.get(miner_type)

View File

@@ -22,8 +22,8 @@ import hashlib
import json import json
import logging import logging
import re import re
from typing import Literal, Union
import struct import struct
from typing import Literal, Union
import httpx import httpx
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes

View File

@@ -757,4 +757,4 @@ class LUXMinerRPCAPI(BaseMinerRPCAPI):
Returns: Returns:
The response from the miner after sending the 'updaterun' command. The response from the miner after sending the 'updaterun' command.
""" """
return await self.send_command("updaterun") return await self.send_command("updaterun")

View File

@@ -17,10 +17,11 @@ from __future__ import annotations
import asyncio import asyncio
import json import json
from pathlib import Path
from typing import Any from typing import Any
import aiofiles import aiofiles
import httpx import httpx
from pathlib import Path
from pyasic import settings from pyasic import settings
from pyasic.web.base import BaseWebAPI from pyasic.web.base import BaseWebAPI
@@ -414,10 +415,7 @@ class AntminerOldWebAPI(BaseWebAPI):
parameters = { parameters = {
"file": (file.name, file_content, "application/octet-stream"), "file": (file.name, file_content, "application/octet-stream"),
"filename": file.name, "filename": file.name,
"keep_settings": keep_settings "keep_settings": keep_settings,
} }
return await self.send_command( return await self.send_command(command="upgrade", **parameters)
command="upgrade",
**parameters
)

View File

@@ -4,17 +4,12 @@
# This file has been @generated # This file has been @generated
from dataclasses import dataclass from dataclasses import dataclass
from typing import ( from typing import TYPE_CHECKING, Dict, Optional
TYPE_CHECKING,
Dict,
Optional,
)
import betterproto import betterproto
import grpclib import grpclib
from betterproto.grpc.grpclib_server import ServiceBase from betterproto.grpc.grpclib_server import ServiceBase
if TYPE_CHECKING: if TYPE_CHECKING:
import grpclib.server import grpclib.server
from betterproto.grpc.grpclib_client import MetadataLike from betterproto.grpc.grpclib_client import MetadataLike

View File

@@ -5,19 +5,12 @@
import warnings import warnings
from dataclasses import dataclass from dataclasses import dataclass
from datetime import datetime from datetime import datetime
from typing import ( from typing import TYPE_CHECKING, AsyncIterator, Dict, List, Optional
TYPE_CHECKING,
AsyncIterator,
Dict,
List,
Optional,
)
import betterproto import betterproto
import grpclib import grpclib
from betterproto.grpc.grpclib_server import ServiceBase from betterproto.grpc.grpclib_server import ServiceBase
if TYPE_CHECKING: if TYPE_CHECKING:
import grpclib.server import grpclib.server
from betterproto.grpc.grpclib_client import MetadataLike from betterproto.grpc.grpclib_client import MetadataLike

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "pyasic" name = "pyasic"
version = "0.61.6" version = "0.61.9"
description = "A simplified and standardized interface for Bitcoin ASICs." description = "A simplified and standardized interface for Bitcoin ASICs."
authors = ["UpstreamData <brett@upstreamdata.ca>"] authors = ["UpstreamData <brett@upstreamdata.ca>"]
repository = "https://github.com/UpstreamData/pyasic" repository = "https://github.com/UpstreamData/pyasic"