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 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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -15,7 +15,4 @@
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
from .S21 import ePICS21, ePICS21Pro
|
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():
|
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
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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")],
|
||||||
)
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -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(
|
||||||
**{
|
**{
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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"]
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -14,7 +14,4 @@
|
|||||||
# limitations under the License. -
|
# limitations under the License. -
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
from .blockminer import (
|
from .blockminer import ePICBlockMiner520i, ePICBlockMiner720i
|
||||||
ePICBlockMiner520i,
|
|
||||||
ePICBlockMiner720i,
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -43,4 +43,4 @@ class LuxOSFirmware(BaseMiner):
|
|||||||
|
|
||||||
|
|
||||||
class MaraFirmware(BaseMiner):
|
class MaraFirmware(BaseMiner):
|
||||||
firmware = MinerFirmware.MARATHON
|
firmware = MinerFirmware.MARATHON
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|||||||
@@ -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
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user