From c0694688035359f22656e4508e1ff0aab7ddaf93 Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Mon, 15 Jan 2024 14:58:54 -0700 Subject: [PATCH] bug: fix some bugs with epic, update miner repr, and remove get_model from braiinsOS. --- pyasic/miners/backends/braiins_os.py | 5 ----- pyasic/miners/backends/epic.py | 27 +++++++++++++-------------- pyasic/miners/base.py | 2 +- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/pyasic/miners/backends/braiins_os.py b/pyasic/miners/backends/braiins_os.py index 28c0a375..5f3222ec 100644 --- a/pyasic/miners/backends/braiins_os.py +++ b/pyasic/miners/backends/braiins_os.py @@ -808,11 +808,6 @@ class BOSer(BaseMiner): except (LookupError, TypeError): pass - async def _get_model(self) -> Optional[str]: - if self.model is not None: - return self.model + " (BOS)" - return "? (BOS)" - async def _get_api_ver(self, api_version: dict = None) -> Optional[str]: if not api_version: try: diff --git a/pyasic/miners/backends/epic.py b/pyasic/miners/backends/epic.py index 979a65ab..1f58a1d7 100644 --- a/pyasic/miners/backends/epic.py +++ b/pyasic/miners/backends/epic.py @@ -192,8 +192,7 @@ class ePIC(BaseMiner): for hb in web_summary["HBs"]: hashrate += hb["Hashrate"][0] return round(float(float(hashrate / 1000000)), 2) - except (LookupError, ValueError, TypeError) as e: - logger.error(e) + except (LookupError, ValueError, TypeError): pass async def _get_expected_hashrate(self, web_summary: dict = None) -> Optional[float]: @@ -207,7 +206,7 @@ class ePIC(BaseMiner): if web_summary: try: hashrate = 0 - if web_summary["HBs"] is not None: + if web_summary.get("HBs") is not None: for hb in web_summary["HBs"]: if hb["Hashrate"][1] == 0: ideal = 1.0 @@ -216,8 +215,7 @@ class ePIC(BaseMiner): hashrate += hb["Hashrate"][0] / ideal return round(float(float(hashrate / 1000000)), 2) - except (LookupError, ValueError, TypeError) as e: - logger.error(e) + except (LookupError, ValueError, TypeError): pass async def _get_fw_ver(self, web_summary: dict = None) -> Optional[str]: @@ -266,7 +264,8 @@ class ePIC(BaseMiner): HashBoard(slot=i, expected_chips=self.expected_chips) for i in range(self.expected_hashboards) ] - if web_summary["HBs"] is not None: + + if web_summary.get("HBs") is not None: for hb in web_summary["HBs"]: for hr in web_hashrate: if hr["Index"] == hb["Index"]: @@ -319,26 +318,26 @@ class ePIC(BaseMiner): pass return errors - def fault_light_off(self) -> bool: + async def fault_light_off(self) -> bool: return False - def fault_light_on(self) -> bool: + async def fault_light_on(self) -> bool: return False - def _get_api_ver(self, *args, **kwargs) -> Optional[str]: + async def _get_api_ver(self, *args, **kwargs) -> Optional[str]: pass - def _get_env_temp(self, *args, **kwargs) -> Optional[float]: + async def _get_env_temp(self, *args, **kwargs) -> Optional[float]: pass - def _get_fan_psu(self, *args, **kwargs) -> Optional[int]: + async def _get_fan_psu(self, *args, **kwargs) -> Optional[int]: pass - def _get_wattage_limit(self, *args, **kwargs) -> Optional[int]: + async def _get_wattage_limit(self, *args, **kwargs) -> Optional[int]: pass - def send_config(self, config: MinerConfig, user_suffix: str = None) -> None: + async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None: pass - def set_power_limit(self, wattage: int) -> bool: + async def set_power_limit(self, wattage: int) -> bool: return False diff --git a/pyasic/miners/base.py b/pyasic/miners/base.py index 68f1013e..161dd2db 100644 --- a/pyasic/miners/base.py +++ b/pyasic/miners/base.py @@ -130,7 +130,7 @@ class BaseMiner(ABC): return object.__new__(cls) def __repr__(self): - return f"{'' if not self.api_type else self.api_type}{'' if not self.model else ' ' + self.model}: {str(self.ip)}" + return f"{self.model}: {str(self.ip)}" def __lt__(self, other): return ipaddress.ip_address(self.ip) < ipaddress.ip_address(other.ip)