bug: remove StrEnum references.

This commit is contained in:
Brett Rowan
2024-05-17 21:00:43 -06:00
parent 5d90b7e938
commit 1d656da2a2
4 changed files with 49 additions and 14 deletions

View File

@@ -26,17 +26,25 @@ class PoolMetrics:
pool_stale_percent: float = field(init=False) pool_stale_percent: float = field(init=False)
@property @property
def pool_rejected_percent(self) -> float: def pool_rejected_percent(self) -> float: # noqa - Skip PyCharm inspection
"""Calculate and return the percentage of rejected shares""" """Calculate and return the percentage of rejected shares"""
return self._calculate_percentage(self.rejected, self.accepted + self.rejected) return self._calculate_percentage(self.rejected, self.accepted + self.rejected)
@pool_rejected_percent.setter
def pool_rejected_percent(self, val):
pass
@property @property
def pool_stale_percent(self) -> float: def pool_stale_percent(self) -> float: # noqa - Skip PyCharm inspection
"""Calculate and return the percentage of stale shares.""" """Calculate and return the percentage of stale shares."""
return self._calculate_percentage( return self._calculate_percentage(
self.get_failures, self.accepted + self.rejected self.get_failures, self.accepted + self.rejected
) )
@pool_stale_percent.setter
def pool_stale_percent(self, val):
pass
@staticmethod @staticmethod
def _calculate_percentage(value: int, total: int) -> float: def _calculate_percentage(value: int, total: int) -> float:
"""Calculate the percentage.""" """Calculate the percentage."""

View File

@@ -14,10 +14,10 @@
# limitations under the License. - # limitations under the License. -
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from enum import StrEnum from enum import Enum
class MinerFirmware(StrEnum): class MinerFirmware(str, Enum):
STOCK = "Stock" STOCK = "Stock"
BRAIINS_OS = "BOS+" BRAIINS_OS = "BOS+"
VNISH = "VNish" VNISH = "VNish"
@@ -25,3 +25,6 @@ class MinerFirmware(StrEnum):
HIVEON = "Hive" HIVEON = "Hive"
LUXOS = "LuxOS" LUXOS = "LuxOS"
MARATHON = "MaraFW" MARATHON = "MaraFW"
def __str__(self):
return self.value

View File

@@ -14,10 +14,10 @@
# limitations under the License. - # limitations under the License. -
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
from enum import StrEnum from enum import Enum
class MinerMake(StrEnum): class MinerMake(str, Enum):
WHATSMINER = "WhatsMiner" WHATSMINER = "WhatsMiner"
ANTMINER = "AntMiner" ANTMINER = "AntMiner"
AVALONMINER = "AvalonMiner" AVALONMINER = "AvalonMiner"
@@ -25,3 +25,6 @@ class MinerMake(StrEnum):
GOLDSHELL = "Goldshell" GOLDSHELL = "Goldshell"
AURADINE = "Auradine" AURADINE = "Auradine"
EPIC = "ePIC" EPIC = "ePIC"
def __str__(self):
return self.value

View File

@@ -1,7 +1,7 @@
from enum import StrEnum from enum import Enum
class AntminerModels(StrEnum): class AntminerModels(str, Enum):
D3 = "D3" D3 = "D3"
HS3 = "HS3" HS3 = "HS3"
L3Plus = "L3+" L3Plus = "L3+"
@@ -46,8 +46,11 @@ class AntminerModels(StrEnum):
S21 = "S21" S21 = "S21"
T21 = "T21" T21 = "T21"
def __str__(self):
return self.value
class WhatsminerModels(StrEnum):
class WhatsminerModels(str, Enum):
M20V10 = "M20 V10" M20V10 = "M20 V10"
M20SV10 = "M20S V10" M20SV10 = "M20S V10"
M20SV20 = "M20S V20" M20SV20 = "M20S V20"
@@ -263,8 +266,11 @@ class WhatsminerModels(StrEnum):
M66SVK30 = "M66S VK30" M66SVK30 = "M66S VK30"
M66SVK40 = "M66S VK40" M66SVK40 = "M66S VK40"
def __str__(self):
return self.value
class AvalonminerModels(StrEnum):
class AvalonminerModels(str, Enum):
Avalon721 = "Avalon 721" Avalon721 = "Avalon 721"
Avalon741 = "Avalon 741" Avalon741 = "Avalon 741"
Avalon761 = "Avalon 761" Avalon761 = "Avalon 761"
@@ -278,13 +284,19 @@ class AvalonminerModels(StrEnum):
Avalon1166Pro = "Avalon 1166 Pro" Avalon1166Pro = "Avalon 1166 Pro"
Avalon1246 = "Avalon 1246" Avalon1246 = "Avalon 1246"
def __str__(self):
return self.value
class InnosiliconModels(StrEnum):
class InnosiliconModels(str, Enum):
T3HPlus = "T3H+" T3HPlus = "T3H+"
A10X = "A10X" A10X = "A10X"
def __str__(self):
return self.value
class GoldshellModels(StrEnum):
class GoldshellModels(str, Enum):
CK5 = "CK5" CK5 = "CK5"
HS5 = "HS5" HS5 = "HS5"
KD5 = "KD5" KD5 = "KD5"
@@ -292,13 +304,19 @@ class GoldshellModels(StrEnum):
KDBoxII = "KD Box II" KDBoxII = "KD Box II"
KDBoxPro = "KD Box Pro" KDBoxPro = "KD Box Pro"
def __str__(self):
return self.value
class ePICModels(StrEnum):
class ePICModels(str, Enum):
BM520i = "BlockMiner 520i" BM520i = "BlockMiner 520i"
BM720i = "BlockMiner 720i" BM720i = "BlockMiner 720i"
def __str__(self):
return self.value
class AuradineModels(StrEnum):
class AuradineModels(str, Enum):
AT1500 = "AT1500" AT1500 = "AT1500"
AT2860 = "AT2860" AT2860 = "AT2860"
AT2880 = "AT2880" AT2880 = "AT2880"
@@ -307,6 +325,9 @@ class AuradineModels(StrEnum):
AD2500 = "AD2500" AD2500 = "AD2500"
AD3500 = "AD3500" AD3500 = "AD3500"
def __str__(self):
return self.value
class MinerModel: class MinerModel:
ANTMINER = AntminerModels ANTMINER = AntminerModels