refactor: change some if statements to if is not None.

This commit is contained in:
UpstreamData
2024-01-15 15:43:31 -07:00
parent aab8825997
commit d686cdacc8
12 changed files with 281 additions and 257 deletions

View File

@@ -141,26 +141,26 @@ class AntminerModern(BMMiner):
return True
async def _get_hostname(self, web_get_system_info: dict = None) -> Union[str, None]:
if not web_get_system_info:
if web_get_system_info is None:
try:
web_get_system_info = await self.web.get_system_info()
except APIError:
pass
if web_get_system_info:
if web_get_system_info is not None:
try:
return web_get_system_info["hostname"]
except KeyError:
pass
async def _get_mac(self, web_get_system_info: dict = None) -> Union[str, None]:
if not web_get_system_info:
if web_get_system_info is None:
try:
web_get_system_info = await self.web.get_system_info()
except APIError:
pass
if web_get_system_info:
if web_get_system_info is not None:
try:
return web_get_system_info["macaddr"]
except KeyError:
@@ -174,14 +174,14 @@ class AntminerModern(BMMiner):
pass
async def _get_errors(self, web_summary: dict = None) -> List[MinerErrorData]:
if not web_summary:
if web_summary is None:
try:
web_summary = await self.web.summary()
except APIError:
pass
errors = []
if web_summary:
if web_summary is not None:
try:
for item in web_summary["SUMMARY"][0]["status"]:
try:
@@ -204,7 +204,7 @@ class AntminerModern(BMMiner):
except APIError:
return hashboards
if api_stats:
if api_stats is not None:
try:
for board in api_stats["STATS"][0]["chain"]:
hashboards[board["index"]].hashrate = round(
@@ -233,13 +233,13 @@ class AntminerModern(BMMiner):
if self.light:
return self.light
if not web_get_blink_status:
if web_get_blink_status is None:
try:
web_get_blink_status = await self.web.get_blink_status()
except APIError:
pass
if web_get_blink_status:
if web_get_blink_status is not None:
try:
self.light = web_get_blink_status["blink"]
except KeyError:
@@ -247,13 +247,13 @@ class AntminerModern(BMMiner):
return self.light
async def _get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]:
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
expected_rate = api_stats["STATS"][1]["total_rateideal"]
try:
@@ -312,13 +312,13 @@ class AntminerModern(BMMiner):
)
async def _is_mining(self, web_get_conf: dict = None) -> Optional[bool]:
if not web_get_conf:
if web_get_conf is None:
try:
web_get_conf = await self.web.get_miner_conf()
except APIError:
pass
if web_get_conf:
if web_get_conf is not None:
try:
if web_get_conf["bitmain-work-mode"].isdigit():
return (
@@ -329,13 +329,13 @@ class AntminerModern(BMMiner):
pass
async def _get_uptime(self, api_stats: dict = None) -> Optional[int]:
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
return int(api_stats["STATS"][1]["Elapsed"])
except LookupError:
@@ -447,13 +447,13 @@ class AntminerOld(CGMiner):
if self.light:
return self.light
if not web_get_blink_status:
if web_get_blink_status is None:
try:
web_get_blink_status = await self.web.get_blink_status()
except APIError:
pass
if web_get_blink_status:
if web_get_blink_status is not None:
try:
self.light = web_get_blink_status["isBlinking"]
except KeyError:
@@ -461,27 +461,27 @@ class AntminerOld(CGMiner):
return self.light
async def _get_hostname(self, web_get_system_info: dict = None) -> Optional[str]:
if not web_get_system_info:
if web_get_system_info is None:
try:
web_get_system_info = await self.web.get_system_info()
except APIError:
pass
if web_get_system_info:
if web_get_system_info is not None:
try:
return web_get_system_info["hostname"]
except KeyError:
pass
async def _get_fans(self, api_stats: dict = None) -> List[Fan]:
if not api_stats:
if not api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
fans_data = [Fan() for _ in range(self.expected_fans)]
if api_stats:
if api_stats is not None:
try:
fan_offset = -1
@@ -504,13 +504,13 @@ class AntminerOld(CGMiner):
async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]:
hashboards = []
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
board_offset = -1
boards = api_stats["STATS"]
@@ -556,13 +556,13 @@ class AntminerOld(CGMiner):
return hashboards
async def _is_mining(self, web_get_conf: dict = None) -> Optional[bool]:
if not web_get_conf:
if web_get_conf is None:
try:
web_get_conf = await self.web.get_miner_conf()
except APIError:
pass
if web_get_conf:
if web_get_conf is not None:
try:
return False if int(web_get_conf["bitmain-work-mode"]) == 1 else True
except LookupError:
@@ -581,13 +581,13 @@ class AntminerOld(CGMiner):
return False
async def _get_uptime(self, api_stats: dict = None) -> Optional[int]:
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
return int(api_stats["STATS"][1]["Elapsed"])
except LookupError:

View File

@@ -119,13 +119,13 @@ class BFGMiner(BaseMiner):
return None
async def _get_api_ver(self, api_version: dict = None) -> Optional[str]:
if not api_version:
if api_version is None:
try:
api_version = await self.api.version()
except APIError:
pass
if api_version:
if api_version is not None:
try:
self.api_ver = api_version["VERSION"][0]["API"]
except LookupError:
@@ -134,13 +134,13 @@ class BFGMiner(BaseMiner):
return self.api_ver
async def _get_fw_ver(self, api_version: dict = None) -> Optional[str]:
if not api_version:
if api_version is None:
try:
api_version = await self.api.version()
except APIError:
pass
if api_version:
if api_version is not None:
try:
self.fw_ver = api_version["VERSION"][0]["CompileTime"]
except LookupError:
@@ -159,13 +159,13 @@ class BFGMiner(BaseMiner):
async def _get_hashrate(self, api_summary: dict = None) -> Optional[float]:
# get hr from API
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
return round(float(api_summary["SUMMARY"][0]["MHS 20s"] / 1000000), 2)
except (LookupError, ValueError, TypeError):
@@ -174,13 +174,13 @@ class BFGMiner(BaseMiner):
async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]:
hashboards = []
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
board_offset = -1
boards = api_stats["STATS"]
@@ -235,14 +235,14 @@ class BFGMiner(BaseMiner):
return None
async def _get_fans(self, api_stats: dict = None) -> List[Fan]:
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
fans_data = [None, None, None, None]
if api_stats:
if api_stats is not None:
try:
fan_offset = -1
@@ -272,13 +272,13 @@ class BFGMiner(BaseMiner):
async def _get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]:
# X19 method, not sure compatibility
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
expected_rate = api_stats["STATS"][1]["total_rateideal"]
try:

View File

@@ -110,26 +110,26 @@ class BFGMinerGoldshell(BFGMiner):
)
async def _get_mac(self, web_setting: dict = None) -> str:
if not web_setting:
if web_setting is None:
try:
web_setting = await self.web.setting()
except APIError:
pass
if web_setting:
if web_setting is not None:
try:
return web_setting["name"]
except KeyError:
pass
async def _get_fw_ver(self, web_status: dict = None) -> str:
if not web_status:
if web_status is None:
try:
web_status = await self.web.setting()
except APIError:
pass
if web_status:
if web_status is not None:
try:
return web_status["firmware"]
except KeyError:
@@ -138,7 +138,7 @@ class BFGMinerGoldshell(BFGMiner):
async def _get_hashboards(
self, api_devs: dict = None, api_devdetails: dict = None
) -> List[HashBoard]:
if not api_devs:
if api_devs is None:
try:
api_devs = await self.api.devs()
except APIError:
@@ -149,7 +149,7 @@ class BFGMinerGoldshell(BFGMiner):
for i in range(self.expected_hashboards)
]
if api_devs:
if api_devs is not None:
if api_devs.get("DEVS"):
for board in api_devs["DEVS"]:
if board.get("ID") is not None:
@@ -165,13 +165,13 @@ class BFGMinerGoldshell(BFGMiner):
else:
logger.error(self, api_devs)
if not api_devdetails:
if api_devdetails is None:
try:
api_devdetails = await self.api.devdetails()
except APIError:
pass
if api_devdetails:
if api_devdetails is not None:
if api_devdetails.get("DEVS"):
for board in api_devdetails["DEVS"]:
if board.get("ID") is not None:

View File

@@ -158,13 +158,13 @@ class BMMiner(BaseMiner):
return None
async def _get_api_ver(self, api_version: dict = None) -> Optional[str]:
if not api_version:
if api_version is None:
try:
api_version = await self.api.version()
except APIError:
pass
if api_version:
if api_version is not None:
try:
self.api_ver = api_version["VERSION"][0]["API"]
except LookupError:
@@ -173,13 +173,13 @@ class BMMiner(BaseMiner):
return self.api_ver
async def _get_fw_ver(self, api_version: dict = None) -> Optional[str]:
if not api_version:
if api_version is None:
try:
api_version = await self.api.version()
except APIError:
pass
if api_version:
if api_version is not None:
try:
self.fw_ver = api_version["VERSION"][0]["CompileTime"]
except LookupError:
@@ -196,13 +196,13 @@ class BMMiner(BaseMiner):
async def _get_hashrate(self, api_summary: dict = None) -> Optional[float]:
# get hr from API
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
return round(float(api_summary["SUMMARY"][0]["GHS 5s"] / 1000), 2)
except (LookupError, ValueError, TypeError):
@@ -211,13 +211,13 @@ class BMMiner(BaseMiner):
async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]:
hashboards = []
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
board_offset = -1
boards = api_stats["STATS"]
@@ -285,14 +285,14 @@ class BMMiner(BaseMiner):
return None
async def _get_fans(self, api_stats: dict = None) -> List[Fan]:
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
fans = [Fan() for _ in range(self.expected_fans)]
if api_stats:
if api_stats is not None:
try:
fan_offset = -1
@@ -321,13 +321,13 @@ class BMMiner(BaseMiner):
async def _get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]:
# X19 method, not sure compatibility
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
expected_rate = api_stats["STATS"][1]["total_rateideal"]
try:
@@ -347,13 +347,13 @@ class BMMiner(BaseMiner):
return None
async def _get_uptime(self, api_stats: dict = None) -> Optional[int]:
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
return int(api_stats["STATS"][1]["Elapsed"])
except LookupError:

View File

@@ -339,7 +339,7 @@ class BOSMiner(BaseMiner):
##################################################
async def _get_mac(self, web_net_conf: Union[dict, list] = None) -> Optional[str]:
if not web_net_conf:
if web_net_conf is None:
try:
web_net_conf = await self.web.luci.get_net_conf()
except APIError:
@@ -349,7 +349,7 @@ class BOSMiner(BaseMiner):
if "admin/network/iface_status/lan" in web_net_conf.keys():
web_net_conf = web_net_conf["admin/network/iface_status/lan"]
if web_net_conf:
if web_net_conf is not None:
try:
return web_net_conf[0]["macaddr"]
except LookupError:
@@ -360,14 +360,14 @@ class BOSMiner(BaseMiner):
# return result.upper().strip()
async def _get_api_ver(self, api_version: dict = None) -> Optional[str]:
if not api_version:
if api_version is None:
try:
api_version = await self.api.version()
except APIError:
pass
# Now get the API version
if api_version:
if api_version is not None:
try:
api_ver = api_version["VERSION"][0]["API"]
except LookupError:
@@ -409,14 +409,13 @@ class BOSMiner(BaseMiner):
return hostname
async def _get_hashrate(self, api_summary: dict = None) -> Optional[float]:
# get hr from API
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
return round(float(api_summary["SUMMARY"][0]["MHS 1m"] / 1000000), 2)
except (KeyError, IndexError, ValueError, TypeError):
@@ -434,11 +433,11 @@ class BOSMiner(BaseMiner):
]
cmds = []
if not api_temps:
if api_temps is None:
cmds.append("temps")
if not api_devdetails:
if api_devdetails is None:
cmds.append("devdetails")
if not api_devs:
if api_devs is None:
cmds.append("devs")
if len(cmds) > 0:
try:
@@ -457,7 +456,7 @@ class BOSMiner(BaseMiner):
api_devs = d["devs"][0]
except LookupError:
api_devs = None
if api_temps:
if api_temps is not None:
try:
offset = 6 if api_temps["TEMPS"][0]["ID"] in [6, 7, 8] else 1
@@ -470,7 +469,7 @@ class BOSMiner(BaseMiner):
except (IndexError, KeyError, ValueError, TypeError):
pass
if api_devdetails:
if api_devdetails is not None:
try:
offset = 6 if api_devdetails["DEVDETAILS"][0]["ID"] in [6, 7, 8] else 1
@@ -482,7 +481,7 @@ class BOSMiner(BaseMiner):
except (IndexError, KeyError):
pass
if api_devs:
if api_devs is not None:
try:
offset = 6 if api_devs["DEVS"][0]["ID"] in [6, 7, 8] else 1
@@ -499,13 +498,13 @@ class BOSMiner(BaseMiner):
return None
async def _get_wattage(self, api_tunerstatus: dict = None) -> Optional[int]:
if not api_tunerstatus:
if api_tunerstatus is None:
try:
api_tunerstatus = await self.api.tunerstatus()
except APIError:
pass
if api_tunerstatus:
if api_tunerstatus is not None:
try:
return api_tunerstatus["TUNERSTATUS"][0][
"ApproximateMinerPowerConsumption"
@@ -514,26 +513,26 @@ class BOSMiner(BaseMiner):
pass
async def _get_wattage_limit(self, api_tunerstatus: dict = None) -> Optional[int]:
if not api_tunerstatus:
if api_tunerstatus is None:
try:
api_tunerstatus = await self.api.tunerstatus()
except APIError:
pass
if api_tunerstatus:
if api_tunerstatus is not None:
try:
return api_tunerstatus["TUNERSTATUS"][0]["PowerLimit"]
except LookupError:
pass
async def _get_fans(self, api_fans: dict = None) -> List[Fan]:
if not api_fans:
if api_fans is None:
try:
api_fans = await self.api.fans()
except APIError:
pass
if api_fans:
if api_fans is not None:
fans = []
for n in range(self.expected_fans):
try:
@@ -547,13 +546,13 @@ class BOSMiner(BaseMiner):
return None
async def _get_errors(self, api_tunerstatus: dict = None) -> List[MinerErrorData]:
if not api_tunerstatus:
if api_tunerstatus is None:
try:
api_tunerstatus = await self.api.tunerstatus()
except APIError:
pass
if api_tunerstatus:
if api_tunerstatus is not None:
errors = []
try:
chain_status = api_tunerstatus["TUNERSTATUS"][0]["TunerChainStatus"]
@@ -591,13 +590,13 @@ class BOSMiner(BaseMiner):
return self.light
async def _get_expected_hashrate(self, api_devs: dict = None) -> Optional[float]:
if not api_devs:
if api_devs is None:
try:
api_devs = await self.api.devs()
except APIError:
pass
if api_devs:
if api_devs is not None:
try:
offset = 6 if api_devs["DEVS"][0]["ID"] in [6, 7, 8] else 0
hr_list = []
@@ -617,7 +616,7 @@ class BOSMiner(BaseMiner):
pass
async def _is_mining(self, api_devdetails: dict = None) -> Optional[bool]:
if not api_devdetails:
if api_devdetails is None:
try:
api_devdetails = await self.api.send_command(
"devdetails", ignore_errors=True, allow_warning=False
@@ -625,20 +624,20 @@ class BOSMiner(BaseMiner):
except APIError:
pass
if api_devdetails:
if api_devdetails is not None:
try:
return not api_devdetails["STATUS"][0]["Msg"] == "Unavailable"
except LookupError:
pass
async def _get_uptime(self, api_summary: dict = None) -> Optional[int]:
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
return int(api_summary["SUMMARY"][0]["Elapsed"])
except LookupError:
@@ -796,27 +795,27 @@ class BOSer(BaseMiner):
##################################################
async def _get_mac(self, grpc_miner_details: dict = None) -> Optional[str]:
if not grpc_miner_details:
if grpc_miner_details is None:
try:
grpc_miner_details = await self.web.grpc.get_miner_details()
except APIError:
pass
if grpc_miner_details:
if grpc_miner_details is not None:
try:
return grpc_miner_details["macAddress"].upper()
except (LookupError, TypeError):
pass
async def _get_api_ver(self, api_version: dict = None) -> Optional[str]:
if not api_version:
if api_version is None:
try:
api_version = await self.api.version()
except APIError:
pass
# Now get the API version
if api_version:
if api_version is not None:
try:
api_ver = api_version["VERSION"][0]["API"]
except LookupError:
@@ -827,7 +826,7 @@ class BOSer(BaseMiner):
return self.api_ver
async def _get_fw_ver(self, grpc_miner_details: dict = None) -> Optional[str]:
if not grpc_miner_details:
if grpc_miner_details is None:
try:
grpc_miner_details = await self.web.grpc.get_miner_details()
except APIError:
@@ -835,7 +834,7 @@ class BOSer(BaseMiner):
fw_ver = None
if grpc_miner_details:
if grpc_miner_details is not None:
try:
fw_ver = grpc_miner_details["bosVersion"]["current"]
except (KeyError, TypeError):
@@ -851,26 +850,26 @@ class BOSer(BaseMiner):
return self.fw_ver
async def _get_hostname(self, grpc_miner_details: dict = None) -> Union[str, None]:
if not grpc_miner_details:
if grpc_miner_details is None:
try:
grpc_miner_details = await self.web.grpc.get_miner_details()
except APIError:
pass
if grpc_miner_details:
if grpc_miner_details is not None:
try:
return grpc_miner_details["hostname"]
except LookupError:
pass
async def _get_hashrate(self, api_summary: dict = None) -> Optional[float]:
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
return round(float(api_summary["SUMMARY"][0]["MHS 1m"] / 1000000), 2)
except (KeyError, IndexError, ValueError, TypeError):
@@ -879,13 +878,13 @@ class BOSer(BaseMiner):
async def _get_expected_hashrate(
self, grpc_miner_details: dict = None
) -> Optional[float]:
if not grpc_miner_details:
if grpc_miner_details is None:
try:
grpc_miner_details = await self.web.grpc.get_miner_details()
except APIError:
pass
if grpc_miner_details:
if grpc_miner_details is not None:
try:
return grpc_miner_details["stickerHashrate"]["gigahashPerSecond"] / 1000
except LookupError:
@@ -937,7 +936,7 @@ class BOSer(BaseMiner):
except APIError:
pass
if grpc_miner_stats:
if grpc_miner_stats is not None:
try:
return grpc_miner_stats["powerStats"]["approximatedConsumption"]["watt"]
except KeyError:
@@ -954,7 +953,7 @@ class BOSer(BaseMiner):
except APIError:
pass
if grpc_active_performance_mode:
if grpc_active_performance_mode is not None:
try:
return grpc_active_performance_mode["tunerMode"]["powerTarget"][
"powerTarget"
@@ -969,7 +968,7 @@ class BOSer(BaseMiner):
except APIError:
pass
if grpc_cooling_state:
if grpc_cooling_state is not None:
fans = []
for n in range(self.expected_fans):
try:
@@ -983,13 +982,13 @@ class BOSer(BaseMiner):
return None
async def _get_errors(self, api_tunerstatus: dict = None) -> List[MinerErrorData]:
if not api_tunerstatus:
if api_tunerstatus is None:
try:
api_tunerstatus = await self.api.tunerstatus()
except APIError:
pass
if api_tunerstatus:
if api_tunerstatus is not None:
errors = []
try:
chain_status = api_tunerstatus["TUNERSTATUS"][0]["TunerChainStatus"]
@@ -1016,7 +1015,7 @@ class BOSer(BaseMiner):
if self.light is not None:
return self.light
if not grpc_locate_device_status:
if grpc_locate_device_status is None:
try:
grpc_locate_device_status = (
await self.web.grpc.get_locate_device_status()
@@ -1033,7 +1032,7 @@ class BOSer(BaseMiner):
pass
async def _is_mining(self, api_devdetails: dict = None) -> Optional[bool]:
if not api_devdetails:
if api_devdetails is None:
try:
api_devdetails = await self.api.send_command(
"devdetails", ignore_errors=True, allow_warning=False
@@ -1041,20 +1040,20 @@ class BOSer(BaseMiner):
except APIError:
pass
if api_devdetails:
if api_devdetails is not None:
try:
return not api_devdetails["STATUS"][0]["Msg"] == "Unavailable"
except LookupError:
pass
async def _get_uptime(self, api_summary: dict = None) -> Optional[int]:
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
return int(api_summary["SUMMARY"][0]["Elapsed"])
except LookupError:

View File

@@ -287,26 +287,26 @@ class BTMiner(BaseMiner):
async def _get_mac(
self, api_summary: dict = None, api_get_miner_info: dict = None
) -> Optional[str]:
if not api_get_miner_info:
if api_get_miner_info is None:
try:
api_get_miner_info = await self.api.get_miner_info()
except APIError:
pass
if api_get_miner_info:
if api_get_miner_info is not None:
try:
mac = api_get_miner_info["Msg"]["mac"]
return str(mac).upper()
except KeyError:
pass
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
mac = api_summary["SUMMARY"][0]["MAC"]
return str(mac).upper()
@@ -314,13 +314,13 @@ class BTMiner(BaseMiner):
pass
async def _get_api_ver(self, api_get_version: dict = None) -> Optional[str]:
if not api_get_version:
if api_get_version is None:
try:
api_get_version = await self.api.get_version()
except APIError:
pass
if api_get_version:
if api_get_version is not None:
if "Code" in api_get_version.keys():
if api_get_version["Code"] == 131:
try:
@@ -339,13 +339,13 @@ class BTMiner(BaseMiner):
async def _get_fw_ver(
self, api_get_version: dict = None, api_summary: dict = None
) -> Optional[str]:
if not api_get_version:
if api_get_version is None:
try:
api_get_version = await self.api.get_version()
except APIError:
pass
if api_get_version:
if api_get_version is not None:
if "Code" in api_get_version.keys():
if api_get_version["Code"] == 131:
try:
@@ -355,7 +355,7 @@ class BTMiner(BaseMiner):
else:
return self.fw_ver
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
@@ -373,13 +373,13 @@ class BTMiner(BaseMiner):
async def _get_hostname(self, api_get_miner_info: dict = None) -> Optional[str]:
hostname = None
if not api_get_miner_info:
if api_get_miner_info is None:
try:
api_get_miner_info = await self.api.get_miner_info()
except APIError:
return None # only one way to get this
if api_get_miner_info:
if api_get_miner_info is not None:
try:
hostname = api_get_miner_info["Msg"]["hostname"]
except KeyError:
@@ -389,13 +389,13 @@ class BTMiner(BaseMiner):
async def _get_hashrate(self, api_summary: dict = None) -> Optional[float]:
# get hr from API
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
return round(float(api_summary["SUMMARY"][0]["MHS 1m"] / 1000000), 2)
except LookupError:
@@ -407,13 +407,13 @@ class BTMiner(BaseMiner):
for i in range(self.expected_hashboards)
]
if not api_devs:
if api_devs is None:
try:
api_devs = await self.api.devs()
except APIError:
pass
if api_devs:
if api_devs is not None:
try:
for board in api_devs["DEVS"]:
if len(hashboards) < board["ASC"] + 1:
@@ -437,26 +437,26 @@ class BTMiner(BaseMiner):
return hashboards
async def _get_env_temp(self, api_summary: dict = None) -> Optional[float]:
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
return api_summary["SUMMARY"][0]["Env Temp"]
except LookupError:
pass
async def _get_wattage(self, api_summary: dict = None) -> Optional[int]:
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
wattage = api_summary["SUMMARY"][0]["Power"]
return wattage if not wattage == -1 else None
@@ -464,13 +464,13 @@ class BTMiner(BaseMiner):
pass
async def _get_wattage_limit(self, api_summary: dict = None) -> Optional[int]:
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
return api_summary["SUMMARY"][0]["Power Limit"]
except LookupError:
@@ -479,14 +479,14 @@ class BTMiner(BaseMiner):
async def _get_fans(
self, api_summary: dict = None, api_get_psu: dict = None
) -> List[Fan]:
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
fans = [Fan() for _ in range(self.expected_fans)]
if api_summary:
if api_summary is not None:
try:
if self.expected_fans > 0:
fans = [
@@ -501,25 +501,25 @@ class BTMiner(BaseMiner):
async def _get_fan_psu(
self, api_summary: dict = None, api_get_psu: dict = None
) -> Optional[int]:
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
return int(api_summary["SUMMARY"][0]["Power Fanspeed"])
except LookupError:
pass
if not api_get_psu:
if api_get_psu is None:
try:
api_get_psu = await self.api.get_psu()
except APIError:
pass
if api_get_psu:
if api_get_psu is not None:
try:
return int(api_get_psu["Msg"]["fan_speed"])
except (KeyError, TypeError):
@@ -529,13 +529,13 @@ class BTMiner(BaseMiner):
self, api_summary: dict = None, api_get_error_code: dict = None
) -> List[MinerErrorData]:
errors = []
if not api_get_error_code and not api_summary:
if api_get_error_code is None and api_summary is None:
try:
api_get_error_code = await self.api.get_error_code()
except APIError:
pass
if api_get_error_code:
if api_get_error_code is not None:
for err in api_get_error_code["Msg"]["error_code"]:
if isinstance(err, dict):
for code in err:
@@ -543,13 +543,13 @@ class BTMiner(BaseMiner):
else:
errors.append(WhatsminerError(error_code=int(err)))
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
for i in range(api_summary["SUMMARY"][0]["Error Code Count"]):
err = api_summary["SUMMARY"][0].get(f"Error Code {i}")
@@ -560,13 +560,13 @@ class BTMiner(BaseMiner):
return errors
async def _get_expected_hashrate(self, api_summary: dict = None):
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
expected_hashrate = api_summary["SUMMARY"][0]["Factory GHS"]
if expected_hashrate:
@@ -575,14 +575,14 @@ class BTMiner(BaseMiner):
pass
async def _get_fault_light(self, api_get_miner_info: dict = None) -> bool:
if not api_get_miner_info:
if api_get_miner_info is None:
try:
api_get_miner_info = await self.api.get_miner_info()
except APIError:
if not self.light:
self.light = False
if api_get_miner_info:
if api_get_miner_info is not None:
try:
self.light = not (api_get_miner_info["Msg"]["ledstat"] == "auto")
except KeyError:
@@ -613,13 +613,13 @@ class BTMiner(BaseMiner):
await self.api.set_hostname(hostname)
async def _is_mining(self, api_status: dict = None) -> Optional[bool]:
if not api_status:
if api_status is None:
try:
api_status = await self.api.status()
except APIError:
pass
if api_status:
if api_status is not None:
try:
if api_status["Msg"].get("btmineroff"):
try:
@@ -632,13 +632,13 @@ class BTMiner(BaseMiner):
pass
async def _get_uptime(self, api_summary: dict = None) -> Optional[int]:
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
return int(api_summary["SUMMARY"][0]["Elapsed"])
except LookupError:

View File

@@ -183,13 +183,13 @@ class CGMiner(BaseMiner):
return None
async def _get_api_ver(self, api_version: dict = None) -> Optional[str]:
if not api_version:
if api_version is None:
try:
api_version = await self.api.version()
except APIError:
pass
if api_version:
if api_version is not None:
try:
self.api_ver = api_version["VERSION"][0]["API"]
except LookupError:
@@ -198,13 +198,13 @@ class CGMiner(BaseMiner):
return self.api_ver
async def _get_fw_ver(self, api_version: dict = None) -> Optional[str]:
if not api_version:
if api_version is None:
try:
api_version = await self.api.version()
except APIError:
pass
if api_version:
if api_version is not None:
try:
self.fw_ver = api_version["VERSION"][0]["CGMiner"]
except LookupError:
@@ -218,13 +218,13 @@ class CGMiner(BaseMiner):
async def _get_hashrate(self, api_summary: dict = None) -> Optional[float]:
# get hr from API
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
return round(
float(float(api_summary["SUMMARY"][0]["GHS 5s"]) / 1000), 2
@@ -235,13 +235,13 @@ class CGMiner(BaseMiner):
async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]:
hashboards = []
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
board_offset = -1
boards = api_stats["STATS"]
@@ -296,14 +296,14 @@ class CGMiner(BaseMiner):
return None
async def _get_fans(self, api_stats: dict = None) -> List[Fan]:
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
fans = [Fan() for _ in range(self.expected_fans)]
if api_stats:
if api_stats is not None:
try:
fan_offset = -1
@@ -334,13 +334,13 @@ class CGMiner(BaseMiner):
async def _get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]:
# X19 method, not sure compatibility
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
expected_rate = api_stats["STATS"][1]["total_rateideal"]
try:
@@ -360,13 +360,13 @@ class CGMiner(BaseMiner):
return None
async def _get_uptime(self, api_stats: dict = None) -> Optional[int]:
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
return int(api_stats["STATS"][1]["Elapsed"])
except LookupError:

View File

@@ -173,13 +173,13 @@ class CGMinerAvalon(CGMiner):
##################################################
async def _get_mac(self, api_version: dict = None) -> Optional[str]:
if not api_version:
if api_version is None:
try:
api_version = await self.api.version()
except APIError:
pass
if api_version:
if api_version is not None:
try:
base_mac = api_version["VERSION"][0]["MAC"]
base_mac = base_mac.upper()
@@ -199,13 +199,13 @@ class CGMinerAvalon(CGMiner):
# return f"Avalon{mac.replace(':', '')[-6:]}"
async def _get_hashrate(self, api_devs: dict = None) -> Optional[float]:
if not api_devs:
if api_devs is None:
try:
api_devs = await self.api.devs()
except APIError:
pass
if api_devs:
if api_devs is not None:
try:
return round(float(api_devs["DEVS"][0]["MHS 1m"] / 1000000), 2)
except (KeyError, IndexError, ValueError, TypeError):
@@ -217,13 +217,13 @@ class CGMinerAvalon(CGMiner):
for i in range(self.expected_hashboards)
]
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
unparsed_stats = api_stats["STATS"][0]["MM ID0"]
parsed_stats = self.parse_stats(unparsed_stats)
@@ -260,13 +260,13 @@ class CGMinerAvalon(CGMiner):
return hashboards
async def _get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]:
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
unparsed_stats = api_stats["STATS"][0]["MM ID0"]
parsed_stats = self.parse_stats(unparsed_stats)
@@ -275,13 +275,13 @@ class CGMinerAvalon(CGMiner):
pass
async def _get_env_temp(self, api_stats: dict = None) -> Optional[float]:
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
unparsed_stats = api_stats["STATS"][0]["MM ID0"]
parsed_stats = self.parse_stats(unparsed_stats)
@@ -293,13 +293,13 @@ class CGMinerAvalon(CGMiner):
return None
async def _get_wattage_limit(self, api_stats: dict = None) -> Optional[int]:
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
unparsed_stats = api_stats["STATS"][0]["MM ID0"]
parsed_stats = self.parse_stats(unparsed_stats)
@@ -308,14 +308,14 @@ class CGMinerAvalon(CGMiner):
pass
async def _get_fans(self, api_stats: dict = None) -> List[Fan]:
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
fans_data = [Fan() for _ in range(self.expected_fans)]
if api_stats:
if api_stats is not None:
try:
unparsed_stats = api_stats["STATS"][0]["MM ID0"]
parsed_stats = self.parse_stats(unparsed_stats)
@@ -335,13 +335,13 @@ class CGMinerAvalon(CGMiner):
async def _get_fault_light(self, api_stats: dict = None) -> bool: # noqa
if self.light:
return self.light
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
unparsed_stats = api_stats["STATS"][0]["MM ID0"]
parsed_stats = self.parse_stats(unparsed_stats)

View File

@@ -145,9 +145,13 @@ class ePIC(BaseMiner):
return False
async def _get_mac(self, web_network: dict = None) -> str:
if not web_network:
web_network = await self.web.network()
if web_network:
if web_network is None:
try:
web_network = await self.web.network()
except APIError:
pass
if web_network is not None:
try:
for network in web_network:
mac = web_network[network]["mac_address"]
@@ -156,9 +160,13 @@ class ePIC(BaseMiner):
pass
async def _get_hostname(self, web_summary: dict = None) -> str:
if not web_summary:
web_summary = await self.web.summary()
if web_summary:
if web_summary is None:
try:
web_summary = await self.web.summary()
except APIError:
pass
if web_summary is not None:
try:
hostname = web_summary["Hostname"]
return hostname
@@ -166,10 +174,13 @@ class ePIC(BaseMiner):
pass
async def _get_wattage(self, web_summary: dict = None) -> Optional[int]:
if not web_summary:
web_summary = await self.web.summary()
if web_summary is None:
try:
web_summary = await self.web.summary()
except APIError:
pass
if web_summary:
if web_summary is not None:
try:
wattage = web_summary["Power Supply Stats"]["Input Power"]
wattage = round(wattage)
@@ -178,14 +189,13 @@ class ePIC(BaseMiner):
pass
async def _get_hashrate(self, web_summary: dict = None) -> Optional[float]:
# get hr from API
if not web_summary:
if web_summary is None:
try:
web_summary = await self.web.summary()
except APIError:
pass
if web_summary:
if web_summary is not None:
try:
hashrate = 0
if web_summary["HBs"] is not None:
@@ -196,14 +206,13 @@ class ePIC(BaseMiner):
pass
async def _get_expected_hashrate(self, web_summary: dict = None) -> Optional[float]:
# get hr from API
if not web_summary:
if web_summary is None:
try:
web_summary = await self.web.summary()
except APIError:
pass
if web_summary:
if web_summary is not None:
try:
hashrate = 0
if web_summary.get("HBs") is not None:
@@ -219,10 +228,13 @@ class ePIC(BaseMiner):
pass
async def _get_fw_ver(self, web_summary: dict = None) -> Optional[str]:
if not web_summary:
web_summary = await self.web.summary()
if web_summary is None:
try:
web_summary = await self.web.summary()
except APIError:
pass
if web_summary:
if web_summary is not None:
try:
fw_ver = web_summary["Software"]
fw_ver = fw_ver.split(" ")[1].replace("v", "")
@@ -231,7 +243,7 @@ class ePIC(BaseMiner):
pass
async def _get_fans(self, web_summary: dict = None) -> List[Fan]:
if not web_summary:
if web_summary is None:
try:
web_summary = await self.web.summary()
except APIError:
@@ -239,7 +251,7 @@ class ePIC(BaseMiner):
fans = []
if web_summary:
if web_summary is not None:
for fan in web_summary["Fans Rpm"]:
try:
fans.append(Fan(web_summary["Fans Rpm"][fan]))
@@ -250,12 +262,13 @@ class ePIC(BaseMiner):
async def _get_hashboards(
self, web_summary: dict = None, web_hashrate: dict = None
) -> List[HashBoard]:
if not web_summary:
if web_summary is None:
try:
web_summary = await self.web.summary()
except APIError:
pass
if not web_hashrate:
if not web_hashrate is not None:
try:
web_hashrate = await self.web.hashrate()
except APIError:
@@ -283,9 +296,13 @@ class ePIC(BaseMiner):
return None
async def _get_uptime(self, web_summary: dict = None) -> Optional[int]:
if not web_summary:
web_summary = await self.web.summary()
if web_summary:
if web_summary is None:
try:
web_summary = await self.web.summary()
except APIError:
pass
if web_summary is not None:
try:
uptime = web_summary["Session"]["Uptime"]
return uptime
@@ -294,9 +311,13 @@ class ePIC(BaseMiner):
return None
async def _get_fault_light(self, web_summary: dict = None) -> bool:
if not web_summary:
web_summary = await self.web.summary()
if web_summary:
if web_summary is None:
try:
web_summary = await self.web.summary()
except APIError:
pass
if web_summary is not None:
try:
light = web_summary["Misc"]["Locate Miner State"]
return light
@@ -306,9 +327,13 @@ class ePIC(BaseMiner):
async def _get_errors(self, web_summary: dict = None) -> List[MinerErrorData]:
if not web_summary:
web_summary = await self.web.summary()
try:
web_summary = await self.web.summary()
except APIError:
pass
errors = []
if web_summary:
if web_summary is not None:
try:
error = web_summary["Status"]["Last Error"]
if error is not None:

View File

@@ -181,20 +181,20 @@ class Innosilicon(CGMiner):
if web_get_all:
web_get_all = web_get_all["all"]
if not web_get_all and not web_overview:
if web_get_all is None and web_overview is None:
try:
web_overview = await self.web.overview()
except APIError:
pass
if web_get_all:
if web_get_all is not None:
try:
mac = web_get_all["mac"]
return mac.upper()
except KeyError:
pass
if web_overview:
if web_overview is not None:
try:
mac = web_overview["version"]["ethaddr"]
return mac.upper()
@@ -207,13 +207,13 @@ class Innosilicon(CGMiner):
if web_get_all:
web_get_all = web_get_all["all"]
if not api_summary and not web_get_all:
if api_summary is None and web_get_all is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if web_get_all:
if web_get_all is not None:
try:
if "Hash Rate H" in web_get_all["total_hash"].keys():
return round(
@@ -227,7 +227,7 @@ class Innosilicon(CGMiner):
except KeyError:
pass
if api_summary:
if api_summary is not None:
try:
return round(float(api_summary["SUMMARY"][0]["MHS 1m"] / 1000000), 2)
except (KeyError, IndexError):
@@ -244,13 +244,13 @@ class Innosilicon(CGMiner):
for i in range(self.expected_hashboards)
]
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if not web_get_all:
if web_get_all is None:
try:
web_get_all = await self.web.get_all()
except APIError:
@@ -258,7 +258,7 @@ class Innosilicon(CGMiner):
else:
web_get_all = web_get_all["all"]
if api_stats:
if api_stats is not None:
if api_stats.get("STATS"):
for board in api_stats["STATS"]:
try:
@@ -270,7 +270,7 @@ class Innosilicon(CGMiner):
hashboards[idx].chips = chips
hashboards[idx].missing = False
if web_get_all:
if web_get_all is not None:
if web_get_all.get("chain"):
for board in web_get_all["chain"]:
idx = board.get("ASC")
@@ -297,7 +297,7 @@ class Innosilicon(CGMiner):
if web_get_all:
web_get_all = web_get_all["all"]
if not web_get_all:
if web_get_all is None:
try:
web_get_all = await self.web.get_all()
except APIError:
@@ -305,19 +305,19 @@ class Innosilicon(CGMiner):
else:
web_get_all = web_get_all["all"]
if web_get_all:
if web_get_all is not None:
try:
return web_get_all["power"]
except KeyError:
pass
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
if api_stats.get("STATS"):
for board in api_stats["STATS"]:
try:
@@ -332,7 +332,7 @@ class Innosilicon(CGMiner):
if web_get_all:
web_get_all = web_get_all["all"]
if not web_get_all:
if web_get_all is None:
try:
web_get_all = await self.web.get_all()
except APIError:
@@ -341,7 +341,7 @@ class Innosilicon(CGMiner):
web_get_all = web_get_all["all"]
fans = [Fan() for _ in range(self.expected_fans)]
if web_get_all:
if web_get_all is not None:
try:
spd = web_get_all["fansSpeed"]
except KeyError:
@@ -357,13 +357,13 @@ class Innosilicon(CGMiner):
self, web_get_error_detail: dict = None
) -> List[MinerErrorData]:
errors = []
if not web_get_error_detail:
if web_get_error_detail is None:
try:
web_get_error_detail = await self.web.get_error_detail()
except APIError:
pass
if web_get_error_detail:
if web_get_error_detail is not None:
try:
# only 1 error?
# TODO: check if this should be a loop, can't remember.
@@ -380,7 +380,7 @@ class Innosilicon(CGMiner):
if web_get_all:
web_get_all = web_get_all["all"]
if not web_get_all:
if web_get_all is None:
try:
web_get_all = await self.web.get_all()
except APIError:
@@ -388,7 +388,7 @@ class Innosilicon(CGMiner):
else:
web_get_all = web_get_all["all"]
if web_get_all:
if web_get_all is not None:
try:
level = web_get_all["running_mode"]["level"]
except KeyError:

View File

@@ -175,13 +175,13 @@ class LUXMiner(BaseMiner):
async def _get_mac(self, api_config: dict = None) -> Optional[str]:
mac = None
if not api_config:
if api_config is None:
try:
api_config = await self.api.config()
except APIError:
return None
if api_config:
if api_config is not None:
try:
mac = api_config["CONFIG"][0]["MACAddr"]
except KeyError:
@@ -202,13 +202,13 @@ class LUXMiner(BaseMiner):
pass
async def _get_hashrate(self, api_summary: dict = None) -> Optional[float]:
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
return round(float(api_summary["SUMMARY"][0]["GHS 5s"] / 1000), 2)
except (LookupError, ValueError, TypeError):
@@ -217,13 +217,13 @@ class LUXMiner(BaseMiner):
async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]:
hashboards = []
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
board_offset = -1
boards = api_stats["STATS"]
@@ -272,13 +272,13 @@ class LUXMiner(BaseMiner):
return None
async def _get_wattage(self, api_power: dict) -> Optional[int]:
if not api_power:
if api_power is None:
try:
api_power = await self.api.power()
except APIError:
pass
if api_power:
if api_power is not None:
try:
return api_power["POWER"][0]["Watts"]
except (LookupError, ValueError, TypeError):
@@ -288,7 +288,7 @@ class LUXMiner(BaseMiner):
return None
async def _get_fans(self, api_fans: dict = None) -> List[Fan]:
if not api_fans:
if api_fans is None:
try:
api_fans = await self.api.fans()
except APIError:
@@ -296,7 +296,7 @@ class LUXMiner(BaseMiner):
fans = []
if api_fans:
if api_fans is not None:
for fan in range(self.expected_fans):
try:
fans.append(Fan(api_fans["FANS"][fan]["RPM"]))
@@ -314,13 +314,13 @@ class LUXMiner(BaseMiner):
pass
async def _get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]:
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
expected_rate = api_stats["STATS"][1]["total_rateideal"]
try:
@@ -340,13 +340,13 @@ class LUXMiner(BaseMiner):
pass
async def _get_uptime(self, api_stats: dict = None) -> Optional[int]:
if not api_stats:
if api_stats is None:
try:
api_stats = await self.api.stats()
except APIError:
pass
if api_stats:
if api_stats is not None:
try:
return int(api_stats["STATS"][1]["Elapsed"])
except LookupError:

View File

@@ -121,17 +121,17 @@ class VNish(BMMiner):
return False
async def _get_mac(self, web_summary: dict = None) -> str:
if not web_summary:
if web_summary is None:
web_info = await self.web.info()
if web_info:
if web_info is not None:
try:
mac = web_info["system"]["network_status"]["mac"]
return mac
except KeyError:
pass
if web_summary:
if web_summary is not None:
try:
mac = web_summary["system"]["network_status"]["mac"]
return mac
@@ -139,17 +139,17 @@ class VNish(BMMiner):
pass
async def _get_hostname(self, web_summary: dict = None) -> str:
if not web_summary:
if web_summary is None:
web_info = await self.web.info()
if web_info:
if web_info is not None:
try:
hostname = web_info["system"]["network_status"]["hostname"]
return hostname
except KeyError:
pass
if web_summary:
if web_summary is not None:
try:
hostname = web_summary["system"]["network_status"]["hostname"]
return hostname
@@ -157,10 +157,10 @@ class VNish(BMMiner):
pass
async def _get_wattage(self, web_summary: dict = None) -> Optional[int]:
if not web_summary:
if web_summary is None:
web_summary = await self.web.summary()
if web_summary:
if web_summary is not None:
try:
wattage = web_summary["miner"]["power_usage"]
wattage = round(wattage * 1000)
@@ -170,13 +170,13 @@ class VNish(BMMiner):
async def _get_hashrate(self, api_summary: dict = None) -> Optional[float]:
# get hr from API
if not api_summary:
if api_summary is None:
try:
api_summary = await self.api.summary()
except APIError:
pass
if api_summary:
if api_summary is not None:
try:
return round(
float(float(api_summary["SUMMARY"][0]["GHS 5s"]) / 1000), 2
@@ -186,10 +186,10 @@ class VNish(BMMiner):
pass
async def _get_wattage_limit(self, web_settings: dict = None) -> Optional[int]:
if not web_settings:
if web_settings is None:
web_settings = await self.web.summary()
if web_settings:
if web_settings is not None:
try:
wattage_limit = web_settings["miner"]["overclock"]["preset"]
if wattage_limit == "disabled":
@@ -199,10 +199,10 @@ class VNish(BMMiner):
pass
async def _get_fw_ver(self, web_summary: dict = None) -> Optional[str]:
if not web_summary:
if web_summary is None:
web_summary = await self.web.summary()
if web_summary:
if web_summary is not None:
try:
fw_ver = web_summary["miner"]["miner_type"]
fw_ver = fw_ver.split("(Vnish ")[1].replace(")", "")