Run pre-commit formatting on all files
This commit is contained in:
committed by
Brett Rowan
parent
8b1cbed9ce
commit
f20531cff5
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -15,7 +15,4 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from .S21 import ePICS21, ePICS21Pro
|
||||
|
||||
from .T21 import (
|
||||
ePICT21,
|
||||
)
|
||||
from .T21 import ePICT21
|
||||
|
||||
@@ -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
|
||||
|
||||
##################################################
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")],
|
||||
)
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -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(
|
||||
**{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"]
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -14,7 +14,4 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from .blockminer import (
|
||||
ePICBlockMiner520i,
|
||||
ePICBlockMiner720i,
|
||||
)
|
||||
from .blockminer import ePICBlockMiner520i, ePICBlockMiner720i
|
||||
|
||||
@@ -43,4 +43,4 @@ class LuxOSFirmware(BaseMiner):
|
||||
|
||||
|
||||
class MaraFirmware(BaseMiner):
|
||||
firmware = MinerFirmware.MARATHON
|
||||
firmware = MinerFirmware.MARATHON
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user