Compare commits

...

9 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
Upstream Data
18931c4e98 version: bump version number 2024-10-30 12:18:53 -06:00
Upstream Data
8622c080aa bug: fix inno pool parsing 2024-10-30 12:18:27 -06:00
23 changed files with 78 additions and 66 deletions

View File

@@ -23,13 +23,13 @@ from typing import Any, List, Union
from pyasic.config import MinerConfig
from pyasic.config.mining import MiningModePowerTune
from pyasic.data.pools import PoolMetrics
from .boards import HashBoard
from .device import DeviceInfo
from .error_codes import BraiinsOSError, InnosiliconError, WhatsminerError, X19Error
from .fans import Fan
from .hashrate import AlgoHashRate, HashUnit
from pyasic.data.pools import PoolMetrics
@dataclass

View File

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

View File

@@ -15,7 +15,4 @@
# ------------------------------------------------------------------------------
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():
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.
@@ -209,7 +216,9 @@ class Auradine(StockFirmware):
logging.info("Starting firmware upgrade process.")
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:
result = await self.web.firmware_upgrade(url=url)
@@ -220,11 +229,15 @@ class Auradine(StockFirmware):
logging.info("Firmware upgrade process completed successfully.")
return True
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
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
##################################################

View File

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

View File

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

View File

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

View File

@@ -454,8 +454,9 @@ class ePIC(ePICFirmware):
except LookupError:
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.
@@ -466,4 +467,4 @@ class ePIC(ePICFirmware):
Returns:
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:
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):
pass
@@ -89,7 +89,9 @@ class IceRiver(StockFirmware):
if web_userpanel is not None:
try:
return web_userpanel["mac"].upper().replace("-", ":")
return (
web_userpanel["userpanel"]["data"]["mac"].upper().replace("-", ":")
)
except (LookupError, ValueError, TypeError):
pass
@@ -102,7 +104,7 @@ class IceRiver(StockFirmware):
if web_userpanel is not None:
try:
return web_userpanel["host"]
return web_userpanel["userpanel"]["data"]["host"]
except (LookupError, ValueError, TypeError):
pass
@@ -115,9 +117,13 @@ class IceRiver(StockFirmware):
if web_userpanel is not None:
try:
base_unit = web_userpanel["unit"]
base_unit = web_userpanel["userpanel"]["data"]["unit"]
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"),
).into(MinerAlgo.SHA256.unit.default)
except (LookupError, ValueError, TypeError):
@@ -132,7 +138,7 @@ class IceRiver(StockFirmware):
if web_userpanel is not None:
try:
return web_userpanel["locate"]
return web_userpanel["userpanel"]["data"]["locate"]
except (LookupError, ValueError, TypeError):
pass
return False
@@ -146,7 +152,7 @@ class IceRiver(StockFirmware):
if web_userpanel is not None:
try:
return web_userpanel["powstate"]
return web_userpanel["userpanel"]["data"]["powstate"]
except (LookupError, ValueError, TypeError):
pass
@@ -164,7 +170,7 @@ class IceRiver(StockFirmware):
if web_userpanel is not None:
try:
for board in web_userpanel["boards"]:
for board in web_userpanel["userpanel"]["data"]["boards"]:
idx = int(board["no"] - 1)
hb_list[idx].chip_temp = round(board["outtmp"])
hb_list[idx].temp = round(board["intmp"])
@@ -186,7 +192,7 @@ class IceRiver(StockFirmware):
if web_userpanel is not None:
try:
runtime = web_userpanel["runtime"]
runtime = web_userpanel["userpanel"]["data"]["runtime"]
days, hours, minutes, seconds = runtime.split(":")
return (
(int(days) * 24 * 60 * 60)

View File

@@ -19,6 +19,7 @@ from pyasic.config import MinerConfig
from pyasic.data import AlgoHashRate, Fan, HashBoard, HashUnit
from pyasic.data.error_codes import MinerErrorData
from pyasic.data.error_codes.innosilicon import InnosiliconError
from pyasic.data.pools import PoolMetrics, PoolUrl
from pyasic.errors import APIError
from pyasic.miners.backends import CGMiner
from pyasic.miners.data import (
@@ -29,7 +30,6 @@ from pyasic.miners.data import (
WebAPICommand,
)
from pyasic.web.innosilicon import InnosiliconWebAPI
from pyasic.data.pools import PoolMetrics, PoolUrl
INNOSILICON_DATA_LOC = DataLocations(
**{
@@ -92,9 +92,8 @@ INNOSILICON_DATA_LOC = DataLocations(
[RPCAPICommand("rpc_stats", "stats")],
),
str(DataOptions.POOLS): DataFunction(
"_get_pools",
[RPCAPICommand("rpc_pools", "pools")]
)
"_get_pools", [RPCAPICommand("rpc_pools", "pools")]
),
}
)
@@ -116,7 +115,7 @@ class Innosilicon(CGMiner):
except APIError:
return self.config
self.config = MinerConfig.from_inno([pools])
self.config = MinerConfig.from_inno(pools["pools"])
return self.config
async def reboot(self) -> bool:

View File

@@ -13,8 +13,8 @@
# See the License for the specific language governing permissions and -
# limitations under the License. -
# ------------------------------------------------------------------------------
from typing import List, Optional
import logging
from typing import List, Optional
from pyasic.config import MinerConfig
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.config import MiningModeConfig
from pyasic.data import AlgoHashRate, Fan, HashBoard, HashUnit
from pyasic.data.pools import PoolMetrics, PoolUrl
from pyasic.errors import APIError
from pyasic.miners.data import DataFunction, DataLocations, DataOptions, WebAPICommand
from pyasic.miners.device.firmware import MaraFirmware
from pyasic.misc import merge_dicts
from pyasic.rpc.marathon import MaraRPCAPI
from pyasic.web.marathon import MaraWebAPI
from pyasic.data.pools import PoolMetrics, PoolUrl
MARA_DATA_LOC = DataLocations(
**{
@@ -319,10 +319,13 @@ class MaraMiner(MaraFirmware):
return []
active_pool_index = None
highest_priority = float('inf')
highest_priority = float("inf")
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"]
active_pool_index = pool_info["index"]

View File

@@ -560,7 +560,14 @@ class BaseMiner(MinerProtocol):
if self._ssh_cls is not None:
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.
Parameters:
@@ -574,4 +581,5 @@ class BaseMiner(MinerProtocol):
"""
return False
AnyMiner = TypeVar("AnyMiner", bound=BaseMiner)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -757,4 +757,4 @@ class LUXMinerRPCAPI(BaseMinerRPCAPI):
Returns:
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 json
from pathlib import Path
from typing import Any
import aiofiles
import httpx
from pathlib import Path
from pyasic import settings
from pyasic.web.base import BaseWebAPI
@@ -414,10 +415,7 @@ class AntminerOldWebAPI(BaseWebAPI):
parameters = {
"file": (file.name, file_content, "application/octet-stream"),
"filename": file.name,
"keep_settings": keep_settings
"keep_settings": keep_settings,
}
return await self.send_command(
command="upgrade",
**parameters
)
return await self.send_command(command="upgrade", **parameters)

View File

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

View File

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

View File

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