refactor: swap (KeyError, IndexError) for LookupError.

This commit is contained in:
UpstreamData
2024-01-11 15:20:33 -07:00
parent 2ef85d3868
commit cd1768aae9
10 changed files with 42 additions and 42 deletions

View File

@@ -478,7 +478,7 @@ class BOSMiner(BaseMiner):
if api_version:
try:
api_ver = api_version["VERSION"][0]["API"]
except (KeyError, IndexError):
except LookupError:
api_ver = None
self.api_ver = api_ver
self.api.api_ver = self.api_ver
@@ -580,7 +580,7 @@ class BOSMiner(BaseMiner):
if api_summary:
try:
return round(float(api_summary["SUMMARY"][0]["MHS 1m"] / 1000000), 2)
except (KeyError, IndexError, ValueError, TypeError):
except (LookupError, ValueError, TypeError):
pass
async def _get_hashboards(
@@ -642,7 +642,7 @@ class BOSMiner(BaseMiner):
board.temp = round(hb["temperatures"][0]["degreesC"])
if len(temps) > 1:
board.chip_temp = round(hb["temperatures"][1]["degreesC"])
except (TypeError, KeyError, ValueError, IndexError):
except (LookupError, TypeError, ValueError):
pass
details = hb.get("hwDetails")
if details:
@@ -666,15 +666,15 @@ class BOSMiner(BaseMiner):
d = {}
try:
api_temps = d["temps"][0]
except (KeyError, IndexError):
except LookupError:
api_temps = None
try:
api_devdetails = d["devdetails"][0]
except (KeyError, IndexError):
except LookupError:
api_devdetails = None
try:
api_devs = d["devs"][0]
except (KeyError, IndexError):
except LookupError:
api_devs = None
if api_temps:
try:
@@ -686,7 +686,7 @@ class BOSMiner(BaseMiner):
board_temp = round(board["Board"])
hashboards[_id].chip_temp = chip_temp
hashboards[_id].temp = board_temp
except (IndexError, KeyError, ValueError, TypeError):
except (LookupError, ValueError, TypeError):
pass
if api_devdetails:
@@ -698,7 +698,7 @@ class BOSMiner(BaseMiner):
chips = board["Chips"]
hashboards[_id].chips = chips
hashboards[_id].missing = False
except (IndexError, KeyError):
except LookupError:
pass
if api_devs:
@@ -709,7 +709,7 @@ class BOSMiner(BaseMiner):
_id = board["ID"] - offset
hashrate = round(float(board["MHS 1m"] / 1000000), 2)
hashboards[_id].hashrate = hashrate
except (IndexError, KeyError):
except LookupError:
pass
return hashboards
@@ -750,7 +750,7 @@ class BOSMiner(BaseMiner):
return api_tunerstatus["TUNERSTATUS"][0][
"ApproximateMinerPowerConsumption"
]
except (KeyError, IndexError):
except LookupError:
pass
async def _get_wattage_limit(
@@ -781,7 +781,7 @@ class BOSMiner(BaseMiner):
if api_tunerstatus:
try:
return api_tunerstatus["TUNERSTATUS"][0]["PowerLimit"]
except (KeyError, IndexError):
except LookupError:
pass
async def _get_fans(
@@ -820,7 +820,7 @@ class BOSMiner(BaseMiner):
for n in range(self.expected_fans):
try:
fans.append(Fan(api_fans["FANS"][n]["RPM"]))
except (IndexError, KeyError):
except LookupError:
pass
return fans
return [Fan() for _ in range(self.expected_fans)]
@@ -904,7 +904,7 @@ class BOSMiner(BaseMiner):
_error = _error[0].lower() + _error[1:]
errors.append(BraiinsOSError(f"Slot {_id} {_error}"))
return errors
except (KeyError, IndexError):
except LookupError:
pass
async def _get_fault_light(self, graphql_fault_light: dict = None) -> bool:
@@ -987,7 +987,7 @@ class BOSMiner(BaseMiner):
return round(
(sum(hr_list) / len(hr_list)) * self.expected_hashboards, 2
)
except (IndexError, KeyError):
except LookupError:
pass
async def _is_mining(self, api_devdetails: dict = None) -> Optional[bool]: