From a8428a2739d27e4d9248434bda369ec0739d516a Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Thu, 11 Jan 2024 11:33:44 -0700 Subject: [PATCH 01/14] refactor: remove parameters from `get_{x}` functions and move them to `_get_{x}(**params)`. Add `miner.fw_str`, and `miner.raw_model`. Remove `model` from `get_data` exclude. Swap `fan_count` to `expected_fans`. --- pyasic/load/__init__.py | 8 +- pyasic/miners/backends/antminer.py | 98 ++++++----- pyasic/miners/backends/bfgminer.py | 87 ++++------ pyasic/miners/backends/bfgminer_goldshell.py | 43 +++-- pyasic/miners/backends/bmminer.py | 91 ++++------ pyasic/miners/backends/bosminer.py | 78 ++++----- pyasic/miners/backends/bosminer_old.py | 32 ++-- pyasic/miners/backends/btminer.py | 89 ++++------ pyasic/miners/backends/cgminer.py | 84 ++++----- pyasic/miners/backends/cgminer_avalon.py | 61 ++++--- pyasic/miners/backends/epic.py | 76 ++++---- pyasic/miners/backends/hiveon.py | 6 +- pyasic/miners/backends/luxminer.py | 73 ++++---- pyasic/miners/backends/vnish.py | 55 +++--- pyasic/miners/base.py | 163 ++++++++++++------ .../miners/innosilicon/cgminer/A10X/A10X.py | 4 +- pyasic/miners/types/antminer/X15/Z15.py | 2 +- pyasic/miners/types/antminer/X17/S17.py | 8 +- pyasic/miners/types/antminer/X17/T17.py | 6 +- pyasic/miners/types/antminer/X19/S19.py | 34 ++-- pyasic/miners/types/antminer/X19/T19.py | 2 +- pyasic/miners/types/antminer/X3/D3.py | 2 +- pyasic/miners/types/antminer/X3/HS3.py | 2 +- pyasic/miners/types/antminer/X3/L3.py | 2 +- pyasic/miners/types/antminer/X5/DR5.py | 2 +- pyasic/miners/types/antminer/X7/L7.py | 2 +- pyasic/miners/types/antminer/X9/E9.py | 2 +- pyasic/miners/types/antminer/X9/S9.py | 6 +- pyasic/miners/types/antminer/X9/T9.py | 2 +- pyasic/miners/types/avalonminer/A10X/A1026.py | 2 +- pyasic/miners/types/avalonminer/A10X/A1047.py | 2 +- pyasic/miners/types/avalonminer/A10X/A1066.py | 2 +- pyasic/miners/types/avalonminer/A11X/A1166.py | 2 +- pyasic/miners/types/avalonminer/A12X/A1246.py | 2 +- pyasic/miners/types/avalonminer/A7X/A721.py | 2 +- pyasic/miners/types/avalonminer/A7X/A741.py | 2 +- pyasic/miners/types/avalonminer/A7X/A761.py | 2 +- pyasic/miners/types/avalonminer/A8X/A821.py | 2 +- pyasic/miners/types/avalonminer/A8X/A841.py | 2 +- pyasic/miners/types/avalonminer/A8X/A851.py | 2 +- pyasic/miners/types/avalonminer/A9X/A921.py | 2 +- pyasic/miners/types/goldshell/X5/CK5.py | 2 +- pyasic/miners/types/goldshell/X5/HS5.py | 2 +- pyasic/miners/types/goldshell/X5/KD5.py | 2 +- pyasic/miners/types/goldshell/XMax/KDMax.py | 2 +- pyasic/miners/types/innosilicon/A10X/A10X.py | 2 +- pyasic/miners/types/innosilicon/T3X/T3H.py | 2 +- pyasic/miners/types/whatsminer/M2X/M20.py | 2 +- pyasic/miners/types/whatsminer/M2X/M20P.py | 4 +- pyasic/miners/types/whatsminer/M2X/M20S.py | 6 +- .../miners/types/whatsminer/M2X/M20S_Plus.py | 2 +- pyasic/miners/types/whatsminer/M2X/M21.py | 2 +- pyasic/miners/types/whatsminer/M2X/M21S.py | 6 +- .../miners/types/whatsminer/M2X/M21S_Plus.py | 2 +- pyasic/miners/types/whatsminer/M2X/M29.py | 2 +- pyasic/miners/types/whatsminer/M3X/M30.py | 4 +- pyasic/miners/types/whatsminer/M3X/M30K.py | 2 +- pyasic/miners/types/whatsminer/M3X/M30L.py | 2 +- pyasic/miners/types/whatsminer/M3X/M30S.py | 58 +++---- .../miners/types/whatsminer/M3X/M30S_Plus.py | 62 +++---- .../types/whatsminer/M3X/M30S_Plus_Plus.py | 42 ++--- pyasic/miners/types/whatsminer/M3X/M31.py | 4 +- pyasic/miners/types/whatsminer/M3X/M31H.py | 4 +- pyasic/miners/types/whatsminer/M3X/M31L.py | 2 +- pyasic/miners/types/whatsminer/M3X/M31S.py | 24 +-- pyasic/miners/types/whatsminer/M3X/M31SE.py | 6 +- .../miners/types/whatsminer/M3X/M31S_Plus.py | 44 ++--- pyasic/miners/types/whatsminer/M3X/M32.py | 4 +- pyasic/miners/types/whatsminer/M3X/M32S.py | 2 +- pyasic/miners/types/whatsminer/M3X/M33.py | 6 +- pyasic/miners/types/whatsminer/M3X/M33S.py | 2 +- .../miners/types/whatsminer/M3X/M33S_Plus.py | 6 +- .../types/whatsminer/M3X/M33S_Plus_Plus.py | 6 +- .../miners/types/whatsminer/M3X/M34S_Plus.py | 2 +- pyasic/miners/types/whatsminer/M3X/M36S.py | 2 +- .../miners/types/whatsminer/M3X/M36S_Plus.py | 2 +- .../types/whatsminer/M3X/M36S_Plus_Plus.py | 2 +- pyasic/miners/types/whatsminer/M3X/M39.py | 6 +- pyasic/miners/types/whatsminer/M5X/M50.py | 26 +-- pyasic/miners/types/whatsminer/M5X/M50S.py | 16 +- .../miners/types/whatsminer/M5X/M50S_Plus.py | 8 +- .../types/whatsminer/M5X/M50S_Plus_Plus.py | 6 +- pyasic/miners/types/whatsminer/M5X/M53.py | 2 +- pyasic/miners/types/whatsminer/M5X/M53S.py | 2 +- .../miners/types/whatsminer/M5X/M53S_Plus.py | 2 +- pyasic/miners/types/whatsminer/M5X/M56.py | 2 +- pyasic/miners/types/whatsminer/M5X/M56S.py | 2 +- .../miners/types/whatsminer/M5X/M56S_Plus.py | 2 +- pyasic/miners/types/whatsminer/M5X/M59.py | 2 +- pyasic/miners/types/whatsminer/M6X/M60.py | 8 +- pyasic/miners/types/whatsminer/M6X/M60S.py | 8 +- pyasic/miners/types/whatsminer/M6X/M63.py | 6 +- pyasic/miners/types/whatsminer/M6X/M63S.py | 6 +- pyasic/miners/types/whatsminer/M6X/M66.py | 4 +- pyasic/miners/types/whatsminer/M6X/M66S.py | 6 +- tests/miners_tests/__init__.py | 1 - 96 files changed, 771 insertions(+), 814 deletions(-) diff --git a/pyasic/load/__init__.py b/pyasic/load/__init__.py index f706c256..012c15fe 100644 --- a/pyasic/load/__init__.py +++ b/pyasic/load/__init__.py @@ -66,14 +66,14 @@ class _MinerPhaseBalancer: str(miner.ip): { "miner": miner, "set": 0, - "min": miner.fan_count * FAN_USAGE, + "min": miner.expected_fans * FAN_USAGE, } for miner in miners } for miner in miners: if ( isinstance(miner, BTMiner) - and not (miner.model.startswith("M2") if miner.model else True) + and not (miner.raw_model.startswith("M2") if miner.raw_model else True) ) or isinstance(miner, BOSMiner): if isinstance(miner, S9): self.miners[str(miner.ip)]["tune"] = True @@ -98,8 +98,8 @@ class _MinerPhaseBalancer: self.miners[str(miner.ip)]["tune"] = False self.miners[str(miner.ip)]["shutdown"] = True self.miners[str(miner.ip)]["max"] = 3600 - if miner.model: - if miner.model.startswith("M2"): + if miner.raw_model: + if miner.raw_model.startswith("M2"): self.miners[str(miner.ip)]["tune"] = False self.miners[str(miner.ip)]["shutdown"] = True self.miners[str(miner.ip)]["max"] = 2400 diff --git a/pyasic/miners/backends/antminer.py b/pyasic/miners/backends/antminer.py index e314f761..1de438e9 100644 --- a/pyasic/miners/backends/antminer.py +++ b/pyasic/miners/backends/antminer.py @@ -34,44 +34,43 @@ from pyasic.web.antminer import AntminerModernWebAPI, AntminerOldWebAPI ANTMINER_MODERN_DATA_LOC = DataLocations( **{ str(DataOptions.MAC): DataFunction( - "get_mac", [WebAPICommand("web_get_system_info", "get_system_info")] + "_get_mac", [WebAPICommand("web_get_system_info", "get_system_info")] ), - str(DataOptions.MODEL): DataFunction("get_model"), str(DataOptions.API_VERSION): DataFunction( - "get_api_ver", [RPCAPICommand("api_version", "version")] + "_get_api_ver", [RPCAPICommand("api_version", "version")] ), str(DataOptions.FW_VERSION): DataFunction( - "get_fw_ver", [RPCAPICommand("api_version", "version")] + "_get_fw_ver", [RPCAPICommand("api_version", "version")] ), str(DataOptions.HOSTNAME): DataFunction( - "get_hostname", [WebAPICommand("web_get_system_info", "get_system_info")] + "_get_hostname", [WebAPICommand("web_get_system_info", "get_system_info")] ), str(DataOptions.HASHRATE): DataFunction( - "get_hashrate", [RPCAPICommand("api_summary", "summary")] + "_get_hashrate", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] + "_get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.HASHBOARDS): DataFunction("get_hashboards", []), - str(DataOptions.ENVIRONMENT_TEMP): DataFunction("get_env_temp"), - str(DataOptions.WATTAGE): DataFunction("get_wattage"), - str(DataOptions.WATTAGE_LIMIT): DataFunction("get_wattage_limit"), + str(DataOptions.HASHBOARDS): DataFunction("_get_hashboards"), + str(DataOptions.ENVIRONMENT_TEMP): DataFunction("_get_env_temp"), + str(DataOptions.WATTAGE): DataFunction("_get_wattage"), + str(DataOptions.WATTAGE_LIMIT): DataFunction("_get_wattage_limit"), str(DataOptions.FANS): DataFunction( - "get_fans", [RPCAPICommand("api_stats", "stats")] + "_get_fans", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), str(DataOptions.ERRORS): DataFunction( - "get_errors", [WebAPICommand("web_summary", "summary")] + "_get_errors", [WebAPICommand("web_summary", "summary")] ), str(DataOptions.FAULT_LIGHT): DataFunction( - "get_fault_light", + "_get_fault_light", [WebAPICommand("web_get_blink_status", "get_blink_status")], ), str(DataOptions.IS_MINING): DataFunction( - "is_mining", [WebAPICommand("web_get_conf", "get_miner_conf")] + "_is_mining", [WebAPICommand("web_get_conf", "get_miner_conf")] ), str(DataOptions.UPTIME): DataFunction( - "get_uptime", [RPCAPICommand("api_stats", "stats")] + "_get_uptime", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.CONFIG): DataFunction("get_config"), } @@ -141,7 +140,7 @@ class AntminerModern(BMMiner): await self.send_config(cfg) return True - async def get_hostname(self, web_get_system_info: dict = None) -> Union[str, None]: + async def _get_hostname(self, web_get_system_info: dict = None) -> Union[str, None]: if not web_get_system_info: try: web_get_system_info = await self.web.get_system_info() @@ -154,7 +153,7 @@ class AntminerModern(BMMiner): except KeyError: pass - async def get_mac(self, web_get_system_info: dict = None) -> Union[str, None]: + async def _get_mac(self, web_get_system_info: dict = None) -> Union[str, None]: if not web_get_system_info: try: web_get_system_info = await self.web.get_system_info() @@ -174,7 +173,7 @@ class AntminerModern(BMMiner): except KeyError: pass - async def get_errors(self, web_summary: dict = None) -> List[MinerErrorData]: + async def _get_errors(self, web_summary: dict = None) -> List[MinerErrorData]: if not web_summary: try: web_summary = await self.web.summary() @@ -194,7 +193,7 @@ class AntminerModern(BMMiner): pass return errors - async def get_hashboards(self) -> List[HashBoard]: + async def _get_hashboards(self) -> List[HashBoard]: hashboards = [ HashBoard(idx, expected_chips=self.expected_chips) for idx in range(self.expected_hashboards) @@ -230,7 +229,7 @@ class AntminerModern(BMMiner): pass return hashboards - async def get_fault_light(self, web_get_blink_status: dict = None) -> bool: + async def _get_fault_light(self, web_get_blink_status: dict = None) -> bool: if self.light: return self.light @@ -247,7 +246,7 @@ class AntminerModern(BMMiner): pass return self.light - async def get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]: + async def _get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]: if not api_stats: try: api_stats = await self.api.stats() @@ -312,7 +311,7 @@ class AntminerModern(BMMiner): protocol=protocol, ) - async def is_mining(self, web_get_conf: dict = None) -> Optional[bool]: + async def _is_mining(self, web_get_conf: dict = None) -> Optional[bool]: if not web_get_conf: try: web_get_conf = await self.web.get_miner_conf() @@ -329,7 +328,7 @@ class AntminerModern(BMMiner): except LookupError: pass - async def get_uptime(self, api_stats: dict = None) -> Optional[int]: + async def _get_uptime(self, api_stats: dict = None) -> Optional[int]: if not api_stats: try: api_stats = await self.api.stats() @@ -345,43 +344,42 @@ class AntminerModern(BMMiner): ANTMINER_OLD_DATA_LOC = DataLocations( **{ - str(DataOptions.MAC): DataFunction("get_mac"), - str(DataOptions.MODEL): DataFunction("get_model"), + str(DataOptions.MAC): DataFunction("_get_mac"), str(DataOptions.API_VERSION): DataFunction( - "get_api_ver", [RPCAPICommand("api_version", "version")] + "_get_api_ver", [RPCAPICommand("api_version", "version")] ), str(DataOptions.FW_VERSION): DataFunction( - "get_fw_ver", [RPCAPICommand("api_version", "version")] + "_get_fw_ver", [RPCAPICommand("api_version", "version")] ), str(DataOptions.HOSTNAME): DataFunction( - "get_hostname", [WebAPICommand("web_get_system_info", "get_system_info")] + "_get_hostname", [WebAPICommand("web_get_system_info", "get_system_info")] ), str(DataOptions.HASHRATE): DataFunction( - "get_hashrate", [RPCAPICommand("api_summary", "summary")] + "_get_hashrate", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] + "_get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.HASHBOARDS): DataFunction( - "get_hashboards", [RPCAPICommand("api_stats", "stats")] + "_get_hashboards", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.ENVIRONMENT_TEMP): DataFunction("get_env_temp"), - str(DataOptions.WATTAGE): DataFunction("get_wattage"), - str(DataOptions.WATTAGE_LIMIT): DataFunction("get_wattage_limit"), + str(DataOptions.ENVIRONMENT_TEMP): DataFunction("_get_env_temp"), + str(DataOptions.WATTAGE): DataFunction("_get_wattage"), + str(DataOptions.WATTAGE_LIMIT): DataFunction("_get_wattage_limit"), str(DataOptions.FANS): DataFunction( - "get_fans", [RPCAPICommand("api_stats", "stats")] + "_get_fans", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), - str(DataOptions.ERRORS): DataFunction("get_errors"), + str(DataOptions.FAN_PSU): DataFunction("_get_fan_psu"), + str(DataOptions.ERRORS): DataFunction("_get_errors"), str(DataOptions.FAULT_LIGHT): DataFunction( - "get_fault_light", + "_get_fault_light", [WebAPICommand("web_get_blink_status", "get_blink_status")], ), str(DataOptions.IS_MINING): DataFunction( - "is_mining", [WebAPICommand("web_get_conf", "get_miner_conf")] + "_is_mining", [WebAPICommand("web_get_conf", "get_miner_conf")] ), str(DataOptions.UPTIME): DataFunction( - "get_uptime", [RPCAPICommand("api_stats", "stats")] + "_get_uptime", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.CONFIG): DataFunction("get_config"), } @@ -408,7 +406,7 @@ class AntminerOld(CGMiner): self.config = config await self.web.set_miner_conf(config.as_am_old(user_suffix=user_suffix)) - async def get_mac(self) -> Union[str, None]: + async def _get_mac(self) -> Union[str, None]: try: data = await self.web.get_system_info() if data: @@ -445,7 +443,7 @@ class AntminerOld(CGMiner): return True return False - async def get_fault_light(self, web_get_blink_status: dict = None) -> bool: + async def _get_fault_light(self, web_get_blink_status: dict = None) -> bool: if self.light: return self.light @@ -462,7 +460,7 @@ class AntminerOld(CGMiner): pass return self.light - async def get_hostname(self, web_get_system_info: dict = None) -> Optional[str]: + async def _get_hostname(self, web_get_system_info: dict = None) -> Optional[str]: if not web_get_system_info: try: web_get_system_info = await self.web.get_system_info() @@ -475,14 +473,14 @@ class AntminerOld(CGMiner): except KeyError: pass - async def get_fans(self, api_stats: dict = None) -> List[Fan]: + async def _get_fans(self, api_stats: dict = None) -> List[Fan]: if not api_stats: try: api_stats = await self.api.stats() except APIError: pass - fans_data = [Fan() for _ in range(self.fan_count)] + fans_data = [Fan() for _ in range(self.expected_fans)] if api_stats: try: fan_offset = -1 @@ -495,7 +493,7 @@ class AntminerOld(CGMiner): if fan_offset == -1: fan_offset = 3 - for fan in range(self.fan_count): + for fan in range(self.expected_fans): fans_data[fan].speed = api_stats["STATS"][1].get( f"fan{fan_offset+fan}", 0 ) @@ -503,7 +501,7 @@ class AntminerOld(CGMiner): pass return fans_data - async def get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: + async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: hashboards = [] if not api_stats: @@ -557,7 +555,7 @@ class AntminerOld(CGMiner): return hashboards - async def is_mining(self, web_get_conf: dict = None) -> Optional[bool]: + async def _is_mining(self, web_get_conf: dict = None) -> Optional[bool]: if not web_get_conf: try: web_get_conf = await self.web.get_miner_conf() @@ -582,7 +580,7 @@ class AntminerOld(CGMiner): else: return False - async def get_uptime(self, api_stats: dict = None) -> Optional[int]: + async def _get_uptime(self, api_stats: dict = None) -> Optional[int]: if not api_stats: try: api_stats = await self.api.stats() diff --git a/pyasic/miners/backends/bfgminer.py b/pyasic/miners/backends/bfgminer.py index 06f83423..71d36d46 100644 --- a/pyasic/miners/backends/bfgminer.py +++ b/pyasic/miners/backends/bfgminer.py @@ -32,35 +32,34 @@ from pyasic.miners.base import ( BFGMINER_DATA_LOC = DataLocations( **{ - str(DataOptions.MAC): DataFunction("get_mac"), - str(DataOptions.MODEL): DataFunction("get_model"), + str(DataOptions.MAC): DataFunction("_get_mac"), str(DataOptions.API_VERSION): DataFunction( - "get_api_ver", [RPCAPICommand("api_version", "version")] + "_get_api_ver", [RPCAPICommand("api_version", "version")] ), str(DataOptions.FW_VERSION): DataFunction( - "get_fw_ver", [RPCAPICommand("api_version", "version")] + "_get_fw_ver", [RPCAPICommand("api_version", "version")] ), - str(DataOptions.HOSTNAME): DataFunction("get_hostname"), + str(DataOptions.HOSTNAME): DataFunction("_get_hostname"), str(DataOptions.HASHRATE): DataFunction( - "get_hashrate", [RPCAPICommand("api_summary", "summary")] + "_get_hashrate", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] + "_get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.HASHBOARDS): DataFunction( - "get_hashboards", [RPCAPICommand("api_stats", "stats")] + "_get_hashboards", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.ENVIRONMENT_TEMP): DataFunction("get_env_temp"), - str(DataOptions.WATTAGE): DataFunction("get_wattage"), - str(DataOptions.WATTAGE_LIMIT): DataFunction("get_wattage_limit"), + str(DataOptions.ENVIRONMENT_TEMP): DataFunction("_get_env_temp"), + str(DataOptions.WATTAGE): DataFunction("_get_wattage"), + str(DataOptions.WATTAGE_LIMIT): DataFunction("_get_wattage_limit"), str(DataOptions.FANS): DataFunction( - "get_fans", [RPCAPICommand("api_stats", "stats")] + "_get_fans", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), - str(DataOptions.ERRORS): DataFunction("get_errors"), - str(DataOptions.FAULT_LIGHT): DataFunction("get_fault_light"), - str(DataOptions.IS_MINING): DataFunction("is_mining"), - str(DataOptions.UPTIME): DataFunction("get_uptime"), + str(DataOptions.FAN_PSU): DataFunction("_get_fan_psu"), + str(DataOptions.ERRORS): DataFunction("_get_errors"), + str(DataOptions.FAULT_LIGHT): DataFunction("_get_fault_light"), + str(DataOptions.IS_MINING): DataFunction("_is_mining"), + str(DataOptions.UPTIME): DataFunction("_get_uptime"), str(DataOptions.CONFIG): DataFunction("get_config"), } ) @@ -117,14 +116,10 @@ class BFGMiner(BaseMiner): ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## - async def get_mac(self) -> str: - return "00:00:00:00:00:00" - - async def get_api_ver(self, api_version: dict = None) -> Optional[str]: - # Check to see if the version info is already cached - if self.api_ver: - return self.api_ver + async def _get_mac(self) -> Optional[str]: + return None + async def _get_api_ver(self, api_version: dict = None) -> Optional[str]: if not api_version: try: api_version = await self.api.version() @@ -139,11 +134,7 @@ class BFGMiner(BaseMiner): return self.api_ver - async def get_fw_ver(self, api_version: dict = None) -> Optional[str]: - # Check to see if the version info is already cached - if self.fw_ver: - return self.fw_ver - + async def _get_fw_ver(self, api_version: dict = None) -> Optional[str]: if not api_version: try: api_version = await self.api.version() @@ -158,26 +149,16 @@ class BFGMiner(BaseMiner): return self.fw_ver - async def get_version( - self, api_version: dict = None - ) -> Tuple[Optional[str], Optional[str]]: - # check if version is cached - miner_version = namedtuple("MinerVersion", "api_ver fw_ver") - return miner_version( - api_ver=await self.get_api_ver(api_version), - fw_ver=await self.get_fw_ver(api_version=api_version), - ) - async def reboot(self) -> bool: return False - async def get_fan_psu(self): + async def _get_fan_psu(self): return None - async def get_hostname(self) -> Optional[str]: + async def _get_hostname(self) -> Optional[str]: return None - async def get_hashrate(self, api_summary: dict = None) -> Optional[float]: + async def _get_hashrate(self, api_summary: dict = None) -> Optional[float]: # get hr from API if not api_summary: try: @@ -191,7 +172,7 @@ class BFGMiner(BaseMiner): except (IndexError, KeyError, ValueError, TypeError): pass - async def get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: + async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: hashboards = [] if not api_stats: @@ -245,16 +226,16 @@ class BFGMiner(BaseMiner): return hashboards - async def get_env_temp(self) -> Optional[float]: + async def _get_env_temp(self) -> Optional[float]: return None - async def get_wattage(self) -> Optional[int]: + async def _get_wattage(self) -> Optional[int]: return None - async def get_wattage_limit(self) -> Optional[int]: + async def _get_wattage_limit(self) -> Optional[int]: return None - async def get_fans(self, api_stats: dict = None) -> List[Fan]: + async def _get_fans(self, api_stats: dict = None) -> List[Fan]: if not api_stats: try: api_stats = await self.api.stats() @@ -274,7 +255,7 @@ class BFGMiner(BaseMiner): if fan_offset == -1: fan_offset = 1 - for fan in range(self.fan_count): + for fan in range(self.expected_fans): fans_data[fan] = api_stats["STATS"][1].get( f"fan{fan_offset+fan}", 0 ) @@ -284,13 +265,13 @@ class BFGMiner(BaseMiner): return fans - async def get_errors(self) -> List[MinerErrorData]: + async def _get_errors(self) -> List[MinerErrorData]: return [] - async def get_fault_light(self) -> bool: + async def _get_fault_light(self) -> bool: return False - async def get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]: + async def _get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]: # X19 method, not sure compatibility if not api_stats: try: @@ -314,8 +295,8 @@ class BFGMiner(BaseMiner): except (KeyError, IndexError): pass - async def is_mining(self, *args, **kwargs) -> Optional[bool]: + async def _is_mining(self, *args, **kwargs) -> Optional[bool]: return None - async def get_uptime(self, *args, **kwargs) -> Optional[int]: + async def _get_uptime(self, *args, **kwargs) -> Optional[int]: return None diff --git a/pyasic/miners/backends/bfgminer_goldshell.py b/pyasic/miners/backends/bfgminer_goldshell.py index 07c2d0a9..ee8a3fb5 100644 --- a/pyasic/miners/backends/bfgminer_goldshell.py +++ b/pyasic/miners/backends/bfgminer_goldshell.py @@ -32,40 +32,39 @@ from pyasic.web.goldshell import GoldshellWebAPI GOLDSHELL_DATA_LOC = DataLocations( **{ str(DataOptions.MAC): DataFunction( - "get_mac", [WebAPICommand("web_setting", "setting")] + "_get_mac", [WebAPICommand("web_setting", "setting")] ), - str(DataOptions.MODEL): DataFunction("get_model"), str(DataOptions.API_VERSION): DataFunction( - "get_api_ver", [RPCAPICommand("api_version", "version")] + "_get_api_ver", [RPCAPICommand("api_version", "version")] ), str(DataOptions.FW_VERSION): DataFunction( - "get_fw_ver", [WebAPICommand("web_status", "status")] + "_get_fw_ver", [WebAPICommand("web_status", "status")] ), - str(DataOptions.HOSTNAME): DataFunction("get_hostname"), + str(DataOptions.HOSTNAME): DataFunction("_get_hostname"), str(DataOptions.HASHRATE): DataFunction( - "get_hashrate", [RPCAPICommand("api_summary", "summary")] + "_get_hashrate", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] + "_get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.HASHBOARDS): DataFunction( - "get_hashboards", + "_get_hashboards", [ RPCAPICommand("api_devs", "devs"), RPCAPICommand("api_devdetails", "devdetails"), ], ), - str(DataOptions.ENVIRONMENT_TEMP): DataFunction("get_env_temp"), - str(DataOptions.WATTAGE): DataFunction("get_wattage"), - str(DataOptions.WATTAGE_LIMIT): DataFunction("get_wattage_limit"), + str(DataOptions.ENVIRONMENT_TEMP): DataFunction("_get_env_temp"), + str(DataOptions.WATTAGE): DataFunction("_get_wattage"), + str(DataOptions.WATTAGE_LIMIT): DataFunction("_get_wattage_limit"), str(DataOptions.FANS): DataFunction( - "get_fans", [RPCAPICommand("api_stats", "stats")] + "_get_fans", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), - str(DataOptions.ERRORS): DataFunction("get_errors"), - str(DataOptions.FAULT_LIGHT): DataFunction("get_fault_light"), - str(DataOptions.IS_MINING): DataFunction("is_mining"), - str(DataOptions.UPTIME): DataFunction("get_uptime"), + str(DataOptions.FAN_PSU): DataFunction("_get_fan_psu"), + str(DataOptions.ERRORS): DataFunction("_get_errors"), + str(DataOptions.FAULT_LIGHT): DataFunction("_get_fault_light"), + str(DataOptions.IS_MINING): DataFunction("_is_mining"), + str(DataOptions.UPTIME): DataFunction("_get_uptime"), str(DataOptions.CONFIG): DataFunction("get_config"), } ) @@ -110,7 +109,7 @@ class BFGMinerGoldshell(BFGMiner): url=pool["url"], user=pool["user"], password=pool["pass"] ) - async def get_mac(self, web_setting: dict = None) -> str: + async def _get_mac(self, web_setting: dict = None) -> str: if not web_setting: try: web_setting = await self.web.setting() @@ -123,7 +122,7 @@ class BFGMinerGoldshell(BFGMiner): except KeyError: pass - async def get_fw_ver(self, web_status: dict = None) -> str: + async def _get_fw_ver(self, web_status: dict = None) -> str: if not web_status: try: web_status = await self.web.setting() @@ -136,7 +135,7 @@ class BFGMinerGoldshell(BFGMiner): except KeyError: pass - async def get_hashboards( + async def _get_hashboards( self, api_devs: dict = None, api_devdetails: dict = None ) -> List[HashBoard]: if not api_devs: @@ -186,8 +185,8 @@ class BFGMinerGoldshell(BFGMiner): return hashboards - async def is_mining(self, *args, **kwargs) -> Optional[bool]: + async def _is_mining(self, *args, **kwargs) -> Optional[bool]: return None - async def get_uptime(self, *args, **kwargs) -> Optional[int]: + async def _get_uptime(self, *args, **kwargs) -> Optional[int]: return None diff --git a/pyasic/miners/backends/bmminer.py b/pyasic/miners/backends/bmminer.py index 5999c692..a1b32f7e 100644 --- a/pyasic/miners/backends/bmminer.py +++ b/pyasic/miners/backends/bmminer.py @@ -33,36 +33,35 @@ from pyasic.miners.base import ( BMMINER_DATA_LOC = DataLocations( **{ - str(DataOptions.MAC): DataFunction("get_mac"), - str(DataOptions.MODEL): DataFunction("get_model"), + str(DataOptions.MAC): DataFunction("_get_mac"), str(DataOptions.API_VERSION): DataFunction( - "get_api_ver", [RPCAPICommand("api_version", "version")] + "_get_api_ver", [RPCAPICommand("api_version", "version")] ), str(DataOptions.FW_VERSION): DataFunction( - "get_fw_ver", [RPCAPICommand("api_version", "version")] + "_get_fw_ver", [RPCAPICommand("api_version", "version")] ), - str(DataOptions.HOSTNAME): DataFunction("get_hostname"), + str(DataOptions.HOSTNAME): DataFunction("_get_hostname"), str(DataOptions.HASHRATE): DataFunction( - "get_hashrate", [RPCAPICommand("api_summary", "summary")] + "_get_hashrate", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] + "_get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.HASHBOARDS): DataFunction( - "get_hashboards", [RPCAPICommand("api_stats", "stats")] + "_get_hashboards", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.ENVIRONMENT_TEMP): DataFunction("get_env_temp"), - str(DataOptions.WATTAGE): DataFunction("get_wattage"), - str(DataOptions.WATTAGE_LIMIT): DataFunction("get_wattage_limit"), + str(DataOptions.ENVIRONMENT_TEMP): DataFunction("_get_env_temp"), + str(DataOptions.WATTAGE): DataFunction("_get_wattage"), + str(DataOptions.WATTAGE_LIMIT): DataFunction("_get_wattage_limit"), str(DataOptions.FANS): DataFunction( - "get_fans", [RPCAPICommand("api_stats", "stats")] + "_get_fans", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), - str(DataOptions.ERRORS): DataFunction("get_errors"), - str(DataOptions.FAULT_LIGHT): DataFunction("get_fault_light"), - str(DataOptions.IS_MINING): DataFunction("is_mining"), + str(DataOptions.FAN_PSU): DataFunction("_get_fan_psu"), + str(DataOptions.ERRORS): DataFunction("_get_errors"), + str(DataOptions.FAULT_LIGHT): DataFunction("_get_fault_light"), + str(DataOptions.IS_MINING): DataFunction("_is_mining"), str(DataOptions.UPTIME): DataFunction( - "get_uptime", [RPCAPICommand("api_stats", "stats")] + "_get_uptime", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.CONFIG): DataFunction("get_config"), } @@ -156,14 +155,10 @@ class BMMiner(BaseMiner): ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## - async def get_mac(self) -> str: - return "00:00:00:00:00:00" - - async def get_api_ver(self, api_version: dict = None) -> Optional[str]: - # Check to see if the version info is already cached - if self.api_ver: - return self.api_ver + async def _get_mac(self) -> Optional[str]: + return None + async def _get_api_ver(self, api_version: dict = None) -> Optional[str]: if not api_version: try: api_version = await self.api.version() @@ -178,11 +173,7 @@ class BMMiner(BaseMiner): return self.api_ver - async def get_fw_ver(self, api_version: dict = None) -> Optional[str]: - # Check to see if the version info is already cached - if self.fw_ver: - return self.fw_ver - + async def _get_fw_ver(self, api_version: dict = None) -> Optional[str]: if not api_version: try: api_version = await self.api.version() @@ -197,24 +188,14 @@ class BMMiner(BaseMiner): return self.fw_ver - async def get_version( - self, api_version: dict = None - ) -> Tuple[Optional[str], Optional[str]]: - # check if version is cached - miner_version = namedtuple("MinerVersion", "api_ver fw_ver") - return miner_version( - api_ver=await self.get_api_ver(api_version), - fw_ver=await self.get_fw_ver(api_version=api_version), - ) - - async def get_fan_psu(self): + async def _get_fan_psu(self): return None - async def get_hostname(self) -> Optional[str]: + async def _get_hostname(self) -> Optional[str]: hn = await self.send_ssh_command("cat /proc/sys/kernel/hostname") return hn - async def get_hashrate(self, api_summary: dict = None) -> Optional[float]: + async def _get_hashrate(self, api_summary: dict = None) -> Optional[float]: # get hr from API if not api_summary: try: @@ -228,7 +209,7 @@ class BMMiner(BaseMiner): except (IndexError, KeyError, ValueError, TypeError): pass - async def get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: + async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: hashboards = [] if not api_stats: @@ -295,23 +276,23 @@ class BMMiner(BaseMiner): return hashboards - async def get_env_temp(self) -> Optional[float]: + async def _get_env_temp(self) -> Optional[float]: return None - async def get_wattage(self) -> Optional[int]: + async def _get_wattage(self) -> Optional[int]: return None - async def get_wattage_limit(self) -> Optional[int]: + async def _get_wattage_limit(self) -> Optional[int]: return None - async def get_fans(self, api_stats: dict = None) -> List[Fan]: + async def _get_fans(self, api_stats: dict = None) -> List[Fan]: if not api_stats: try: api_stats = await self.api.stats() except APIError: pass - fans = [Fan() for _ in range(self.fan_count)] + fans = [Fan() for _ in range(self.expected_fans)] if api_stats: try: fan_offset = -1 @@ -324,7 +305,7 @@ class BMMiner(BaseMiner): if fan_offset == -1: fan_offset = 1 - for fan in range(self.fan_count): + for fan in range(self.expected_fans): fans[fan].speed = api_stats["STATS"][1].get( f"fan{fan_offset+fan}", 0 ) @@ -333,13 +314,13 @@ class BMMiner(BaseMiner): return fans - async def get_errors(self) -> List[MinerErrorData]: + async def _get_errors(self) -> List[MinerErrorData]: return [] - async def get_fault_light(self) -> bool: + async def _get_fault_light(self) -> bool: return False - async def get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]: + async def _get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]: # X19 method, not sure compatibility if not api_stats: try: @@ -363,13 +344,13 @@ class BMMiner(BaseMiner): except (KeyError, IndexError): pass - async def is_mining(self, *args, **kwargs) -> Optional[bool]: + async def _is_mining(self, *args, **kwargs) -> Optional[bool]: return None - async def get_uptime(self, api_stats: dict = None) -> Optional[int]: + async def _get_uptime(self, api_stats: dict = None) -> Optional[int]: if not api_stats: try: - api_stats = await self.web.get_miner_conf() + api_stats = await self.api.stats() except APIError: pass diff --git a/pyasic/miners/backends/bosminer.py b/pyasic/miners/backends/bosminer.py index 51720562..7307233d 100644 --- a/pyasic/miners/backends/bosminer.py +++ b/pyasic/miners/backends/bosminer.py @@ -41,19 +41,18 @@ from pyasic.web.bosminer import BOSMinerWebAPI BOSMINER_DATA_LOC = DataLocations( **{ str(DataOptions.MAC): DataFunction( - "get_mac", + "_get_mac", [ WebAPICommand( "web_net_conf", "/cgi-bin/luci/admin/network/iface_status/lan" ) ], ), - str(DataOptions.MODEL): DataFunction("get_model"), str(DataOptions.API_VERSION): DataFunction( - "get_api_ver", [RPCAPICommand("api_version", "version")] + "_get_api_ver", [RPCAPICommand("api_version", "version")] ), str(DataOptions.FW_VERSION): DataFunction( - "get_fw_ver", + "_get_fw_ver", [ GraphQLCommand( "graphql_version", {"bos": {"info": {"version": {"full": None}}}} @@ -61,11 +60,11 @@ BOSMINER_DATA_LOC = DataLocations( ], ), str(DataOptions.HOSTNAME): DataFunction( - "get_hostname", + "_get_hostname", [GraphQLCommand("graphql_hostname", {"bos": {"hostname": None}})], ), str(DataOptions.HASHRATE): DataFunction( - "get_hashrate", + "_get_hashrate", [ RPCAPICommand("api_summary", "summary"), GraphQLCommand( @@ -79,10 +78,10 @@ BOSMINER_DATA_LOC = DataLocations( ], ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "get_expected_hashrate", [RPCAPICommand("api_devs", "devs")] + "_get_expected_hashrate", [RPCAPICommand("api_devs", "devs")] ), str(DataOptions.HASHBOARDS): DataFunction( - "get_hashboards", + "_get_hashboards", [ RPCAPICommand("api_temps", "temps"), RPCAPICommand("api_devdetails", "devdetails"), @@ -106,9 +105,9 @@ BOSMINER_DATA_LOC = DataLocations( ), ], ), - str(DataOptions.ENVIRONMENT_TEMP): DataFunction("get_env_temp"), + str(DataOptions.ENVIRONMENT_TEMP): DataFunction("_get_env_temp"), str(DataOptions.WATTAGE): DataFunction( - "get_wattage", + "_get_wattage", [ RPCAPICommand("api_tunerstatus", "tunerstatus"), GraphQLCommand( @@ -124,7 +123,7 @@ BOSMINER_DATA_LOC = DataLocations( ], ), str(DataOptions.WATTAGE_LIMIT): DataFunction( - "get_wattage_limit", + "_get_wattage_limit", [ RPCAPICommand("api_tunerstatus", "tunerstatus"), GraphQLCommand( @@ -134,7 +133,7 @@ BOSMINER_DATA_LOC = DataLocations( ], ), str(DataOptions.FANS): DataFunction( - "get_fans", + "_get_fans", [ RPCAPICommand("api_fans", "fans"), GraphQLCommand( @@ -143,9 +142,9 @@ BOSMINER_DATA_LOC = DataLocations( ), ], ), - str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), + str(DataOptions.FAN_PSU): DataFunction("_get_fan_psu"), str(DataOptions.ERRORS): DataFunction( - "get_errors", + "_get_errors", [ RPCAPICommand("api_tunerstatus", "tunerstatus"), GraphQLCommand( @@ -166,14 +165,14 @@ BOSMINER_DATA_LOC = DataLocations( ], ), str(DataOptions.FAULT_LIGHT): DataFunction( - "get_fault_light", + "_get_fault_light", [GraphQLCommand("graphql_fault_light", {"bos": {"faultLight": None}})], ), str(DataOptions.IS_MINING): DataFunction( - "is_mining", [RPCAPICommand("api_devdetails", "devdetails")] + "_is_mining", [RPCAPICommand("api_devdetails", "devdetails")] ), str(DataOptions.UPTIME): DataFunction( - "get_uptime", [RPCAPICommand("api_summary", "summary")] + "_get_uptime", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.CONFIG): DataFunction("get_config"), } @@ -189,6 +188,7 @@ class BOSMiner(BaseMiner): # static data self.api_type = "BOSMiner" + self.fw_str = "BOS" # data gathering locations self.data_locations = BOSMINER_DATA_LOC # autotuning/shutdown support @@ -329,7 +329,7 @@ class BOSMiner(BaseMiner): "format": { "version": "1.2+", "generator": "pyasic", - "model": f"{self.make.replace('Miner', 'miner')} {self.model.replace(' (BOS)', '').replace('j', 'J')}", + "raw_model": f"{self.make.replace('Miner', 'miner')} {self.raw_model}", "timestamp": int(time.time()), }, **config.as_bosminer(user_suffix=user_suffix), @@ -428,7 +428,7 @@ class BOSMiner(BaseMiner): ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## - async def get_mac(self, web_net_conf: Union[dict, list] = None) -> Optional[str]: + async def _get_mac(self, web_net_conf: Union[dict, list] = None) -> Optional[str]: if not web_net_conf: try: web_net_conf = await self.web.send_command( @@ -454,8 +454,8 @@ class BOSMiner(BaseMiner): # return result.upper().strip() async def get_model(self) -> Optional[str]: - if self.model is not None: - return self.model + " (BOS)" + if self.raw_model is not None: + return self.raw_model + " (BOS)" return "? (BOS)" async def get_version( @@ -467,7 +467,7 @@ class BOSMiner(BaseMiner): fw_ver = await self.get_fw_ver(graphql_version) return miner_version(api_ver, fw_ver) - async def get_api_ver(self, api_version: dict = None) -> Optional[str]: + async def _get_api_ver(self, api_version: dict = None) -> Optional[str]: if not api_version: try: api_version = await self.api.version() @@ -485,7 +485,7 @@ class BOSMiner(BaseMiner): return self.api_ver - async def get_fw_ver(self, graphql_version: dict = None) -> Optional[str]: + async def _get_fw_ver(self, graphql_version: dict = None) -> Optional[str]: if not graphql_version: try: graphql_version = await self.web.send_command( @@ -515,7 +515,7 @@ class BOSMiner(BaseMiner): return self.fw_ver - async def get_hostname(self, graphql_hostname: dict = None) -> Union[str, None]: + async def _get_hostname(self, graphql_hostname: dict = None) -> Union[str, None]: hostname = None if not graphql_hostname: @@ -544,7 +544,7 @@ class BOSMiner(BaseMiner): logging.warning(f"Failed to get hostname for miner: {self}, {e}") return hostname - async def get_hashrate( + async def _get_hashrate( self, api_summary: dict = None, graphql_hashrate: dict = None ) -> Optional[float]: # get hr from graphql @@ -583,7 +583,7 @@ class BOSMiner(BaseMiner): except (KeyError, IndexError, ValueError, TypeError): pass - async def get_hashboards( + async def _get_hashboards( self, api_temps: dict = None, api_devdetails: dict = None, @@ -714,10 +714,10 @@ class BOSMiner(BaseMiner): return hashboards - async def get_env_temp(self) -> Optional[float]: + async def _get_env_temp(self) -> Optional[float]: return None - async def get_wattage( + async def _get_wattage( self, api_tunerstatus: dict = None, graphql_wattage: dict = None ) -> Optional[int]: if not graphql_wattage and not api_tunerstatus: @@ -753,7 +753,7 @@ class BOSMiner(BaseMiner): except (KeyError, IndexError): pass - async def get_wattage_limit( + async def _get_wattage_limit( self, api_tunerstatus: dict = None, graphql_wattage_limit: dict = None ) -> Optional[int]: if not graphql_wattage_limit and not api_tunerstatus: @@ -784,7 +784,7 @@ class BOSMiner(BaseMiner): except (KeyError, IndexError): pass - async def get_fans( + async def _get_fans( self, api_fans: dict = None, graphql_fans: dict = None ) -> List[Fan]: if not graphql_fans and not api_fans: @@ -796,7 +796,7 @@ class BOSMiner(BaseMiner): pass if graphql_fans.get("data"): fans = [] - for n in range(self.fan_count): + for n in range(self.expected_fans): try: fans.append( Fan( @@ -817,18 +817,18 @@ class BOSMiner(BaseMiner): if api_fans: fans = [] - for n in range(self.fan_count): + for n in range(self.expected_fans): try: fans.append(Fan(api_fans["FANS"][n]["RPM"])) except (IndexError, KeyError): pass return fans - return [Fan() for _ in range(self.fan_count)] + return [Fan() for _ in range(self.expected_fans)] - async def get_fan_psu(self) -> Optional[int]: + async def _get_fan_psu(self) -> Optional[int]: return None - async def get_errors( + async def _get_errors( self, api_tunerstatus: dict = None, graphql_errors: dict = None ) -> List[MinerErrorData]: if not graphql_errors and not api_tunerstatus: @@ -907,7 +907,7 @@ class BOSMiner(BaseMiner): except (KeyError, IndexError): pass - async def get_fault_light(self, graphql_fault_light: dict = None) -> bool: + async def _get_fault_light(self, graphql_fault_light: dict = None) -> bool: if self.light: return self.light @@ -964,7 +964,7 @@ class BOSMiner(BaseMiner): except (TypeError, AttributeError): return self.light - async def get_expected_hashrate(self, api_devs: dict = None) -> Optional[float]: + async def _get_expected_hashrate(self, api_devs: dict = None) -> Optional[float]: if not api_devs: try: api_devs = await self.api.devs() @@ -990,7 +990,7 @@ class BOSMiner(BaseMiner): except (IndexError, KeyError): pass - async def is_mining(self, api_devdetails: dict = None) -> Optional[bool]: + async def _is_mining(self, api_devdetails: dict = None) -> Optional[bool]: if not api_devdetails: try: api_devdetails = await self.api.send_command( @@ -1005,7 +1005,7 @@ class BOSMiner(BaseMiner): except LookupError: pass - async def get_uptime(self, api_summary: dict = None) -> Optional[int]: + async def _get_uptime(self, api_summary: dict = None) -> Optional[int]: if not api_summary: try: api_summary = await self.api.summary() diff --git a/pyasic/miners/backends/bosminer_old.py b/pyasic/miners/backends/bosminer_old.py index 5e6def99..86b99309 100644 --- a/pyasic/miners/backends/bosminer_old.py +++ b/pyasic/miners/backends/bosminer_old.py @@ -93,7 +93,7 @@ class BOSMinerOld(BOSMiner): ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## - async def get_mac(self, *args, **kwargs) -> Optional[str]: + async def _get_mac(self, *args, **kwargs) -> Optional[str]: return None async def get_model(self, *args, **kwargs) -> str: @@ -102,54 +102,54 @@ class BOSMinerOld(BOSMiner): async def get_version(self, *args, **kwargs) -> Tuple[Optional[str], Optional[str]]: return None, None - async def get_hostname(self, *args, **kwargs) -> Optional[str]: + async def _get_hostname(self, *args, **kwargs) -> Optional[str]: return None - async def get_hashrate(self, *args, **kwargs) -> Optional[float]: + async def _get_hashrate(self, *args, **kwargs) -> Optional[float]: return None - async def get_hashboards(self, *args, **kwargs) -> List[HashBoard]: + async def _get_hashboards(self, *args, **kwargs) -> List[HashBoard]: return [] - async def get_env_temp(self, *args, **kwargs) -> Optional[float]: + async def _get_env_temp(self, *args, **kwargs) -> Optional[float]: return None - async def get_wattage(self, *args, **kwargs) -> Optional[int]: + async def _get_wattage(self, *args, **kwargs) -> Optional[int]: return None - async def get_wattage_limit(self, *args, **kwargs) -> Optional[int]: + async def _get_wattage_limit(self, *args, **kwargs) -> Optional[int]: return None - async def get_fans( + async def _get_fans( self, *args, **kwargs, ) -> List[Fan]: return [Fan(), Fan(), Fan(), Fan()] - async def get_fan_psu(self, *args, **kwargs) -> Optional[int]: + async def _get_fan_psu(self, *args, **kwargs) -> Optional[int]: return None - async def get_api_ver(self, *args, **kwargs) -> Optional[str]: + async def _get_api_ver(self, *args, **kwargs) -> Optional[str]: return None - async def get_fw_ver(self, *args, **kwargs) -> Optional[str]: + async def _get_fw_ver(self, *args, **kwargs) -> Optional[str]: return None - async def get_errors(self, *args, **kwargs) -> List[MinerErrorData]: + async def _get_errors(self, *args, **kwargs) -> List[MinerErrorData]: return [] - async def get_fault_light(self, *args, **kwargs) -> bool: + async def _get_fault_light(self, *args, **kwargs) -> bool: return False - async def get_expected_hashrate(self, *args, **kwargs) -> Optional[float]: + async def _get_expected_hashrate(self, *args, **kwargs) -> Optional[float]: return None async def get_data(self, allow_warning: bool = False, **kwargs) -> MinerData: return MinerData(ip=str(self.ip)) - async def is_mining(self, *args, **kwargs) -> Optional[bool]: + async def _is_mining(self, *args, **kwargs) -> Optional[bool]: return None - async def get_uptime(self, *args, **kwargs) -> Optional[int]: + async def _get_uptime(self, *args, **kwargs) -> Optional[int]: return None diff --git a/pyasic/miners/backends/btminer.py b/pyasic/miners/backends/btminer.py index 9af81880..68f3a966 100644 --- a/pyasic/miners/backends/btminer.py +++ b/pyasic/miners/backends/btminer.py @@ -35,70 +35,69 @@ from pyasic.miners.base import ( BTMINER_DATA_LOC = DataLocations( **{ str(DataOptions.MAC): DataFunction( - "get_mac", + "_get_mac", [ RPCAPICommand("api_summary", "summary"), RPCAPICommand("api_get_miner_info", "get_miner_info"), ], ), - str(DataOptions.MODEL): DataFunction("get_model"), str(DataOptions.API_VERSION): DataFunction( - "get_api_ver", [RPCAPICommand("api_get_version", "get_version")] + "_get_api_ver", [RPCAPICommand("api_get_version", "get_version")] ), str(DataOptions.FW_VERSION): DataFunction( - "get_fw_ver", + "_get_fw_ver", [ RPCAPICommand("api_get_version", "get_version"), RPCAPICommand("api_summary", "summary"), ], ), str(DataOptions.HOSTNAME): DataFunction( - "get_hostname", [RPCAPICommand("api_get_miner_info", "get_miner_info")] + "_get_hostname", [RPCAPICommand("api_get_miner_info", "get_miner_info")] ), str(DataOptions.HASHRATE): DataFunction( - "get_hashrate", [RPCAPICommand("api_summary", "summary")] + "_get_hashrate", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "get_expected_hashrate", [RPCAPICommand("api_summary", "summary")] + "_get_expected_hashrate", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.HASHBOARDS): DataFunction( - "get_hashboards", [RPCAPICommand("api_devs", "devs")] + "_get_hashboards", [RPCAPICommand("api_devs", "devs")] ), str(DataOptions.ENVIRONMENT_TEMP): DataFunction( - "get_env_temp", [RPCAPICommand("api_summary", "summary")] + "_get_env_temp", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.WATTAGE): DataFunction( - "get_wattage", [RPCAPICommand("api_summary", "summary")] + "_get_wattage", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.WATTAGE_LIMIT): DataFunction( - "get_wattage_limit", [RPCAPICommand("api_summary", "summary")] + "_get_wattage_limit", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.FANS): DataFunction( - "get_fans", + "_get_fans", [ RPCAPICommand("api_summary", "summary"), RPCAPICommand("api_get_psu", "get_psu"), ], ), str(DataOptions.FAN_PSU): DataFunction( - "get_fan_psu", + "_get_fan_psu", [ RPCAPICommand("api_summary", "summary"), RPCAPICommand("api_get_psu", "get_psu"), ], ), str(DataOptions.ERRORS): DataFunction( - "get_errors", [RPCAPICommand("api_get_error_code", "get_error_code")] + "_get_errors", [RPCAPICommand("api_get_error_code", "get_error_code")] ), str(DataOptions.FAULT_LIGHT): DataFunction( - "get_fault_light", + "_get_fault_light", [RPCAPICommand("api_get_miner_info", "get_miner_info")], ), str(DataOptions.IS_MINING): DataFunction( - "is_mining", [RPCAPICommand("api_status", "status")] + "_is_mining", [RPCAPICommand("api_status", "status")] ), str(DataOptions.UPTIME): DataFunction( - "get_uptime", [RPCAPICommand("api_summary", "summary")] + "_get_uptime", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.CONFIG): DataFunction("get_config"), } @@ -239,7 +238,7 @@ class BTMiner(BaseMiner): else: cfg = MinerConfig() - is_mining = await self.is_mining(status) + is_mining = await self._is_mining(status) if not is_mining: cfg.mining_mode = MiningModeConfig.sleep() return cfg @@ -283,7 +282,7 @@ class BTMiner(BaseMiner): ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## - async def get_mac( + async def _get_mac( self, api_summary: dict = None, api_get_miner_info: dict = None ) -> Optional[str]: if not api_get_miner_info: @@ -312,21 +311,7 @@ class BTMiner(BaseMiner): except (KeyError, IndexError): pass - async def get_version( - self, api_get_version: dict = None, api_summary: dict = None - ) -> Tuple[Optional[str], Optional[str]]: - miner_version = namedtuple("MinerVersion", "api_ver fw_ver") - api_ver = await self.get_api_ver(api_get_version=api_get_version) - fw_ver = await self.get_fw_ver( - api_get_version=api_get_version, api_summary=api_summary - ) - return miner_version(api_ver, fw_ver) - - async def get_api_ver(self, api_get_version: dict = None) -> Optional[str]: - # Check to see if the version info is already cached - if self.api_ver: - return self.api_ver - + async def _get_api_ver(self, api_get_version: dict = None) -> Optional[str]: if not api_get_version: try: api_get_version = await self.api.get_version() @@ -349,13 +334,9 @@ class BTMiner(BaseMiner): return self.api_ver - async def get_fw_ver( + async def _get_fw_ver( self, api_get_version: dict = None, api_summary: dict = None ) -> Optional[str]: - # Check to see if the version info is already cached - if self.fw_ver: - return self.fw_ver - if not api_get_version: try: api_get_version = await self.api.get_version() @@ -388,7 +369,7 @@ class BTMiner(BaseMiner): return self.fw_ver - async def get_hostname(self, api_get_miner_info: dict = None) -> Optional[str]: + async def _get_hostname(self, api_get_miner_info: dict = None) -> Optional[str]: hostname = None if not api_get_miner_info: try: @@ -404,7 +385,7 @@ class BTMiner(BaseMiner): return hostname - async def get_hashrate(self, api_summary: dict = None) -> Optional[float]: + async def _get_hashrate(self, api_summary: dict = None) -> Optional[float]: # get hr from API if not api_summary: try: @@ -418,7 +399,7 @@ class BTMiner(BaseMiner): except (KeyError, IndexError): pass - async def get_hashboards(self, api_devs: dict = None) -> List[HashBoard]: + async def _get_hashboards(self, api_devs: dict = None) -> List[HashBoard]: hashboards = [ HashBoard(slot=i, expected_chips=self.expected_chips) for i in range(self.expected_hashboards) @@ -453,7 +434,7 @@ class BTMiner(BaseMiner): return hashboards - async def get_env_temp(self, api_summary: dict = None) -> Optional[float]: + async def _get_env_temp(self, api_summary: dict = None) -> Optional[float]: if not api_summary: try: api_summary = await self.api.summary() @@ -466,7 +447,7 @@ class BTMiner(BaseMiner): except (KeyError, IndexError): pass - async def get_wattage(self, api_summary: dict = None) -> Optional[int]: + async def _get_wattage(self, api_summary: dict = None) -> Optional[int]: if not api_summary: try: api_summary = await self.api.summary() @@ -480,7 +461,7 @@ class BTMiner(BaseMiner): except (KeyError, IndexError): pass - async def get_wattage_limit(self, api_summary: dict = None) -> Optional[int]: + async def _get_wattage_limit(self, api_summary: dict = None) -> Optional[int]: if not api_summary: try: api_summary = await self.api.summary() @@ -493,7 +474,7 @@ class BTMiner(BaseMiner): except (KeyError, IndexError): pass - async def get_fans( + async def _get_fans( self, api_summary: dict = None, api_get_psu: dict = None ) -> List[Fan]: if not api_summary: @@ -502,10 +483,10 @@ class BTMiner(BaseMiner): except APIError: pass - fans = [Fan() for _ in range(self.fan_count)] + fans = [Fan() for _ in range(self.expected_fans)] if api_summary: try: - if self.fan_count > 0: + if self.expected_fans > 0: fans = [ Fan(api_summary["SUMMARY"][0].get("Fan Speed In", 0)), Fan(api_summary["SUMMARY"][0].get("Fan Speed Out", 0)), @@ -515,7 +496,7 @@ class BTMiner(BaseMiner): return fans - async def get_fan_psu( + async def _get_fan_psu( self, api_summary: dict = None, api_get_psu: dict = None ) -> Optional[int]: if not api_summary: @@ -542,7 +523,7 @@ class BTMiner(BaseMiner): except (KeyError, TypeError): pass - async def get_errors( + async def _get_errors( self, api_summary: dict = None, api_get_error_code: dict = None ) -> List[MinerErrorData]: errors = [] @@ -577,7 +558,7 @@ class BTMiner(BaseMiner): return errors - async def get_expected_hashrate(self, api_summary: dict = None): + async def _get_expected_hashrate(self, api_summary: dict = None): if not api_summary: try: api_summary = await self.api.summary() @@ -592,7 +573,7 @@ class BTMiner(BaseMiner): except (KeyError, IndexError): pass - async def get_fault_light(self, api_get_miner_info: dict = None) -> bool: + async def _get_fault_light(self, api_get_miner_info: dict = None) -> bool: if not api_get_miner_info: try: api_get_miner_info = await self.api.get_miner_info() @@ -630,7 +611,7 @@ class BTMiner(BaseMiner): async def set_hostname(self, hostname: str): await self.api.set_hostname(hostname) - async def is_mining(self, api_status: dict = None) -> Optional[bool]: + async def _is_mining(self, api_status: dict = None) -> Optional[bool]: if not api_status: try: api_status = await self.api.status() @@ -649,7 +630,7 @@ class BTMiner(BaseMiner): except LookupError: pass - async def get_uptime(self, api_summary: dict = None) -> Optional[int]: + async def _get_uptime(self, api_summary: dict = None) -> Optional[int]: if not api_summary: try: api_summary = await self.api.summary() diff --git a/pyasic/miners/backends/cgminer.py b/pyasic/miners/backends/cgminer.py index 424a979c..927ed852 100644 --- a/pyasic/miners/backends/cgminer.py +++ b/pyasic/miners/backends/cgminer.py @@ -33,36 +33,35 @@ from pyasic.miners.base import ( CGMINER_DATA_LOC = DataLocations( **{ - str(DataOptions.MAC): DataFunction("get_mac"), - str(DataOptions.MODEL): DataFunction("get_model"), + str(DataOptions.MAC): DataFunction("_get_mac"), str(DataOptions.API_VERSION): DataFunction( - "get_api_ver", [RPCAPICommand("api_version", "version")] + "_get_api_ver", [RPCAPICommand("api_version", "version")] ), str(DataOptions.FW_VERSION): DataFunction( - "get_fw_ver", [RPCAPICommand("api_version", "version")] + "_get_fw_ver", [RPCAPICommand("api_version", "version")] ), - str(DataOptions.HOSTNAME): DataFunction("get_hostname"), + str(DataOptions.HOSTNAME): DataFunction("_get_hostname"), str(DataOptions.HASHRATE): DataFunction( - "get_hashrate", [RPCAPICommand("api_summary", "summary")] + "_get_hashrate", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] + "_get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.HASHBOARDS): DataFunction( - "get_hashboards", [RPCAPICommand("api_stats", "stats")] + "_get_hashboards", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.ENVIRONMENT_TEMP): DataFunction("get_env_temp"), - str(DataOptions.WATTAGE): DataFunction("get_wattage"), - str(DataOptions.WATTAGE_LIMIT): DataFunction("get_wattage_limit"), + str(DataOptions.ENVIRONMENT_TEMP): DataFunction("_get_env_temp"), + str(DataOptions.WATTAGE): DataFunction("_get_wattage"), + str(DataOptions.WATTAGE_LIMIT): DataFunction("_get_wattage_limit"), str(DataOptions.FANS): DataFunction( - "get_fans", [RPCAPICommand("api_stats", "stats")] + "_get_fans", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), - str(DataOptions.ERRORS): DataFunction("get_errors"), - str(DataOptions.FAULT_LIGHT): DataFunction("get_fault_light"), - str(DataOptions.IS_MINING): DataFunction("is_mining"), + str(DataOptions.FAN_PSU): DataFunction("_get_fan_psu"), + str(DataOptions.ERRORS): DataFunction("_get_errors"), + str(DataOptions.FAULT_LIGHT): DataFunction("_get_fault_light"), + str(DataOptions.IS_MINING): DataFunction("_is_mining"), str(DataOptions.UPTIME): DataFunction( - "get_uptime", [RPCAPICommand("api_stats", "stats")] + "_get_uptime", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.CONFIG): DataFunction("get_config"), } @@ -181,22 +180,10 @@ class CGMiner(BaseMiner): ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## - async def get_mac(self) -> Optional[str]: + async def _get_mac(self) -> Optional[str]: return None - async def get_version( - self, api_version: dict = None - ) -> Tuple[Optional[str], Optional[str]]: - miner_version = namedtuple("MinerVersion", "api_ver fw_ver") - return miner_version( - api_ver=await self.get_api_ver(api_version=api_version), - fw_ver=await self.get_fw_ver(api_version=api_version), - ) - - async def get_api_ver(self, api_version: dict = None) -> Optional[str]: - if self.api_ver: - return self.api_ver - + async def _get_api_ver(self, api_version: dict = None) -> Optional[str]: if not api_version: try: api_version = await self.api.version() @@ -211,10 +198,7 @@ class CGMiner(BaseMiner): return self.api_ver - async def get_fw_ver(self, api_version: dict = None) -> Optional[str]: - if self.fw_ver: - return self.fw_ver - + async def _get_fw_ver(self, api_version: dict = None) -> Optional[str]: if not api_version: try: api_version = await self.api.version() @@ -229,11 +213,11 @@ class CGMiner(BaseMiner): return self.fw_ver - async def get_hostname(self) -> Optional[str]: + async def _get_hostname(self) -> Optional[str]: hn = await self.send_ssh_command("cat /proc/sys/kernel/hostname") return hn - async def get_hashrate(self, api_summary: dict = None) -> Optional[float]: + async def _get_hashrate(self, api_summary: dict = None) -> Optional[float]: # get hr from API if not api_summary: try: @@ -249,7 +233,7 @@ class CGMiner(BaseMiner): except (IndexError, KeyError, ValueError, TypeError): pass - async def get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: + async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: hashboards = [] if not api_stats: @@ -303,23 +287,23 @@ class CGMiner(BaseMiner): return hashboards - async def get_env_temp(self) -> Optional[float]: + async def _get_env_temp(self) -> Optional[float]: return None - async def get_wattage(self) -> Optional[int]: + async def _get_wattage(self) -> Optional[int]: return None - async def get_wattage_limit(self) -> Optional[int]: + async def _get_wattage_limit(self) -> Optional[int]: return None - async def get_fans(self, api_stats: dict = None) -> List[Fan]: + async def _get_fans(self, api_stats: dict = None) -> List[Fan]: if not api_stats: try: api_stats = await self.api.stats() except APIError: pass - fans = [Fan() for _ in range(self.fan_count)] + fans = [Fan() for _ in range(self.expected_fans)] if api_stats: try: fan_offset = -1 @@ -332,7 +316,7 @@ class CGMiner(BaseMiner): if fan_offset == -1: fan_offset = 1 - for fan in range(self.fan_count): + for fan in range(self.expected_fans): fans[fan].speed = api_stats["STATS"][1].get( f"fan{fan_offset+fan}", 0 ) @@ -340,16 +324,16 @@ class CGMiner(BaseMiner): pass return fans - async def get_fan_psu(self) -> Optional[int]: + async def _get_fan_psu(self) -> Optional[int]: return None - async def get_errors(self) -> List[MinerErrorData]: + async def _get_errors(self) -> List[MinerErrorData]: return [] - async def get_fault_light(self) -> bool: + async def _get_fault_light(self) -> bool: return False - async def get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]: + async def _get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]: # X19 method, not sure compatibility if not api_stats: try: @@ -373,10 +357,10 @@ class CGMiner(BaseMiner): except (KeyError, IndexError): pass - async def is_mining(self, *args, **kwargs) -> Optional[bool]: + async def _is_mining(self, *args, **kwargs) -> Optional[bool]: return None - async def get_uptime(self, api_stats: dict = None) -> Optional[int]: + async def _get_uptime(self, api_stats: dict = None) -> Optional[int]: if not api_stats: try: api_stats = await self.api.stats() diff --git a/pyasic/miners/backends/cgminer_avalon.py b/pyasic/miners/backends/cgminer_avalon.py index 1db2dd9e..ebc7b716 100644 --- a/pyasic/miners/backends/cgminer_avalon.py +++ b/pyasic/miners/backends/cgminer_avalon.py @@ -28,44 +28,43 @@ from pyasic.miners.base import DataFunction, DataLocations, DataOptions, RPCAPIC AVALON_DATA_LOC = DataLocations( **{ str(DataOptions.MAC): DataFunction( - "get_mac", [RPCAPICommand("api_version", "version")] + "_get_mac", [RPCAPICommand("api_version", "version")] ), - str(DataOptions.MODEL): DataFunction("get_model"), str(DataOptions.API_VERSION): DataFunction( - "get_api_ver", [RPCAPICommand("api_version", "version")] + "_get_api_ver", [RPCAPICommand("api_version", "version")] ), str(DataOptions.FW_VERSION): DataFunction( - "get_fw_ver", [RPCAPICommand("api_version", "version")] + "_get_fw_ver", [RPCAPICommand("api_version", "version")] ), str(DataOptions.HOSTNAME): DataFunction( - "get_hostname", [RPCAPICommand("api_version", "version")] + "_get_hostname", [RPCAPICommand("api_version", "version")] ), str(DataOptions.HASHRATE): DataFunction( - "get_hashrate", [RPCAPICommand("api_devs", "devs")] + "_get_hashrate", [RPCAPICommand("api_devs", "devs")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] + "_get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.HASHBOARDS): DataFunction( - "get_hashboards", [RPCAPICommand("api_stats", "stats")] + "_get_hashboards", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.ENVIRONMENT_TEMP): DataFunction( - "get_env_temp", [RPCAPICommand("api_stats", "stats")] + "_get_env_temp", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.WATTAGE): DataFunction("get_wattage"), + str(DataOptions.WATTAGE): DataFunction("_get_wattage"), str(DataOptions.WATTAGE_LIMIT): DataFunction( - "get_wattage_limit", [RPCAPICommand("api_stats", "stats")] + "_get_wattage_limit", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.FANS): DataFunction( - "get_fans", [RPCAPICommand("api_stats", "stats")] + "_get_fans", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), - str(DataOptions.ERRORS): DataFunction("get_errors"), + str(DataOptions.FAN_PSU): DataFunction("_get_fan_psu"), + str(DataOptions.ERRORS): DataFunction("_get_errors"), str(DataOptions.FAULT_LIGHT): DataFunction( - "get_fault_light", [RPCAPICommand("api_stats", "stats")] + "_get_fault_light", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.IS_MINING): DataFunction("is_mining"), - str(DataOptions.UPTIME): DataFunction("get_uptime"), + str(DataOptions.IS_MINING): DataFunction("_is_mining"), + str(DataOptions.UPTIME): DataFunction("_get_uptime"), str(DataOptions.CONFIG): DataFunction("get_config"), } ) @@ -176,7 +175,7 @@ class CGMinerAvalon(CGMiner): ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## - async def get_mac(self, api_version: dict = None) -> Optional[str]: + async def _get_mac(self, api_version: dict = None) -> Optional[str]: if not api_version: try: api_version = await self.api.version() @@ -194,7 +193,7 @@ class CGMinerAvalon(CGMiner): except (KeyError, ValueError): pass - async def get_hostname(self, mac: str = None) -> Optional[str]: + async def _get_hostname(self, mac: str = None) -> Optional[str]: return None # if not mac: # mac = await self.get_mac() @@ -202,7 +201,7 @@ class CGMinerAvalon(CGMiner): # if mac: # return f"Avalon{mac.replace(':', '')[-6:]}" - async def get_hashrate(self, api_devs: dict = None) -> Optional[float]: + async def _get_hashrate(self, api_devs: dict = None) -> Optional[float]: if not api_devs: try: api_devs = await self.api.devs() @@ -215,7 +214,7 @@ class CGMinerAvalon(CGMiner): except (KeyError, IndexError, ValueError, TypeError): pass - async def get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: + async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: hashboards = [ HashBoard(slot=i, expected_chips=self.expected_chips) for i in range(self.expected_hashboards) @@ -263,7 +262,7 @@ class CGMinerAvalon(CGMiner): return hashboards - async def get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]: + async def _get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]: if not api_stats: try: api_stats = await self.api.stats() @@ -278,7 +277,7 @@ class CGMinerAvalon(CGMiner): except (IndexError, KeyError, ValueError, TypeError): pass - async def get_env_temp(self, api_stats: dict = None) -> Optional[float]: + async def _get_env_temp(self, api_stats: dict = None) -> Optional[float]: if not api_stats: try: api_stats = await self.api.stats() @@ -293,10 +292,10 @@ class CGMinerAvalon(CGMiner): except (IndexError, KeyError, ValueError, TypeError): pass - async def get_wattage(self) -> Optional[int]: + async def _get_wattage(self) -> Optional[int]: return None - async def get_wattage_limit(self, api_stats: dict = None) -> Optional[int]: + async def _get_wattage_limit(self, api_stats: dict = None) -> Optional[int]: if not api_stats: try: api_stats = await self.api.stats() @@ -311,14 +310,14 @@ class CGMinerAvalon(CGMiner): except (IndexError, KeyError, ValueError, TypeError): pass - async def get_fans(self, api_stats: dict = None) -> List[Fan]: + async def _get_fans(self, api_stats: dict = None) -> List[Fan]: if not api_stats: try: api_stats = await self.api.stats() except APIError: pass - fans_data = [Fan() for _ in range(self.fan_count)] + fans_data = [Fan() for _ in range(self.expected_fans)] if api_stats: try: unparsed_stats = api_stats["STATS"][0]["MM ID0"] @@ -326,17 +325,17 @@ class CGMinerAvalon(CGMiner): except LookupError: return fans_data - for fan in range(self.fan_count): + for fan in range(self.expected_fans): try: fans_data[fan].speed = int(parsed_stats[f"Fan{fan + 1}"]) except (IndexError, KeyError, ValueError, TypeError): pass return fans_data - async def get_errors(self) -> List[MinerErrorData]: + async def _get_errors(self) -> List[MinerErrorData]: return [] - async def get_fault_light(self, api_stats: dict = None) -> bool: # noqa + async def _get_fault_light(self, api_stats: dict = None) -> bool: # noqa if self.light: return self.light if not api_stats: @@ -365,5 +364,5 @@ class CGMinerAvalon(CGMiner): pass return False - async def is_mining(self, *args, **kwargs) -> Optional[bool]: + async def _is_mining(self, *args, **kwargs) -> Optional[bool]: return None diff --git a/pyasic/miners/backends/epic.py b/pyasic/miners/backends/epic.py index 88358403..0914d0f8 100644 --- a/pyasic/miners/backends/epic.py +++ b/pyasic/miners/backends/epic.py @@ -17,9 +17,9 @@ from typing import List, Optional, Tuple from pyasic import MinerConfig +from pyasic.config import MinerConfig, MiningModeConfig from pyasic.data import Fan, HashBoard from pyasic.data.error_codes import MinerErrorData, X19Error -from pyasic.config import MinerConfig, MiningModeConfig from pyasic.errors import APIError from pyasic.logger import logger from pyasic.miners.base import ( @@ -34,47 +34,46 @@ from pyasic.web.epic import ePICWebAPI EPIC_DATA_LOC = DataLocations( **{ str(DataOptions.MAC): DataFunction( - "get_mac", [WebAPICommand("web_network", "network")] + "_get_mac", [WebAPICommand("web_network", "network")] ), - str(DataOptions.MODEL): DataFunction("get_model"), - str(DataOptions.API_VERSION): DataFunction("get_api_ver"), + str(DataOptions.API_VERSION): DataFunction("_get_api_ver"), str(DataOptions.FW_VERSION): DataFunction( - "get_fw_ver", [WebAPICommand("web_summary", "summary")] + "_get_fw_ver", [WebAPICommand("web_summary", "summary")] ), str(DataOptions.HOSTNAME): DataFunction( - "get_hostname", [WebAPICommand("web_summary", "summary")] + "_get_hostname", [WebAPICommand("web_summary", "summary")] ), str(DataOptions.HASHRATE): DataFunction( - "get_hashrate", [WebAPICommand("web_summary", "summary")] + "_get_hashrate", [WebAPICommand("web_summary", "summary")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "get_expected_hashrate", [WebAPICommand("web_summary", "summary")] + "_get_expected_hashrate", [WebAPICommand("web_summary", "summary")] ), str(DataOptions.HASHBOARDS): DataFunction( - "get_hashboards", + "_get_hashboards", [ WebAPICommand("web_summary", "summary"), WebAPICommand("web_hashrate", "hashrate"), ], ), - str(DataOptions.ENVIRONMENT_TEMP): DataFunction("get_env_temp"), + str(DataOptions.ENVIRONMENT_TEMP): DataFunction("_get_env_temp"), str(DataOptions.WATTAGE): DataFunction( - "get_wattage", [WebAPICommand("web_summary", "summary")] + "_get_wattage", [WebAPICommand("web_summary", "summary")] ), - str(DataOptions.WATTAGE_LIMIT): DataFunction("get_wattage_limit"), + str(DataOptions.WATTAGE_LIMIT): DataFunction("_get_wattage_limit"), str(DataOptions.FANS): DataFunction( - "get_fans", [WebAPICommand("web_summary", "summary")] + "_get_fans", [WebAPICommand("web_summary", "summary")] ), - str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), + str(DataOptions.FAN_PSU): DataFunction("_get_fan_psu"), str(DataOptions.ERRORS): DataFunction( - "get_errors", [WebAPICommand("web_summary", "summary")] + "_get_errors", [WebAPICommand("web_summary", "summary")] ), str(DataOptions.FAULT_LIGHT): DataFunction( - "get_fault_light", [WebAPICommand("web_summary", "summary")] + "_get_fault_light", [WebAPICommand("web_summary", "summary")] ), - str(DataOptions.IS_MINING): DataFunction("is_mining"), + str(DataOptions.IS_MINING): DataFunction("_is_mining"), str(DataOptions.UPTIME): DataFunction( - "get_uptime", [WebAPICommand("web_summary", "summary")] + "_get_uptime", [WebAPICommand("web_summary", "summary")] ), str(DataOptions.CONFIG): DataFunction("get_config"), } @@ -89,14 +88,10 @@ class ePIC(BaseMiner): # static data self.api_type = "ePIC" + self.fw_str = "ePIC" # data gathering locations self.data_locations = EPIC_DATA_LOC - async def get_model(self) -> Optional[str]: - if self.model is not None: - return self.model + " (ePIC)" - return "? (ePIC)" - async def get_config(self) -> MinerConfig: summary = None try: @@ -150,7 +145,7 @@ class ePIC(BaseMiner): pass return False - async def get_mac(self, web_network: dict = None) -> str: + async def _get_mac(self, web_network: dict = None) -> str: if not web_network: web_network = await self.web.network() if web_network: @@ -161,7 +156,7 @@ class ePIC(BaseMiner): except KeyError: pass - async def get_hostname(self, web_summary: dict = None) -> str: + async def _get_hostname(self, web_summary: dict = None) -> str: if not web_summary: web_summary = await self.web.summary() if web_summary: @@ -171,7 +166,7 @@ class ePIC(BaseMiner): except KeyError: pass - async def get_wattage(self, web_summary: dict = None) -> Optional[int]: + async def _get_wattage(self, web_summary: dict = None) -> Optional[int]: if not web_summary: web_summary = await self.web.summary() @@ -183,7 +178,7 @@ class ePIC(BaseMiner): except KeyError: pass - async def get_hashrate(self, web_summary: dict = None) -> Optional[float]: + async def _get_hashrate(self, web_summary: dict = None) -> Optional[float]: # get hr from API if not web_summary: try: @@ -202,7 +197,7 @@ class ePIC(BaseMiner): logger.error(e) pass - async def get_expected_hashrate(self, web_summary: dict = None) -> Optional[float]: + async def _get_expected_hashrate(self, web_summary: dict = None) -> Optional[float]: # get hr from API if not web_summary: try: @@ -226,7 +221,7 @@ class ePIC(BaseMiner): logger.error(e) pass - async def get_fw_ver(self, web_summary: dict = None) -> Optional[str]: + async def _get_fw_ver(self, web_summary: dict = None) -> Optional[str]: if not web_summary: web_summary = await self.web.summary() @@ -238,7 +233,7 @@ class ePIC(BaseMiner): except KeyError: pass - async def get_fans(self, web_summary: dict = None) -> List[Fan]: + async def _get_fans(self, web_summary: dict = None) -> List[Fan]: if not web_summary: try: web_summary = await self.web.summary() @@ -255,7 +250,7 @@ class ePIC(BaseMiner): fans.append(Fan()) return fans - async def get_hashboards( + async def _get_hashboards( self, web_summary: dict = None, web_hashrate: dict = None ) -> List[HashBoard]: if not web_summary: @@ -286,10 +281,10 @@ class ePIC(BaseMiner): hb_list[hr["Index"]].temp = hb["Temperature"] return hb_list - async def is_mining(self, *args, **kwargs) -> Optional[bool]: + async def _is_mining(self, *args, **kwargs) -> Optional[bool]: return None - async def get_uptime(self, web_summary: dict = None) -> Optional[int]: + async def _get_uptime(self, web_summary: dict = None) -> Optional[int]: if not web_summary: web_summary = await self.web.summary() if web_summary: @@ -300,7 +295,7 @@ class ePIC(BaseMiner): pass return None - async def get_fault_light(self, web_summary: dict = None) -> bool: + async def _get_fault_light(self, web_summary: dict = None) -> bool: if not web_summary: web_summary = await self.web.summary() if web_summary: @@ -311,7 +306,7 @@ class ePIC(BaseMiner): pass return False - async def get_errors(self, web_summary: dict = None) -> List[MinerErrorData]: + async def _get_errors(self, web_summary: dict = None) -> List[MinerErrorData]: if not web_summary: web_summary = await self.web.summary() errors = [] @@ -331,22 +326,19 @@ class ePIC(BaseMiner): def fault_light_on(self) -> bool: return False - def get_api_ver(self, *args, **kwargs) -> Optional[str]: + def _get_api_ver(self, *args, **kwargs) -> Optional[str]: pass def get_config(self) -> MinerConfig: return self.config - def get_env_temp(self, *args, **kwargs) -> Optional[float]: + def _get_env_temp(self, *args, **kwargs) -> Optional[float]: pass - def get_fan_psu(self, *args, **kwargs) -> Optional[int]: + def _get_fan_psu(self, *args, **kwargs) -> Optional[int]: pass - def get_version(self, *args, **kwargs) -> Tuple[Optional[str], Optional[str]]: - pass - - def get_wattage_limit(self, *args, **kwargs) -> Optional[int]: + def _get_wattage_limit(self, *args, **kwargs) -> Optional[int]: pass def send_config(self, config: MinerConfig, user_suffix: str = None) -> None: diff --git a/pyasic/miners/backends/hiveon.py b/pyasic/miners/backends/hiveon.py index 11b458e0..3b99bcf6 100644 --- a/pyasic/miners/backends/hiveon.py +++ b/pyasic/miners/backends/hiveon.py @@ -24,8 +24,4 @@ class Hiveon(BMMiner): super().__init__(ip, api_ver) # static data self.api_type = "Hiveon" - - async def get_model(self) -> Optional[str]: - if self.model is not None: - return self.model + " (Hiveon)" - return "? (Hiveon)" + self.fw_str = "Hive" diff --git a/pyasic/miners/backends/luxminer.py b/pyasic/miners/backends/luxminer.py index 3467581c..5f0b0863 100644 --- a/pyasic/miners/backends/luxminer.py +++ b/pyasic/miners/backends/luxminer.py @@ -39,35 +39,34 @@ from pyasic.web.bosminer import BOSMinerWebAPI LUXMINER_DATA_LOC = DataLocations( **{ str(DataOptions.MAC): DataFunction( - "get_mac", [RPCAPICommand("api_config", "config")] + "_get_mac", [RPCAPICommand("api_config", "config")] ), - str(DataOptions.MODEL): DataFunction("get_model"), - str(DataOptions.API_VERSION): DataFunction("get_api_ver"), - str(DataOptions.FW_VERSION): DataFunction("get_fw_ver"), - str(DataOptions.HOSTNAME): DataFunction("get_hostname"), + str(DataOptions.API_VERSION): DataFunction("_get_api_ver"), + str(DataOptions.FW_VERSION): DataFunction("_get_fw_ver"), + str(DataOptions.HOSTNAME): DataFunction("_get_hostname"), str(DataOptions.HASHRATE): DataFunction( - "get_hashrate", [RPCAPICommand("api_summary", "summary")] + "_get_hashrate", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] + "_get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.HASHBOARDS): DataFunction( - "get_hashboards", [RPCAPICommand("api_stats", "stats")] + "_get_hashboards", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.ENVIRONMENT_TEMP): DataFunction("get_env_temp"), + str(DataOptions.ENVIRONMENT_TEMP): DataFunction("_get_env_temp"), str(DataOptions.WATTAGE): DataFunction( - "get_wattage", [RPCAPICommand("api_power", "power")] + "_get_wattage", [RPCAPICommand("api_power", "power")] ), - str(DataOptions.WATTAGE_LIMIT): DataFunction("get_wattage_limit"), + str(DataOptions.WATTAGE_LIMIT): DataFunction("_get_wattage_limit"), str(DataOptions.FANS): DataFunction( - "get_fans", [RPCAPICommand("api_fans", "fans")] + "_get_fans", [RPCAPICommand("api_fans", "fans")] ), - str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), - str(DataOptions.ERRORS): DataFunction("get_errors"), - str(DataOptions.FAULT_LIGHT): DataFunction("get_fault_light"), - str(DataOptions.IS_MINING): DataFunction("is_mining"), + str(DataOptions.FAN_PSU): DataFunction("_get_fan_psu"), + str(DataOptions.ERRORS): DataFunction("_get_errors"), + str(DataOptions.FAULT_LIGHT): DataFunction("_get_fault_light"), + str(DataOptions.IS_MINING): DataFunction("_is_mining"), str(DataOptions.UPTIME): DataFunction( - "get_uptime", [RPCAPICommand("api_stats", "stats")] + "_get_uptime", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.CONFIG): DataFunction("get_config"), } @@ -83,6 +82,7 @@ class LUXMiner(BaseMiner): # static data self.api_type = "LUXMiner" + self.fw_str = "LuxOS" # data gathering locations self.data_locations = LUXMINER_DATA_LOC # autotuning/shutdown support @@ -181,7 +181,7 @@ class LUXMiner(BaseMiner): ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## - async def get_mac(self, api_config: dict = None) -> Optional[str]: + async def _get_mac(self, api_config: dict = None) -> Optional[str]: mac = None if not api_config: try: @@ -197,24 +197,19 @@ class LUXMiner(BaseMiner): return mac - async def get_model(self) -> Optional[str]: - if self.model is not None: - return self.model + " (LuxOS)" - return "? (LuxOS)" - async def get_version(self) -> Tuple[Optional[str], Optional[str]]: pass - async def get_api_ver(self) -> Optional[str]: + async def _get_api_ver(self) -> Optional[str]: pass - async def get_fw_ver(self) -> Optional[str]: + async def _get_fw_ver(self) -> Optional[str]: pass - async def get_hostname(self) -> Union[str, None]: + async def _get_hostname(self) -> Union[str, None]: pass - async def get_hashrate(self, api_summary: dict = None) -> Optional[float]: + async def _get_hashrate(self, api_summary: dict = None) -> Optional[float]: if not api_summary: try: api_summary = await self.api.summary() @@ -227,7 +222,7 @@ class LUXMiner(BaseMiner): except (IndexError, KeyError, ValueError, TypeError): pass - async def get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: + async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: hashboards = [] if not api_stats: @@ -281,10 +276,10 @@ class LUXMiner(BaseMiner): return hashboards - async def get_env_temp(self) -> Optional[float]: + async def _get_env_temp(self) -> Optional[float]: return None - async def get_wattage(self, api_power: dict) -> Optional[int]: + async def _get_wattage(self, api_power: dict) -> Optional[int]: if not api_power: try: api_power = await self.api.power() @@ -297,10 +292,10 @@ class LUXMiner(BaseMiner): except (IndexError, KeyError, ValueError, TypeError): pass - async def get_wattage_limit(self) -> Optional[int]: + async def _get_wattage_limit(self) -> Optional[int]: return None - async def get_fans(self, api_fans: dict = None) -> List[Fan]: + async def _get_fans(self, api_fans: dict = None) -> List[Fan]: if not api_fans: try: api_fans = await self.api.fans() @@ -310,23 +305,23 @@ class LUXMiner(BaseMiner): fans = [] if api_fans: - for fan in range(self.fan_count): + for fan in range(self.expected_fans): try: fans.append(Fan(api_fans["FANS"][0]["RPM"])) except (IndexError, KeyError, ValueError, TypeError): fans.append(Fan()) return fans - async def get_fan_psu(self) -> Optional[int]: + async def _get_fan_psu(self) -> Optional[int]: return None - async def get_errors(self) -> List[MinerErrorData]: + async def _get_errors(self) -> List[MinerErrorData]: pass - async def get_fault_light(self) -> bool: + async def _get_fault_light(self) -> bool: pass - async def get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]: + async def _get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]: if not api_stats: try: api_stats = await self.api.stats() @@ -349,10 +344,10 @@ class LUXMiner(BaseMiner): except (KeyError, IndexError): pass - async def is_mining(self) -> Optional[bool]: + async def _is_mining(self) -> Optional[bool]: pass - async def get_uptime(self, api_stats: dict = None) -> Optional[int]: + async def _get_uptime(self, api_stats: dict = None) -> Optional[int]: if not api_stats: try: api_stats = await self.api.stats() diff --git a/pyasic/miners/backends/vnish.py b/pyasic/miners/backends/vnish.py index 0df888a6..f2af26a2 100644 --- a/pyasic/miners/backends/vnish.py +++ b/pyasic/miners/backends/vnish.py @@ -32,42 +32,41 @@ from pyasic.web.vnish import VNishWebAPI VNISH_DATA_LOC = DataLocations( **{ str(DataOptions.MAC): DataFunction( - "get_mac", [WebAPICommand("web_summary", "summary")] + "_get_mac", [WebAPICommand("web_summary", "summary")] ), - str(DataOptions.MODEL): DataFunction("get_model"), str(DataOptions.API_VERSION): DataFunction( - "get_api_ver", [RPCAPICommand("api_version", "version")] + "_get_api_ver", [RPCAPICommand("api_version", "version")] ), str(DataOptions.FW_VERSION): DataFunction( - "get_fw_ver", [WebAPICommand("web_summary", "summary")] + "_get_fw_ver", [WebAPICommand("web_summary", "summary")] ), str(DataOptions.HOSTNAME): DataFunction( - "get_hostname", [WebAPICommand("web_summary", "summary")] + "_get_hostname", [WebAPICommand("web_summary", "summary")] ), str(DataOptions.HASHRATE): DataFunction( - "get_hashrate", [WebAPICommand("web_summary", "summary")] + "_get_hashrate", [WebAPICommand("web_summary", "summary")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] + "_get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.HASHBOARDS): DataFunction( - "get_hashboards", [RPCAPICommand("api_stats", "stats")] + "_get_hashboards", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.ENVIRONMENT_TEMP): DataFunction("get_env_temp"), + str(DataOptions.ENVIRONMENT_TEMP): DataFunction("_get_env_temp"), str(DataOptions.WATTAGE): DataFunction( - "get_wattage", [WebAPICommand("web_summary", "summary")] + "_get_wattage", [WebAPICommand("web_summary", "summary")] ), str(DataOptions.WATTAGE_LIMIT): DataFunction( - "get_wattage_limit", [WebAPICommand("web_settings", "settings")] + "_get_wattage_limit", [WebAPICommand("web_settings", "settings")] ), str(DataOptions.FANS): DataFunction( - "get_fans", [WebAPICommand("web_summary", "summary")] + "_get_fans", [WebAPICommand("web_summary", "summary")] ), - str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), - str(DataOptions.ERRORS): DataFunction("get_errors"), - str(DataOptions.FAULT_LIGHT): DataFunction("get_fault_light"), - str(DataOptions.IS_MINING): DataFunction("is_mining"), - str(DataOptions.UPTIME): DataFunction("get_uptime"), + str(DataOptions.FAN_PSU): DataFunction("_get_fan_psu"), + str(DataOptions.ERRORS): DataFunction("_get_errors"), + str(DataOptions.FAULT_LIGHT): DataFunction("_get_fault_light"), + str(DataOptions.IS_MINING): DataFunction("_is_mining"), + str(DataOptions.UPTIME): DataFunction("_get_uptime"), str(DataOptions.CONFIG): DataFunction("get_config"), } ) @@ -81,14 +80,10 @@ class VNish(BMMiner): # static data self.api_type = "VNish" + self.fw_str = "VNish" # data gathering locations self.data_locations = VNISH_DATA_LOC - async def get_model(self) -> Optional[str]: - if self.model is not None: - return self.model + " (VNish)" - return "? (VNish)" - async def restart_backend(self) -> bool: data = await self.web.restart_vnish() if data: @@ -125,7 +120,7 @@ class VNish(BMMiner): pass return False - async def get_mac(self, web_summary: dict = None) -> str: + async def _get_mac(self, web_summary: dict = None) -> str: if not web_summary: web_info = await self.web.info() @@ -143,7 +138,7 @@ class VNish(BMMiner): except KeyError: pass - async def get_hostname(self, web_summary: dict = None) -> str: + async def _get_hostname(self, web_summary: dict = None) -> str: if not web_summary: web_info = await self.web.info() @@ -161,7 +156,7 @@ class VNish(BMMiner): except KeyError: pass - async def get_wattage(self, web_summary: dict = None) -> Optional[int]: + async def _get_wattage(self, web_summary: dict = None) -> Optional[int]: if not web_summary: web_summary = await self.web.summary() @@ -173,7 +168,7 @@ class VNish(BMMiner): except KeyError: pass - async def get_hashrate(self, api_summary: dict = None) -> Optional[float]: + async def _get_hashrate(self, api_summary: dict = None) -> Optional[float]: # get hr from API if not api_summary: try: @@ -190,7 +185,7 @@ class VNish(BMMiner): logger.error(e) pass - async def get_wattage_limit(self, web_settings: dict = None) -> Optional[int]: + async def _get_wattage_limit(self, web_settings: dict = None) -> Optional[int]: if not web_settings: web_settings = await self.web.summary() @@ -203,7 +198,7 @@ class VNish(BMMiner): except (KeyError, TypeError): pass - async def get_fw_ver(self, web_summary: dict = None) -> Optional[str]: + async def _get_fw_ver(self, web_summary: dict = None) -> Optional[str]: if not web_summary: web_summary = await self.web.summary() @@ -215,10 +210,10 @@ class VNish(BMMiner): except KeyError: pass - async def is_mining(self, *args, **kwargs) -> Optional[bool]: + async def _is_mining(self, *args, **kwargs) -> Optional[bool]: return None - async def get_uptime(self, *args, **kwargs) -> Optional[int]: + async def _get_uptime(self, *args, **kwargs) -> Optional[int]: return None async def get_config(self) -> MinerConfig: diff --git a/pyasic/miners/base.py b/pyasic/miners/base.py index 52aa88d1..aaf86998 100644 --- a/pyasic/miners/base.py +++ b/pyasic/miners/base.py @@ -31,7 +31,6 @@ from pyasic.logger import logger class DataOptions(Enum): MAC = "mac" - MODEL = "model" API_VERSION = "api_ver" FW_VERSION = "fw_ver" HOSTNAME = "hostname" @@ -106,11 +105,12 @@ class BaseMiner(ABC): self.api_type = None # type self.make = None - self.model = None + self.raw_model = None + self.fw_str = None # physical attributes self.expected_hashboards = 3 self.expected_chips = 0 - self.fan_count = 2 + self.expected_fans = 2 # data gathering locations self.data_locations: DataLocations = None # autotuning/shutdown support @@ -140,6 +140,13 @@ class BaseMiner(ABC): def __eq__(self, other): return ipaddress.ip_address(self.ip) == ipaddress.ip_address(other.ip) + @property + def model(self): + model_data = [self.raw_model] + if self.fw_str is not None: + model_data.append(f"({self.fw_str})") + return " ".join(model_data) + @property def pwd(self): # noqa - Skip PyCharm inspection data = [] @@ -309,14 +316,13 @@ class BaseMiner(ABC): ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## - @abstractmethod - async def get_mac(self, *args, **kwargs) -> Optional[str]: + async def get_mac(self) -> Optional[str]: """Get the MAC address of the miner and return it as a string. Returns: A string representing the MAC address of the miner. """ - pass + return await self._get_mac() async def get_model(self) -> Optional[str]: """Get the model of the miner and return it as a string. @@ -326,148 +332,198 @@ class BaseMiner(ABC): """ return self.model - @abstractmethod - async def get_api_ver(self, *args, **kwargs) -> Optional[str]: + async def get_api_ver(self) -> Optional[str]: """Get the API version of the miner and is as a string. Returns: API version as a string. """ - pass + return await self._get_api_ver() - @abstractmethod - async def get_fw_ver(self, *args, **kwargs) -> Optional[str]: + async def get_fw_ver(self) -> Optional[str]: """Get the firmware version of the miner and is as a string. Returns: Firmware version as a string. """ - pass + return await self._get_fw_ver() - @abstractmethod - async def get_version(self, *args, **kwargs) -> Tuple[Optional[str], Optional[str]]: + async def get_version(self) -> Tuple[Optional[str], Optional[str]]: """Get the API version and firmware version of the miner and return them as strings. Returns: A tuple of (API version, firmware version) as strings. """ - pass + api_ver = await self.get_api_ver() + fw_ver = await self.get_fw_ver() + return api_ver, fw_ver - @abstractmethod - async def get_hostname(self, *args, **kwargs) -> Optional[str]: + async def get_hostname(self) -> Optional[str]: """Get the hostname of the miner and return it as a string. Returns: A string representing the hostname of the miner. """ - pass + return await self._get_hostname() - @abstractmethod - async def get_hashrate(self, *args, **kwargs) -> Optional[float]: + async def get_hashrate(self) -> Optional[float]: """Get the hashrate of the miner and return it as a float in TH/s. Returns: Hashrate of the miner in TH/s as a float. """ - pass + return await self._get_hashrate() - @abstractmethod - async def get_hashboards(self, *args, **kwargs) -> List[HashBoard]: + async def get_hashboards(self) -> List[HashBoard]: """Get hashboard data from the miner in the form of [`HashBoard`][pyasic.data.HashBoard]. Returns: A [`HashBoard`][pyasic.data.HashBoard] instance containing hashboard data from the miner. """ - pass + return await self._get_hashboards() - @abstractmethod - async def get_env_temp(self, *args, **kwargs) -> Optional[float]: + async def get_env_temp(self) -> Optional[float]: """Get environment temp from the miner as a float. Returns: Environment temp of the miner as a float. """ - pass + return await self._get_env_temp() - @abstractmethod - async def get_wattage(self, *args, **kwargs) -> Optional[int]: + async def get_wattage(self) -> Optional[int]: """Get wattage from the miner as an int. Returns: Wattage of the miner as an int. """ - pass + return await self._get_wattage() - @abstractmethod - async def get_wattage_limit(self, *args, **kwargs) -> Optional[int]: + async def get_wattage_limit(self) -> Optional[int]: """Get wattage limit from the miner as an int. Returns: Wattage limit of the miner as an int. """ - pass + return await self._get_wattage_limit() - @abstractmethod - async def get_fans(self, *args, **kwargs) -> List[Fan]: + async def get_fans(self) -> List[Fan]: """Get fan data from the miner in the form [fan_1, fan_2, fan_3, fan_4]. Returns: A list of fan data. """ - pass + return await self._get_fans() - @abstractmethod - async def get_fan_psu(self, *args, **kwargs) -> Optional[int]: + async def get_fan_psu(self) -> Optional[int]: """Get PSU fan speed from the miner. Returns: PSU fan speed. """ - pass + return await self._get_fan_psu() - @abstractmethod - async def get_errors(self, *args, **kwargs) -> List[MinerErrorData]: + async def get_errors(self) -> List[MinerErrorData]: """Get a list of the errors the miner is experiencing. Returns: A list of error classes representing different errors. """ - pass + return await self._get_errors() - @abstractmethod - async def get_fault_light(self, *args, **kwargs) -> bool: + async def get_fault_light(self) -> bool: """Check the status of the fault light and return on or off as a boolean. Returns: A boolean value where `True` represents on and `False` represents off. """ - pass + return await self._get_fault_light() - @abstractmethod - async def get_expected_hashrate(self, *args, **kwargs) -> Optional[float]: + async def get_expected_hashrate(self) -> Optional[float]: """Get the nominal hashrate from factory if available. Returns: A float value of nominal hashrate in TH/s. """ - pass + return await self._get_expected_hashrate() - @abstractmethod - async def is_mining(self, *args, **kwargs) -> Optional[bool]: + async def is_mining(self) -> Optional[bool]: """Check whether the miner is mining. Returns: A boolean value representing if the miner is mining. """ - pass + return await self._is_mining() - @abstractmethod - async def get_uptime(self, *args, **kwargs) -> Optional[int]: + async def get_uptime(self) -> Optional[int]: """Get the uptime of the miner in seconds. Returns: The uptime of the miner in seconds. """ + return await self._get_uptime() + + @abstractmethod + async def _get_mac(self, *args, **kwargs) -> Optional[str]: + pass + + @abstractmethod + async def _get_api_ver(self, *args, **kwargs) -> Optional[str]: + pass + + @abstractmethod + async def _get_fw_ver(self, *args, **kwargs) -> Optional[str]: + pass + + @abstractmethod + async def _get_hostname(self, *args, **kwargs) -> Optional[str]: + pass + + @abstractmethod + async def _get_hashrate(self, *args, **kwargs) -> Optional[float]: + pass + + @abstractmethod + async def _get_hashboards(self, *args, **kwargs) -> List[HashBoard]: + pass + + @abstractmethod + async def _get_env_temp(self, *args, **kwargs) -> Optional[float]: + pass + + @abstractmethod + async def _get_wattage(self, *args, **kwargs) -> Optional[int]: + pass + + @abstractmethod + async def _get_wattage_limit(self, *args, **kwargs) -> Optional[int]: + pass + + @abstractmethod + async def _get_fans(self, *args, **kwargs) -> List[Fan]: + pass + + @abstractmethod + async def _get_fan_psu(self, *args, **kwargs) -> Optional[int]: + pass + + @abstractmethod + async def _get_errors(self, *args, **kwargs) -> List[MinerErrorData]: + pass + + @abstractmethod + async def _get_fault_light(self, *args, **kwargs) -> bool: + pass + + @abstractmethod + async def _get_expected_hashrate(self, *args, **kwargs) -> Optional[float]: + pass + + @abstractmethod + async def _is_mining(self, *args, **kwargs) -> Optional[bool]: + pass + + @abstractmethod + async def _get_uptime(self, *args, **kwargs) -> Optional[int]: pass async def _get_data( @@ -571,6 +627,7 @@ class BaseMiner(ABC): data = MinerData( ip=str(self.ip), make=self.make, + model=self.model, expected_chips=self.expected_chips * self.expected_hashboards, expected_hashboards=self.expected_hashboards, hashboards=[ diff --git a/pyasic/miners/innosilicon/cgminer/A10X/A10X.py b/pyasic/miners/innosilicon/cgminer/A10X/A10X.py index d1e8c77d..bb1890d2 100644 --- a/pyasic/miners/innosilicon/cgminer/A10X/A10X.py +++ b/pyasic/miners/innosilicon/cgminer/A10X/A10X.py @@ -254,7 +254,7 @@ class CGMinerA10X(CGMiner, A10X): else: web_get_all = web_get_all["all"] - fans = [Fan() for _ in range(self.fan_count)] + fans = [Fan() for _ in range(self.expected_fans)] if web_get_all: try: spd = web_get_all["fansSpeed"] @@ -262,7 +262,7 @@ class CGMinerA10X(CGMiner, A10X): pass else: round((int(spd) * 6000) / 100) - for i in range(self.fan_count): + for i in range(self.expected_fans): fans[i].speed = spd return fans diff --git a/pyasic/miners/types/antminer/X15/Z15.py b/pyasic/miners/types/antminer/X15/Z15.py index 7a0e5ac7..f91b25b6 100644 --- a/pyasic/miners/types/antminer/X15/Z15.py +++ b/pyasic/miners/types/antminer/X15/Z15.py @@ -21,6 +21,6 @@ class Z15(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "Z15" + self.raw_model = "Z15" self.expected_chips = 3 self.fan_count = 2 diff --git a/pyasic/miners/types/antminer/X17/S17.py b/pyasic/miners/types/antminer/X17/S17.py index 277e3c92..8d4ec087 100644 --- a/pyasic/miners/types/antminer/X17/S17.py +++ b/pyasic/miners/types/antminer/X17/S17.py @@ -21,7 +21,7 @@ class S17(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S17" + self.raw_model = "S17" self.expected_chips = 48 self.fan_count = 4 @@ -29,7 +29,7 @@ class S17(AntMiner): # noqa - ignore ABC method implementation class S17Plus(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) - self.model = "S17+" + self.raw_model = "S17+" self.expected_chips = 65 self.fan_count = 4 @@ -38,7 +38,7 @@ class S17Pro(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S17 Pro" + self.raw_model = "S17 Pro" self.expected_chips = 48 self.fan_count = 4 @@ -47,6 +47,6 @@ class S17e(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S17e" + self.raw_model = "S17e" self.expected_chips = 135 self.fan_count = 4 diff --git a/pyasic/miners/types/antminer/X17/T17.py b/pyasic/miners/types/antminer/X17/T17.py index d41a27d9..6d4b71fc 100644 --- a/pyasic/miners/types/antminer/X17/T17.py +++ b/pyasic/miners/types/antminer/X17/T17.py @@ -21,7 +21,7 @@ class T17(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "T17" + self.raw_model = "T17" self.expected_chips = 30 self.fan_count = 4 @@ -30,7 +30,7 @@ class T17Plus(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "T17+" + self.raw_model = "T17+" self.expected_chips = 44 self.fan_count = 4 @@ -39,6 +39,6 @@ class T17e(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "T17e" + self.raw_model = "T17e" self.expected_chips = 78 self.fan_count = 4 diff --git a/pyasic/miners/types/antminer/X19/S19.py b/pyasic/miners/types/antminer/X19/S19.py index 42bfd891..86e6d57c 100644 --- a/pyasic/miners/types/antminer/X19/S19.py +++ b/pyasic/miners/types/antminer/X19/S19.py @@ -21,7 +21,7 @@ class S19(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19" + self.raw_model = "S19" self.expected_chips = 76 self.fan_count = 4 @@ -30,7 +30,7 @@ class S19NoPIC(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19 No PIC" + self.raw_model = "S19 No PIC" self.expected_chips = 88 self.fan_count = 4 @@ -39,7 +39,7 @@ class S19Pro(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19 Pro" + self.raw_model = "S19 Pro" self.expected_chips = 114 self.fan_count = 4 @@ -48,7 +48,7 @@ class S19i(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19i" + self.raw_model = "S19i" self.expected_chips = 80 self.fan_count = 4 @@ -57,7 +57,7 @@ class S19Plus(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19+" + self.raw_model = "S19+" self.expected_chips = 80 self.fan_count = 4 @@ -66,7 +66,7 @@ class S19ProPlus(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19 Pro+" + self.raw_model = "S19 Pro+" self.expected_chips = 120 self.fan_count = 4 @@ -75,7 +75,7 @@ class S19XP(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19 XP" + self.raw_model = "S19 XP" self.expected_chips = 110 self.fan_count = 4 @@ -84,7 +84,7 @@ class S19a(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19a" + self.raw_model = "S19a" self.expected_chips = 72 self.fan_count = 4 @@ -93,7 +93,7 @@ class S19aPro(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19a Pro" + self.raw_model = "S19a Pro" self.expected_chips = 100 self.fan_count = 4 @@ -102,7 +102,7 @@ class S19j(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19j" + self.raw_model = "S19j" self.expected_chips = 114 self.fan_count = 4 @@ -111,7 +111,7 @@ class S19jNoPIC(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19j No PIC" + self.raw_model = "S19j No PIC" self.expected_chips = 88 self.fan_count = 4 @@ -120,7 +120,7 @@ class S19jPro(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19j Pro" + self.raw_model = "S19j Pro" self.expected_chips = 126 self.fan_count = 4 @@ -129,7 +129,7 @@ class S19jProPlus(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19j Pro+" + self.raw_model = "S19j Pro+" self.expected_chips = 120 self.fan_count = 4 @@ -138,7 +138,7 @@ class S19kPro(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19k Pro" + self.raw_model = "S19k Pro" self.expected_chips = 77 self.fan_count = 4 @@ -147,7 +147,7 @@ class S19L(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19L" + self.raw_model = "S19L" self.expected_chips = 76 self.fan_count = 4 @@ -156,7 +156,7 @@ class S19kProNoPIC(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19k Pro No PIC" + self.raw_model = "S19k Pro No PIC" self.expected_chips = 77 self.fan_count = 4 @@ -165,7 +165,7 @@ class S19ProHydro(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S19 Pro Hydro" + self.raw_model = "S19 Pro Hydro" self.expected_chips = 180 self.expected_hashboards = 4 self.fan_count = 0 diff --git a/pyasic/miners/types/antminer/X19/T19.py b/pyasic/miners/types/antminer/X19/T19.py index 249d1e06..df575cf8 100644 --- a/pyasic/miners/types/antminer/X19/T19.py +++ b/pyasic/miners/types/antminer/X19/T19.py @@ -21,6 +21,6 @@ class T19(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "T19" + self.raw_model = "T19" self.expected_chips = 76 self.fan_count = 4 diff --git a/pyasic/miners/types/antminer/X3/D3.py b/pyasic/miners/types/antminer/X3/D3.py index 1d24676f..6471db46 100644 --- a/pyasic/miners/types/antminer/X3/D3.py +++ b/pyasic/miners/types/antminer/X3/D3.py @@ -21,7 +21,7 @@ class D3(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "D3" + self.raw_model = "D3" self.expected_chips = 60 self.expected_hashboards = 3 self.fan_count = 2 diff --git a/pyasic/miners/types/antminer/X3/HS3.py b/pyasic/miners/types/antminer/X3/HS3.py index 540f4852..3b90d21b 100644 --- a/pyasic/miners/types/antminer/X3/HS3.py +++ b/pyasic/miners/types/antminer/X3/HS3.py @@ -21,7 +21,7 @@ class HS3(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "HS3" + self.raw_model = "HS3" self.expected_chips = 92 self.expected_hashboards = 3 self.fan_count = 2 diff --git a/pyasic/miners/types/antminer/X3/L3.py b/pyasic/miners/types/antminer/X3/L3.py index 95335304..0567d38a 100644 --- a/pyasic/miners/types/antminer/X3/L3.py +++ b/pyasic/miners/types/antminer/X3/L3.py @@ -20,6 +20,6 @@ class L3Plus(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "L3+" + self.raw_model = "L3+" self.expected_chips = 72 self.fan_count = 2 diff --git a/pyasic/miners/types/antminer/X5/DR5.py b/pyasic/miners/types/antminer/X5/DR5.py index c688c0b3..f6bf4c10 100644 --- a/pyasic/miners/types/antminer/X5/DR5.py +++ b/pyasic/miners/types/antminer/X5/DR5.py @@ -21,7 +21,7 @@ class DR5(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "DR5" + self.raw_model = "DR5" self.expected_chips = 72 self.expected_hashboards = 3 self.fan_count = 2 diff --git a/pyasic/miners/types/antminer/X7/L7.py b/pyasic/miners/types/antminer/X7/L7.py index abcfd920..1401aa27 100644 --- a/pyasic/miners/types/antminer/X7/L7.py +++ b/pyasic/miners/types/antminer/X7/L7.py @@ -20,6 +20,6 @@ class L7(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "L7" + self.raw_model = "L7" self.expected_chips = 120 self.fan_count = 4 diff --git a/pyasic/miners/types/antminer/X9/E9.py b/pyasic/miners/types/antminer/X9/E9.py index 315dc0f5..771ad5cd 100644 --- a/pyasic/miners/types/antminer/X9/E9.py +++ b/pyasic/miners/types/antminer/X9/E9.py @@ -21,7 +21,7 @@ class E9Pro(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "E9Pro" + self.raw_model = "E9Pro" self.expected_chips = 8 self.expected_hashboards = 2 self.fan_count = 4 diff --git a/pyasic/miners/types/antminer/X9/S9.py b/pyasic/miners/types/antminer/X9/S9.py index 48f8b009..32940bf9 100644 --- a/pyasic/miners/types/antminer/X9/S9.py +++ b/pyasic/miners/types/antminer/X9/S9.py @@ -21,7 +21,7 @@ class S9(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S9" + self.raw_model = "S9" self.expected_chips = 63 self.fan_count = 2 @@ -30,7 +30,7 @@ class S9i(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S9i" + self.raw_model = "S9i" self.expected_chips = 63 self.fan_count = 2 @@ -39,6 +39,6 @@ class S9j(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "S9j" + self.raw_model = "S9j" self.expected_chips = 63 self.fan_count = 2 diff --git a/pyasic/miners/types/antminer/X9/T9.py b/pyasic/miners/types/antminer/X9/T9.py index 44273c24..83a27de4 100644 --- a/pyasic/miners/types/antminer/X9/T9.py +++ b/pyasic/miners/types/antminer/X9/T9.py @@ -21,6 +21,6 @@ class T9(AntMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "T9" + self.raw_model = "T9" self.expected_chips = 54 self.fan_count = 2 diff --git a/pyasic/miners/types/avalonminer/A10X/A1026.py b/pyasic/miners/types/avalonminer/A10X/A1026.py index b7655e14..909f32ac 100644 --- a/pyasic/miners/types/avalonminer/A10X/A1026.py +++ b/pyasic/miners/types/avalonminer/A10X/A1026.py @@ -21,6 +21,6 @@ class Avalon1026(AvalonMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "Avalon 1026" + self.raw_model = "Avalon 1026" self.expected_chips = 80 self.fan_count = 2 diff --git a/pyasic/miners/types/avalonminer/A10X/A1047.py b/pyasic/miners/types/avalonminer/A10X/A1047.py index 6bf344ef..9880dadf 100644 --- a/pyasic/miners/types/avalonminer/A10X/A1047.py +++ b/pyasic/miners/types/avalonminer/A10X/A1047.py @@ -21,6 +21,6 @@ class Avalon1047(AvalonMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "Avalon 1047" + self.raw_model = "Avalon 1047" self.expected_chips = 80 self.fan_count = 2 diff --git a/pyasic/miners/types/avalonminer/A10X/A1066.py b/pyasic/miners/types/avalonminer/A10X/A1066.py index eb6dcd67..c9c7ad69 100644 --- a/pyasic/miners/types/avalonminer/A10X/A1066.py +++ b/pyasic/miners/types/avalonminer/A10X/A1066.py @@ -21,6 +21,6 @@ class Avalon1066(AvalonMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "Avalon 1066" + self.raw_model = "Avalon 1066" self.expected_chips = 114 self.fan_count = 4 diff --git a/pyasic/miners/types/avalonminer/A11X/A1166.py b/pyasic/miners/types/avalonminer/A11X/A1166.py index 0a809c1e..e26136f7 100644 --- a/pyasic/miners/types/avalonminer/A11X/A1166.py +++ b/pyasic/miners/types/avalonminer/A11X/A1166.py @@ -22,6 +22,6 @@ class Avalon1166Pro(AvalonMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "Avalon 1166 Pro" + self.raw_model = "Avalon 1166 Pro" self.expected_chips = 120 self.fan_count = 4 diff --git a/pyasic/miners/types/avalonminer/A12X/A1246.py b/pyasic/miners/types/avalonminer/A12X/A1246.py index 7443ed0f..98b3dd1a 100644 --- a/pyasic/miners/types/avalonminer/A12X/A1246.py +++ b/pyasic/miners/types/avalonminer/A12X/A1246.py @@ -22,6 +22,6 @@ class Avalon1246(AvalonMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "Avalon 1246" + self.raw_model = "Avalon 1246" self.expected_chips = 120 self.fan_count = 4 diff --git a/pyasic/miners/types/avalonminer/A7X/A721.py b/pyasic/miners/types/avalonminer/A7X/A721.py index 9c4de083..4074ddf2 100644 --- a/pyasic/miners/types/avalonminer/A7X/A721.py +++ b/pyasic/miners/types/avalonminer/A7X/A721.py @@ -21,7 +21,7 @@ class Avalon721(AvalonMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "Avalon 721" + self.raw_model = "Avalon 721" self.expected_hashboards = 4 self.expected_chips = 18 self.fan_count = 1 diff --git a/pyasic/miners/types/avalonminer/A7X/A741.py b/pyasic/miners/types/avalonminer/A7X/A741.py index 6ee44d13..4c2c704c 100644 --- a/pyasic/miners/types/avalonminer/A7X/A741.py +++ b/pyasic/miners/types/avalonminer/A7X/A741.py @@ -21,7 +21,7 @@ class Avalon741(AvalonMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "Avalon 741" + self.raw_model = "Avalon 741" self.expected_hashboards = 4 self.expected_chips = 22 self.fan_count = 1 diff --git a/pyasic/miners/types/avalonminer/A7X/A761.py b/pyasic/miners/types/avalonminer/A7X/A761.py index 118d8c58..a4ee460c 100644 --- a/pyasic/miners/types/avalonminer/A7X/A761.py +++ b/pyasic/miners/types/avalonminer/A7X/A761.py @@ -21,7 +21,7 @@ class Avalon761(AvalonMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "Avalon 761" + self.raw_model = "Avalon 761" self.expected_hashboards = 4 self.expected_chips = 18 self.fan_count = 1 diff --git a/pyasic/miners/types/avalonminer/A8X/A821.py b/pyasic/miners/types/avalonminer/A8X/A821.py index 129e4abc..137a9feb 100644 --- a/pyasic/miners/types/avalonminer/A8X/A821.py +++ b/pyasic/miners/types/avalonminer/A8X/A821.py @@ -21,7 +21,7 @@ class Avalon821(AvalonMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "Avalon 821" + self.raw_model = "Avalon 821" self.expected_hashboards = 4 self.expected_chips = 26 self.fan_count = 1 diff --git a/pyasic/miners/types/avalonminer/A8X/A841.py b/pyasic/miners/types/avalonminer/A8X/A841.py index aee85c2c..eaa2ceef 100644 --- a/pyasic/miners/types/avalonminer/A8X/A841.py +++ b/pyasic/miners/types/avalonminer/A8X/A841.py @@ -21,7 +21,7 @@ class Avalon841(AvalonMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "Avalon 841" + self.raw_model = "Avalon 841" self.expected_hashboards = 4 self.expected_chips = 26 self.fan_count = 1 diff --git a/pyasic/miners/types/avalonminer/A8X/A851.py b/pyasic/miners/types/avalonminer/A8X/A851.py index 97691680..f6451d5f 100644 --- a/pyasic/miners/types/avalonminer/A8X/A851.py +++ b/pyasic/miners/types/avalonminer/A8X/A851.py @@ -21,7 +21,7 @@ class Avalon851(AvalonMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "Avalon 851" + self.raw_model = "Avalon 851" self.expected_hashboards = 4 self.expected_chips = 26 self.fan_count = 1 diff --git a/pyasic/miners/types/avalonminer/A9X/A921.py b/pyasic/miners/types/avalonminer/A9X/A921.py index 8873ee93..3882bba3 100644 --- a/pyasic/miners/types/avalonminer/A9X/A921.py +++ b/pyasic/miners/types/avalonminer/A9X/A921.py @@ -21,7 +21,7 @@ class Avalon921(AvalonMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "Avalon 921" + self.raw_model = "Avalon 921" self.expected_hashboards = 4 self.expected_chips = 26 self.fan_count = 1 diff --git a/pyasic/miners/types/goldshell/X5/CK5.py b/pyasic/miners/types/goldshell/X5/CK5.py index 51771600..3f7fd4eb 100644 --- a/pyasic/miners/types/goldshell/X5/CK5.py +++ b/pyasic/miners/types/goldshell/X5/CK5.py @@ -20,7 +20,7 @@ class CK5(GoldshellMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "CK5" + self.raw_model = "CK5" self.expected_hashboards = 4 self.expected_chips = 46 self.fan_count = 4 diff --git a/pyasic/miners/types/goldshell/X5/HS5.py b/pyasic/miners/types/goldshell/X5/HS5.py index b789af55..2ee19a79 100644 --- a/pyasic/miners/types/goldshell/X5/HS5.py +++ b/pyasic/miners/types/goldshell/X5/HS5.py @@ -20,7 +20,7 @@ class HS5(GoldshellMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "HS5" + self.raw_model = "HS5" self.expected_hashboards = 4 self.expected_chips = 46 self.fan_count = 4 diff --git a/pyasic/miners/types/goldshell/X5/KD5.py b/pyasic/miners/types/goldshell/X5/KD5.py index 21f137d4..9ac33ebc 100644 --- a/pyasic/miners/types/goldshell/X5/KD5.py +++ b/pyasic/miners/types/goldshell/X5/KD5.py @@ -20,7 +20,7 @@ class KD5(GoldshellMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "KD5" + self.raw_model = "KD5" self.expected_hashboards = 4 self.expected_chips = 46 self.fan_count = 4 diff --git a/pyasic/miners/types/goldshell/XMax/KDMax.py b/pyasic/miners/types/goldshell/XMax/KDMax.py index 8c42dd58..6924a01c 100644 --- a/pyasic/miners/types/goldshell/XMax/KDMax.py +++ b/pyasic/miners/types/goldshell/XMax/KDMax.py @@ -20,7 +20,7 @@ class KDMax(GoldshellMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "KD Max" + self.raw_model = "KD Max" self.expected_hashboards = 3 self.expected_chips = 84 self.fan_count = 4 diff --git a/pyasic/miners/types/innosilicon/A10X/A10X.py b/pyasic/miners/types/innosilicon/A10X/A10X.py index aeeb0dca..b4d489f3 100644 --- a/pyasic/miners/types/innosilicon/A10X/A10X.py +++ b/pyasic/miners/types/innosilicon/A10X/A10X.py @@ -20,4 +20,4 @@ class A10X(InnosiliconMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0") -> None: super().__init__(ip, api_ver) self.ip = ip - self.model = "A10X" + self.raw_model = "A10X" diff --git a/pyasic/miners/types/innosilicon/T3X/T3H.py b/pyasic/miners/types/innosilicon/T3X/T3H.py index cc56274d..bea0a4aa 100644 --- a/pyasic/miners/types/innosilicon/T3X/T3H.py +++ b/pyasic/miners/types/innosilicon/T3X/T3H.py @@ -21,6 +21,6 @@ class T3HPlus(InnosiliconMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0") -> None: super().__init__(ip, api_ver) self.ip = ip - self.model = "T3H+" + self.raw_model = "T3H+" self.expected_chips = 114 self.fan_count = 4 diff --git a/pyasic/miners/types/whatsminer/M2X/M20.py b/pyasic/miners/types/whatsminer/M2X/M20.py index cb805605..01075d86 100644 --- a/pyasic/miners/types/whatsminer/M2X/M20.py +++ b/pyasic/miners/types/whatsminer/M2X/M20.py @@ -21,6 +21,6 @@ class M20V10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M20 V10" + self.raw_model = "M20 V10" self.expected_chips = 70 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M2X/M20P.py b/pyasic/miners/types/whatsminer/M2X/M20P.py index 60c9024b..91c648c1 100644 --- a/pyasic/miners/types/whatsminer/M2X/M20P.py +++ b/pyasic/miners/types/whatsminer/M2X/M20P.py @@ -21,7 +21,7 @@ class M20PV10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M20P V10" + self.raw_model = "M20P V10" self.expected_chips = 156 self.fan_count = 2 @@ -30,6 +30,6 @@ class M20PV30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M20P V30" + self.raw_model = "M20P V30" self.expected_chips = 148 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M2X/M20S.py b/pyasic/miners/types/whatsminer/M2X/M20S.py index 72caa9d3..ccfa4d80 100644 --- a/pyasic/miners/types/whatsminer/M2X/M20S.py +++ b/pyasic/miners/types/whatsminer/M2X/M20S.py @@ -23,7 +23,7 @@ class M20SV10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M20S V10" + self.raw_model = "M20S V10" self.expected_chips = 105 self.fan_count = 2 @@ -32,7 +32,7 @@ class M20SV20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M20S V20" + self.raw_model = "M20S V20" self.expected_chips = 111 self.fan_count = 2 @@ -41,6 +41,6 @@ class M20SV30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M20S V30" + self.raw_model = "M20S V30" self.expected_chips = 140 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M2X/M20S_Plus.py b/pyasic/miners/types/whatsminer/M2X/M20S_Plus.py index 40d3cfe5..036fffb0 100644 --- a/pyasic/miners/types/whatsminer/M2X/M20S_Plus.py +++ b/pyasic/miners/types/whatsminer/M2X/M20S_Plus.py @@ -23,7 +23,7 @@ class M20SPlusV30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M20S+ V30" + self.raw_model = "M20S+ V30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M20S+ V30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." diff --git a/pyasic/miners/types/whatsminer/M2X/M21.py b/pyasic/miners/types/whatsminer/M2X/M21.py index b523d291..1a2f811c 100644 --- a/pyasic/miners/types/whatsminer/M2X/M21.py +++ b/pyasic/miners/types/whatsminer/M2X/M21.py @@ -23,6 +23,6 @@ class M21V10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M21 V10" + self.raw_model = "M21 V10" self.expected_chips = 33 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M2X/M21S.py b/pyasic/miners/types/whatsminer/M2X/M21S.py index 3fd378f2..dd224341 100644 --- a/pyasic/miners/types/whatsminer/M2X/M21S.py +++ b/pyasic/miners/types/whatsminer/M2X/M21S.py @@ -23,7 +23,7 @@ class M21SV20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M21S V20" + self.raw_model = "M21S V20" self.expected_chips = 66 self.fan_count = 2 @@ -32,7 +32,7 @@ class M21SV60(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M21S V60" + self.raw_model = "M21S V60" self.expected_chips = 105 self.fan_count = 2 @@ -41,6 +41,6 @@ class M21SV70(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M21S V70" + self.raw_model = "M21S V70" self.expected_chips = 111 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M2X/M21S_Plus.py b/pyasic/miners/types/whatsminer/M2X/M21S_Plus.py index 6c231025..178e7a3c 100644 --- a/pyasic/miners/types/whatsminer/M2X/M21S_Plus.py +++ b/pyasic/miners/types/whatsminer/M2X/M21S_Plus.py @@ -23,7 +23,7 @@ class M21SPlusV20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M21S+ V20" + self.raw_model = "M21S+ V20" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M21S+ V20, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." diff --git a/pyasic/miners/types/whatsminer/M2X/M29.py b/pyasic/miners/types/whatsminer/M2X/M29.py index 0c2eeab4..e3cd9d34 100644 --- a/pyasic/miners/types/whatsminer/M2X/M29.py +++ b/pyasic/miners/types/whatsminer/M2X/M29.py @@ -23,6 +23,6 @@ class M29V10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M29 V10" + self.raw_model = "M29 V10" self.expected_chips = 50 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M3X/M30.py b/pyasic/miners/types/whatsminer/M3X/M30.py index 3d9d5560..4e1aaf0d 100644 --- a/pyasic/miners/types/whatsminer/M3X/M30.py +++ b/pyasic/miners/types/whatsminer/M3X/M30.py @@ -23,7 +23,7 @@ class M30V10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30 V10" + self.raw_model = "M30 V10" self.expected_chips = 105 self.fan_count = 2 @@ -32,6 +32,6 @@ class M30V20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30 V20" + self.raw_model = "M30 V20" self.expected_chips = 111 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M3X/M30K.py b/pyasic/miners/types/whatsminer/M3X/M30K.py index e8fafa51..b951c10b 100644 --- a/pyasic/miners/types/whatsminer/M3X/M30K.py +++ b/pyasic/miners/types/whatsminer/M3X/M30K.py @@ -23,7 +23,7 @@ class M30KV10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30K V10" + self.raw_model = "M30K V10" self.expected_hashboards = 4 self.expected_chips = 240 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M3X/M30L.py b/pyasic/miners/types/whatsminer/M3X/M30L.py index 07ea7870..191b5e60 100644 --- a/pyasic/miners/types/whatsminer/M3X/M30L.py +++ b/pyasic/miners/types/whatsminer/M3X/M30L.py @@ -23,7 +23,7 @@ class M30LV10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30L V10" + self.raw_model = "M30L V10" self.board_num = 4 self.expected_chips = 144 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M3X/M30S.py b/pyasic/miners/types/whatsminer/M3X/M30S.py index 0d225a8e..c9f4f12d 100644 --- a/pyasic/miners/types/whatsminer/M3X/M30S.py +++ b/pyasic/miners/types/whatsminer/M3X/M30S.py @@ -23,7 +23,7 @@ class M30SV10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S V10" + self.raw_model = "M30S V10" self.expected_chips = 148 self.fan_count = 2 @@ -32,7 +32,7 @@ class M30SV20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S V20" + self.raw_model = "M30S V20" self.expected_chips = 156 self.fan_count = 2 @@ -41,7 +41,7 @@ class M30SV30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S V30" + self.raw_model = "M30S V30" self.expected_chips = 164 self.fan_count = 2 @@ -50,7 +50,7 @@ class M30SV40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S V40" + self.raw_model = "M30S V40" self.expected_chips = 172 self.fan_count = 2 @@ -59,7 +59,7 @@ class M30SV50(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S V50" + self.raw_model = "M30S V50" self.expected_chips = 156 self.fan_count = 2 @@ -68,7 +68,7 @@ class M30SV60(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S V60" + self.raw_model = "M30S V60" self.expected_chips = 164 self.fan_count = 2 @@ -77,7 +77,7 @@ class M30SV70(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S V70" + self.raw_model = "M30S V70" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M30SV70, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -89,7 +89,7 @@ class M30SV80(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S V80" + self.raw_model = "M30S V80" self.expected_chips = 129 self.fan_count = 2 @@ -98,7 +98,7 @@ class M30SVE10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VE10" + self.raw_model = "M30S VE10" self.expected_chips = 105 self.fan_count = 2 @@ -107,7 +107,7 @@ class M30SVE20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VE20" + self.raw_model = "M30S VE20" self.expected_chips = 111 self.fan_count = 2 @@ -116,7 +116,7 @@ class M30SVE30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VE30" + self.raw_model = "M30S VE30" self.expected_chips = 117 self.fan_count = 2 @@ -125,7 +125,7 @@ class M30SVE40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VE40" + self.raw_model = "M30S VE40" self.expected_chips = 123 self.fan_count = 2 @@ -134,7 +134,7 @@ class M30SVE50(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VE50" + self.raw_model = "M30S VE50" self.expected_chips = 129 self.fan_count = 2 @@ -143,7 +143,7 @@ class M30SVE60(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VE60" + self.raw_model = "M30S VE60" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M30SVE60, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -155,7 +155,7 @@ class M30SVE70(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VE70" + self.raw_model = "M30S VE70" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M30SVE70, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -167,7 +167,7 @@ class M30SVF10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VF10" + self.raw_model = "M30S VF10" self.expected_chips = 70 self.fan_count = 2 @@ -176,7 +176,7 @@ class M30SVF20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VF20" + self.raw_model = "M30S VF20" self.expected_chips = 74 self.fan_count = 2 @@ -185,7 +185,7 @@ class M30SVF30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VF30" + self.raw_model = "M30S VF30" self.expected_chips = 78 self.fan_count = 2 @@ -194,7 +194,7 @@ class M30SVG10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VG10" + self.raw_model = "M30S VG10" self.expected_chips = 66 self.fan_count = 2 @@ -203,7 +203,7 @@ class M30SVG20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VG20" + self.raw_model = "M30S VG20" self.expected_chips = 70 self.fan_count = 2 @@ -212,7 +212,7 @@ class M30SVG30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VG30" + self.raw_model = "M30S VG30" self.expected_chips = 74 self.fan_count = 2 @@ -221,7 +221,7 @@ class M30SVG40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VG40" + self.raw_model = "M30S VG40" self.expected_chips = 78 self.fan_count = 2 @@ -230,7 +230,7 @@ class M30SVH10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VH10" + self.raw_model = "M30S VH10" self.expected_chips = 64 self.fan_count = 2 @@ -239,7 +239,7 @@ class M30SVH20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VH20" + self.raw_model = "M30S VH20" self.expected_chips = 66 self.fan_count = 2 @@ -248,7 +248,7 @@ class M30SVH30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VH30" + self.raw_model = "M30S VH30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M30SVH30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -260,7 +260,7 @@ class M30SVH40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VH40" + self.raw_model = "M30S VH40" self.expected_chips = 64 self.fan_count = 2 @@ -269,7 +269,7 @@ class M30SVH50(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VH50" + self.raw_model = "M30S VH50" self.expected_chips = 66 self.fan_count = 2 @@ -278,7 +278,7 @@ class M30SVH60(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VH60" + self.raw_model = "M30S VH60" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M30SVH60, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -290,6 +290,6 @@ class M30SVI20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S VI20" + self.raw_model = "M30S VI20" self.expected_chips = 70 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M3X/M30S_Plus.py b/pyasic/miners/types/whatsminer/M3X/M30S_Plus.py index 16df8c9b..2f0d2f8e 100644 --- a/pyasic/miners/types/whatsminer/M3X/M30S_Plus.py +++ b/pyasic/miners/types/whatsminer/M3X/M30S_Plus.py @@ -23,7 +23,7 @@ class M30SPlusV10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ V10" + self.raw_model = "M30S+ V10" self.expected_chips = 215 self.fan_count = 2 @@ -32,7 +32,7 @@ class M30SPlusV20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ V20" + self.raw_model = "M30S+ V20" self.expected_chips = 255 self.fan_count = 2 @@ -41,7 +41,7 @@ class M30SPlusV30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ V30" + self.raw_model = "M30S+ V30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M30S+ V30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -53,7 +53,7 @@ class M30SPlusV40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ V40" + self.raw_model = "M30S+ V40" self.expected_chips = 235 self.fan_count = 2 @@ -62,7 +62,7 @@ class M30SPlusV50(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ V50" + self.raw_model = "M30S+ V50" self.expected_chips = 225 self.fan_count = 2 @@ -71,7 +71,7 @@ class M30SPlusV60(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ V60" + self.raw_model = "M30S+ V60" self.expected_chips = 245 self.fan_count = 2 @@ -80,7 +80,7 @@ class M30SPlusV70(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ V70" + self.raw_model = "M30S+ V70" self.expected_chips = 235 self.fan_count = 2 @@ -89,7 +89,7 @@ class M30SPlusV80(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ V80" + self.raw_model = "M30S+ V80" self.expected_chips = 245 self.fan_count = 2 @@ -98,7 +98,7 @@ class M30SPlusV90(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ V90" + self.raw_model = "M30S+ V90" self.expected_chips = 225 self.fan_count = 2 @@ -107,7 +107,7 @@ class M30SPlusV100(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ V100" + self.raw_model = "M30S+ V100" self.expected_chips = 215 self.fan_count = 2 @@ -116,7 +116,7 @@ class M30SPlusVE30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VE30" + self.raw_model = "M30S+ VE30" self.expected_chips = 148 self.fan_count = 2 @@ -125,7 +125,7 @@ class M30SPlusVE40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VE40" + self.raw_model = "M30S+ VE40" self.expected_chips = 156 self.fan_count = 2 @@ -134,7 +134,7 @@ class M30SPlusVE50(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VE50" + self.raw_model = "M30S+ VE50" self.expected_chips = 164 self.fan_count = 2 @@ -143,7 +143,7 @@ class M30SPlusVE60(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VE60" + self.raw_model = "M30S+ VE60" self.expected_chips = 172 self.fan_count = 2 @@ -152,7 +152,7 @@ class M30SPlusVE70(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VE70" + self.raw_model = "M30S+ VE70" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M30S+ VE70, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -164,7 +164,7 @@ class M30SPlusVE80(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VE80" + self.raw_model = "M30S+ VE80" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M30S+ VE80, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -176,7 +176,7 @@ class M30SPlusVE90(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VE90" + self.raw_model = "M30S+ VE90" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M30S+ VE90, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -188,7 +188,7 @@ class M30SPlusVE100(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VE100" + self.raw_model = "M30S+ VE100" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M30S+ VE100, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -200,7 +200,7 @@ class M30SPlusVF20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VF20" + self.raw_model = "M30S+ VF20" self.expected_chips = 111 self.fan_count = 2 @@ -209,7 +209,7 @@ class M30SPlusVF30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VF30" + self.raw_model = "M30S+ VF30" self.expected_chips = 117 self.fan_count = 2 @@ -218,7 +218,7 @@ class M30SPlusVG20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VG20" + self.raw_model = "M30S+ VG20" self.expected_chips = 82 self.fan_count = 2 @@ -227,7 +227,7 @@ class M30SPlusVG30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VG30" + self.raw_model = "M30S+ VG30" self.expected_chips = 78 self.fan_count = 2 @@ -236,7 +236,7 @@ class M30SPlusVG40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VG40" + self.raw_model = "M30S+ VG40" self.expected_chips = 105 self.fan_count = 2 @@ -245,7 +245,7 @@ class M30SPlusVG50(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VG50" + self.raw_model = "M30S+ VG50" self.expected_chips = 111 self.fan_count = 2 @@ -254,7 +254,7 @@ class M30SPlusVG60(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VG60" + self.raw_model = "M30S+ VG60" self.expected_chips = 86 self.fan_count = 2 @@ -263,7 +263,7 @@ class M30SPlusVH10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VH10" + self.raw_model = "M30S+ VH10" self.expected_chips = 64 self.fan_count = 2 @@ -272,7 +272,7 @@ class M30SPlusVH20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VH20" + self.raw_model = "M30S+ VH20" self.expected_chips = 66 self.fan_count = 2 @@ -281,7 +281,7 @@ class M30SPlusVH30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VH30" + self.raw_model = "M30S+ VH30" self.expected_chips = 70 self.fan_count = 2 @@ -290,7 +290,7 @@ class M30SPlusVH40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VH40" + self.raw_model = "M30S+ VH40" self.expected_chips = 74 self.fan_count = 2 @@ -299,7 +299,7 @@ class M30SPlusVH50(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VH50" + self.raw_model = "M30S+ VH50" self.expected_chips = 64 self.fan_count = 2 @@ -308,6 +308,6 @@ class M30SPlusVH60(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S+ VH60" + self.raw_model = "M30S+ VH60" self.expected_chips = 66 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M3X/M30S_Plus_Plus.py b/pyasic/miners/types/whatsminer/M3X/M30S_Plus_Plus.py index 4ccac9e6..9a257031 100644 --- a/pyasic/miners/types/whatsminer/M3X/M30S_Plus_Plus.py +++ b/pyasic/miners/types/whatsminer/M3X/M30S_Plus_Plus.py @@ -23,7 +23,7 @@ class M30SPlusPlusV10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ V10" + self.raw_model = "M30S++ V10" self.expected_hashboards = 4 self.expected_chips = 255 self.fan_count = 2 @@ -33,7 +33,7 @@ class M30SPlusPlusV20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ V20" + self.raw_model = "M30S++ V20" self.expected_hashboards = 4 self.expected_chips = 255 self.fan_count = 2 @@ -43,7 +43,7 @@ class M30SPlusPlusVE30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VE30" + self.raw_model = "M30S++ VE30" self.expected_chips = 215 self.fan_count = 2 @@ -52,7 +52,7 @@ class M30SPlusPlusVE40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VE40" + self.raw_model = "M30S++ VE40" self.expected_chips = 225 self.fan_count = 2 @@ -61,7 +61,7 @@ class M30SPlusPlusVE50(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VE50" + self.raw_model = "M30S++ VE50" self.expected_chips = 235 self.fan_count = 2 @@ -70,7 +70,7 @@ class M30SPlusPlusVF40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VF40" + self.raw_model = "M30S++ VF40" self.expected_chips = 156 self.fan_count = 2 @@ -79,7 +79,7 @@ class M30SPlusPlusVG30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VG30" + self.raw_model = "M30S++ VG30" self.expected_chips = 111 self.fan_count = 2 @@ -88,7 +88,7 @@ class M30SPlusPlusVG40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VG40" + self.raw_model = "M30S++ VG40" self.expected_chips = 117 self.fan_count = 2 @@ -97,7 +97,7 @@ class M30SPlusPlusVG50(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VG50" + self.raw_model = "M30S++ VG50" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M30S++ VG50, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -109,7 +109,7 @@ class M30SPlusPlusVH10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VH10" + self.raw_model = "M30S++ VH10" self.expected_chips = 82 self.fan_count = 2 @@ -118,7 +118,7 @@ class M30SPlusPlusVH20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VH20" + self.raw_model = "M30S++ VH20" self.expected_chips = 86 self.fan_count = 2 @@ -127,7 +127,7 @@ class M30SPlusPlusVH30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VH30" + self.raw_model = "M30S++ VH30" self.expected_chips = 111 self.fan_count = 2 @@ -136,7 +136,7 @@ class M30SPlusPlusVH40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VH40" + self.raw_model = "M30S++ VH40" self.expected_chips = 70 self.fan_count = 2 @@ -145,7 +145,7 @@ class M30SPlusPlusVH50(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VH50" + self.raw_model = "M30S++ VH50" self.expected_chips = 74 self.fan_count = 2 @@ -154,7 +154,7 @@ class M30SPlusPlusVH60(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VH60" + self.raw_model = "M30S++ VH60" self.expected_chips = 78 self.fan_count = 2 @@ -163,7 +163,7 @@ class M30SPlusPlusVH70(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VH70" + self.raw_model = "M30S++ VH70" self.expected_chips = 70 self.fan_count = 2 @@ -172,7 +172,7 @@ class M30SPlusPlusVH80(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VH80" + self.raw_model = "M30S++ VH80" self.expected_chips = 74 self.fan_count = 2 @@ -181,7 +181,7 @@ class M30SPlusPlusVH90(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VH90" + self.raw_model = "M30S++ VH90" self.expected_chips = 78 self.fan_count = 2 @@ -190,7 +190,7 @@ class M30SPlusPlusVH100(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VH100" + self.raw_model = "M30S++ VH100" self.expected_chips = 82 self.fan_count = 2 @@ -199,7 +199,7 @@ class M30SPlusPlusVJ20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VJ20" + self.raw_model = "M30S++ VJ20" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M30S++ VJ20, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -211,7 +211,7 @@ class M30SPlusPlusVJ30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M30S++ VJ30" + self.raw_model = "M30S++ VJ30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M30S++ VJ30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." diff --git a/pyasic/miners/types/whatsminer/M3X/M31.py b/pyasic/miners/types/whatsminer/M3X/M31.py index 07785517..0e5b7003 100644 --- a/pyasic/miners/types/whatsminer/M3X/M31.py +++ b/pyasic/miners/types/whatsminer/M3X/M31.py @@ -23,7 +23,7 @@ class M31V10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31 V10" + self.raw_model = "M31 V10" self.expected_chips = 70 self.fan_count = 2 @@ -32,6 +32,6 @@ class M31V20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31 V20" + self.raw_model = "M31 V20" self.expected_chips = 74 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M3X/M31H.py b/pyasic/miners/types/whatsminer/M3X/M31H.py index 8a1a9540..64612a1b 100644 --- a/pyasic/miners/types/whatsminer/M3X/M31H.py +++ b/pyasic/miners/types/whatsminer/M3X/M31H.py @@ -23,7 +23,7 @@ class M31HV10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31H V10" + self.raw_model = "M31H V10" self.expected_chips = 114 self.fan_count = 0 @@ -32,7 +32,7 @@ class M31HV40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31H V40" + self.raw_model = "M31H V40" self.expected_hashboards = 4 self.expected_chips = 136 self.fan_count = 0 diff --git a/pyasic/miners/types/whatsminer/M3X/M31L.py b/pyasic/miners/types/whatsminer/M3X/M31L.py index d5eca1b5..7b30e980 100644 --- a/pyasic/miners/types/whatsminer/M3X/M31L.py +++ b/pyasic/miners/types/whatsminer/M3X/M31L.py @@ -23,6 +23,6 @@ class M31LV10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31L V10" + self.raw_model = "M31L V10" self.expected_chips = 114 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M3X/M31S.py b/pyasic/miners/types/whatsminer/M3X/M31S.py index 70e4a9d1..cbe6df82 100644 --- a/pyasic/miners/types/whatsminer/M3X/M31S.py +++ b/pyasic/miners/types/whatsminer/M3X/M31S.py @@ -23,7 +23,7 @@ class M31SV10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S V10" + self.raw_model = "M31S V10" self.expected_chips = 105 self.fan_count = 2 @@ -32,7 +32,7 @@ class M31SV20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S V20" + self.raw_model = "M31S V20" self.expected_chips = 111 self.fan_count = 2 @@ -41,7 +41,7 @@ class M31SV30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S V30" + self.raw_model = "M31S V30" self.expected_chips = 117 self.fan_count = 2 @@ -50,7 +50,7 @@ class M31SV40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S V40" + self.raw_model = "M31S V40" self.expected_chips = 123 self.fan_count = 2 @@ -59,7 +59,7 @@ class M31SV50(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S V50" + self.raw_model = "M31S V50" self.expected_chips = 78 self.fan_count = 2 @@ -68,7 +68,7 @@ class M31SV60(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S V60" + self.raw_model = "M31S V60" self.expected_chips = 105 self.fan_count = 2 @@ -77,7 +77,7 @@ class M31SV70(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S V70" + self.raw_model = "M31S V70" self.expected_chips = 111 self.fan_count = 2 @@ -86,7 +86,7 @@ class M31SV80(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S V80" + self.raw_model = "M31S V80" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M31SV80, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -98,7 +98,7 @@ class M31SV90(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S V90" + self.raw_model = "M31S V90" self.expected_chips = 117 self.fan_count = 2 @@ -107,7 +107,7 @@ class M31SVE10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S VE10" + self.raw_model = "M31S VE10" self.expected_chips = 70 self.fan_count = 2 @@ -116,7 +116,7 @@ class M31SVE20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S VE20" + self.raw_model = "M31S VE20" self.expected_chips = 74 self.fan_count = 2 @@ -125,7 +125,7 @@ class M31SVE30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S VE30" + self.raw_model = "M31S VE30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M31SVE30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." diff --git a/pyasic/miners/types/whatsminer/M3X/M31SE.py b/pyasic/miners/types/whatsminer/M3X/M31SE.py index c16ead2c..5f6aff90 100644 --- a/pyasic/miners/types/whatsminer/M3X/M31SE.py +++ b/pyasic/miners/types/whatsminer/M3X/M31SE.py @@ -23,7 +23,7 @@ class M31SEV10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31SE V10" + self.raw_model = "M31SE V10" self.expected_chips = 82 self.fan_count = 2 @@ -32,7 +32,7 @@ class M31SEV20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31SE V20" + self.raw_model = "M31SE V20" self.expected_chips = 78 self.fan_count = 2 @@ -41,6 +41,6 @@ class M31SEV30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31SE V30" + self.raw_model = "M31SE V30" self.expected_chips = 78 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M3X/M31S_Plus.py b/pyasic/miners/types/whatsminer/M3X/M31S_Plus.py index 3a609ff8..e4eccfee 100644 --- a/pyasic/miners/types/whatsminer/M3X/M31S_Plus.py +++ b/pyasic/miners/types/whatsminer/M3X/M31S_Plus.py @@ -23,7 +23,7 @@ class M31SPlusV10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ V10" + self.raw_model = "M31S+ V10" self.expected_chips = 105 self.fan_count = 2 @@ -32,7 +32,7 @@ class M31SPlusV20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ V20" + self.raw_model = "M31S+ V20" self.expected_chips = 111 self.fan_count = 2 @@ -41,7 +41,7 @@ class M31SPlusV30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ V30" + self.raw_model = "M31S+ V30" self.expected_chips = 117 self.fan_count = 2 @@ -50,7 +50,7 @@ class M31SPlusV40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ V40" + self.raw_model = "M31S+ V40" self.expected_chips = 123 self.fan_count = 2 @@ -59,7 +59,7 @@ class M31SPlusV50(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ V50" + self.raw_model = "M31S+ V50" self.expected_chips = 148 self.fan_count = 2 @@ -68,7 +68,7 @@ class M31SPlusV60(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ V60" + self.raw_model = "M31S+ V60" self.expected_chips = 156 self.fan_count = 2 @@ -77,7 +77,7 @@ class M31SPlusV80(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ V80" + self.raw_model = "M31S+ V80" self.expected_chips = 129 self.fan_count = 2 @@ -86,7 +86,7 @@ class M31SPlusV90(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ V90" + self.raw_model = "M31S+ V90" self.expected_chips = 117 self.fan_count = 2 @@ -95,7 +95,7 @@ class M31SPlusV100(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ V100" + self.raw_model = "M31S+ V100" self.expected_chips = 111 self.fan_count = 2 @@ -104,7 +104,7 @@ class M31SPlusVE10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ VE10" + self.raw_model = "M31S+ VE10" self.expected_chips = 82 self.fan_count = 2 @@ -113,7 +113,7 @@ class M31SPlusVE20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ VE20" + self.raw_model = "M31S+ VE20" self.expected_chips = 78 self.fan_count = 2 @@ -122,7 +122,7 @@ class M31SPlusVE30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ VE30" + self.raw_model = "M31S+ VE30" self.expected_chips = 105 self.fan_count = 2 @@ -131,7 +131,7 @@ class M31SPlusVE40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ VE40" + self.raw_model = "M31S+ VE40" self.expected_chips = 111 self.fan_count = 2 @@ -140,7 +140,7 @@ class M31SPlusVE50(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ VE50" + self.raw_model = "M31S+ VE50" self.expected_chips = 117 self.fan_count = 2 @@ -149,7 +149,7 @@ class M31SPlusVE60(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ VE60" + self.raw_model = "M31S+ VE60" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M30S+ VE60, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -161,7 +161,7 @@ class M31SPlusVE80(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ VE80" + self.raw_model = "M31S+ VE80" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M30S+ VE80, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -173,7 +173,7 @@ class M31SPlusVF20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ VF20" + self.raw_model = "M31S+ VF20" self.expected_chips = 66 self.fan_count = 2 @@ -182,7 +182,7 @@ class M31SPlusVF30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ VF30" + self.raw_model = "M31S+ VF30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M30S+ VF30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -194,7 +194,7 @@ class M31SPlusVG20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ VG20" + self.raw_model = "M31S+ VG20" self.expected_chips = 66 self.fan_count = 2 @@ -203,7 +203,7 @@ class M31SPlusVG30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ VG30" + self.raw_model = "M31S+ VG30" self.expected_chips = 70 self.fan_count = 2 @@ -212,7 +212,7 @@ class M31SPlusV30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ V30" + self.raw_model = "M31S+ V30" self.expected_chips = 117 self.fan_count = 2 @@ -221,6 +221,6 @@ class M31SPlusV40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M31S+ V40" + self.raw_model = "M31S+ V40" self.expected_chips = 123 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M3X/M32.py b/pyasic/miners/types/whatsminer/M3X/M32.py index 67cb86fd..15d066d3 100644 --- a/pyasic/miners/types/whatsminer/M3X/M32.py +++ b/pyasic/miners/types/whatsminer/M3X/M32.py @@ -23,7 +23,7 @@ class M32V10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M32 V10" + self.raw_model = "M32 V10" self.expected_chips = 78 self.fan_count = 2 @@ -32,6 +32,6 @@ class M32V20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M32 V20" + self.raw_model = "M32 V20" self.expected_chips = 74 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M3X/M32S.py b/pyasic/miners/types/whatsminer/M3X/M32S.py index 2421cda3..9d0705ab 100644 --- a/pyasic/miners/types/whatsminer/M3X/M32S.py +++ b/pyasic/miners/types/whatsminer/M3X/M32S.py @@ -21,6 +21,6 @@ class M32S(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M32S" + self.raw_model = "M32S" self.expected_chips = 78 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M3X/M33.py b/pyasic/miners/types/whatsminer/M3X/M33.py index 92d7f270..373a79a8 100644 --- a/pyasic/miners/types/whatsminer/M3X/M33.py +++ b/pyasic/miners/types/whatsminer/M3X/M33.py @@ -23,7 +23,7 @@ class M33V10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M33 V10" + self.raw_model = "M33 V10" self.expected_chips = 33 self.fan_count = 0 @@ -32,7 +32,7 @@ class M33V20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M33 V20" + self.raw_model = "M33 V20" self.expected_chips = 62 self.fan_count = 0 @@ -41,6 +41,6 @@ class M33V30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M33 V30" + self.raw_model = "M33 V30" self.expected_chips = 66 self.fan_count = 0 diff --git a/pyasic/miners/types/whatsminer/M3X/M33S.py b/pyasic/miners/types/whatsminer/M3X/M33S.py index 5337ff53..98390fc3 100644 --- a/pyasic/miners/types/whatsminer/M3X/M33S.py +++ b/pyasic/miners/types/whatsminer/M3X/M33S.py @@ -23,7 +23,7 @@ class M33SVG30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M33S VG30" + self.raw_model = "M33S VG30" self.expected_hashboards = 4 self.expected_chips = 116 self.fan_count = 0 diff --git a/pyasic/miners/types/whatsminer/M3X/M33S_Plus.py b/pyasic/miners/types/whatsminer/M3X/M33S_Plus.py index e5883eb8..99f7a85f 100644 --- a/pyasic/miners/types/whatsminer/M3X/M33S_Plus.py +++ b/pyasic/miners/types/whatsminer/M3X/M33S_Plus.py @@ -23,7 +23,7 @@ class M33SPlusVG20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M33S+ VG20" + self.raw_model = "M33S+ VG20" self.expected_hashboards = 4 self.expected_chips = 112 self.fan_count = 0 @@ -33,7 +33,7 @@ class M33SPlusVH20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M33S+ VH20" + self.raw_model = "M33S+ VH20" self.expected_hashboards = 4 self.expected_chips = 100 self.fan_count = 0 @@ -43,7 +43,7 @@ class M33SPlusVH30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M33S+ VH30" + self.raw_model = "M33S+ VH30" self.expected_hashboards = 4 self.expected_chips = 0 # slot1 116, slot2 106, slot3 116, slot4 106 warnings.warn( diff --git a/pyasic/miners/types/whatsminer/M3X/M33S_Plus_Plus.py b/pyasic/miners/types/whatsminer/M3X/M33S_Plus_Plus.py index 84dcfc32..2af0f58b 100644 --- a/pyasic/miners/types/whatsminer/M3X/M33S_Plus_Plus.py +++ b/pyasic/miners/types/whatsminer/M3X/M33S_Plus_Plus.py @@ -23,7 +23,7 @@ class M33SPlusPlusVH20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M33S++ VH20" + self.raw_model = "M33S++ VH20" self.expected_hashboards = 4 self.expected_chips = 112 self.fan_count = 0 @@ -33,7 +33,7 @@ class M33SPlusPlusVH30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M33S++ VH30" + self.raw_model = "M33S++ VH30" self.expected_hashboards = 4 self.expected_chips = 0 warnings.warn( @@ -46,7 +46,7 @@ class M33SPlusPlusVG40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M33S++ VG40" + self.raw_model = "M33S++ VG40" self.expected_hashboards = 4 self.expected_chips = 174 self.fan_count = 0 diff --git a/pyasic/miners/types/whatsminer/M3X/M34S_Plus.py b/pyasic/miners/types/whatsminer/M3X/M34S_Plus.py index 2b29ffa1..97bdf1d6 100644 --- a/pyasic/miners/types/whatsminer/M3X/M34S_Plus.py +++ b/pyasic/miners/types/whatsminer/M3X/M34S_Plus.py @@ -21,7 +21,7 @@ class M34SPlusVE10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M34S+ VE10" + self.raw_model = "M34S+ VE10" self.expected_hashboards = 4 self.expected_chips = 116 self.fan_count = 0 diff --git a/pyasic/miners/types/whatsminer/M3X/M36S.py b/pyasic/miners/types/whatsminer/M3X/M36S.py index 2e15d0fd..b100851b 100644 --- a/pyasic/miners/types/whatsminer/M3X/M36S.py +++ b/pyasic/miners/types/whatsminer/M3X/M36S.py @@ -23,7 +23,7 @@ class M36SVE10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M36S VE10" + self.raw_model = "M36S VE10" self.expected_hashboards = 4 self.expected_chips = 114 self.fan_count = 0 diff --git a/pyasic/miners/types/whatsminer/M3X/M36S_Plus.py b/pyasic/miners/types/whatsminer/M3X/M36S_Plus.py index a6fa8ed0..a1dc8826 100644 --- a/pyasic/miners/types/whatsminer/M3X/M36S_Plus.py +++ b/pyasic/miners/types/whatsminer/M3X/M36S_Plus.py @@ -23,7 +23,7 @@ class M36SPlusVG30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M36S+ VG30" + self.raw_model = "M36S+ VG30" self.expected_hashboards = 4 self.expected_chips = 108 self.fan_count = 0 diff --git a/pyasic/miners/types/whatsminer/M3X/M36S_Plus_Plus.py b/pyasic/miners/types/whatsminer/M3X/M36S_Plus_Plus.py index dd04ca83..6ce8dae9 100644 --- a/pyasic/miners/types/whatsminer/M3X/M36S_Plus_Plus.py +++ b/pyasic/miners/types/whatsminer/M3X/M36S_Plus_Plus.py @@ -23,7 +23,7 @@ class M36SPlusPlusVH30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M36S++ VH30" + self.raw_model = "M36S++ VH30" self.expected_hashboards = 4 self.expected_chips = 80 self.fan_count = 0 diff --git a/pyasic/miners/types/whatsminer/M3X/M39.py b/pyasic/miners/types/whatsminer/M3X/M39.py index a6cfae42..6f8b24e1 100644 --- a/pyasic/miners/types/whatsminer/M3X/M39.py +++ b/pyasic/miners/types/whatsminer/M3X/M39.py @@ -23,7 +23,7 @@ class M39V10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M39 V10" + self.raw_model = "M39 V10" self.expected_chips = 50 self.fan_count = 0 @@ -32,7 +32,7 @@ class M39V20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M39 V20" + self.raw_model = "M39 V20" self.expected_chips = 54 self.fan_count = 0 @@ -41,6 +41,6 @@ class M39V30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M39 V30" + self.raw_model = "M39 V30" self.expected_chips = 68 self.fan_count = 0 diff --git a/pyasic/miners/types/whatsminer/M5X/M50.py b/pyasic/miners/types/whatsminer/M5X/M50.py index cac9bb33..76166549 100644 --- a/pyasic/miners/types/whatsminer/M5X/M50.py +++ b/pyasic/miners/types/whatsminer/M5X/M50.py @@ -23,7 +23,7 @@ class M50VE30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50 VE30" + self.raw_model = "M50 VE30" self.expected_hashboards = 4 self.expected_chips = 255 self.fan_count = 2 @@ -33,7 +33,7 @@ class M50VG30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50 VG30" + self.raw_model = "M50 VG30" self.expected_chips = 156 self.fan_count = 2 @@ -42,7 +42,7 @@ class M50VH10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50 VH10" + self.raw_model = "M50 VH10" self.expected_chips = 86 self.fan_count = 2 @@ -51,7 +51,7 @@ class M50VH20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50 VH20" + self.raw_model = "M50 VH20" self.expected_chips = 111 self.fan_count = 2 @@ -60,7 +60,7 @@ class M50VH30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50 VH30" + self.raw_model = "M50 VH30" self.expected_chips = 117 self.fan_count = 2 @@ -69,7 +69,7 @@ class M50VH40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50 VH40" + self.raw_model = "M50 VH40" self.expected_chips = 84 self.fan_count = 2 @@ -78,7 +78,7 @@ class M50VH50(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50 VH50" + self.raw_model = "M50 VH50" self.expected_chips = 105 self.fan_count = 2 @@ -87,7 +87,7 @@ class M50VH60(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50 VH60" + self.raw_model = "M50 VH60" self.expected_chips = 84 self.fan_count = 2 @@ -96,7 +96,7 @@ class M50VH70(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50 VH70" + self.raw_model = "M50 VH70" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M50 VH70, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -108,7 +108,7 @@ class M50VH80(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50 VH80" + self.raw_model = "M50 VH80" self.expected_chips = 111 self.fan_count = 2 @@ -117,7 +117,7 @@ class M50VJ10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50 VJ10" + self.raw_model = "M50 VJ10" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M50 VJ10, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -129,7 +129,7 @@ class M50VJ20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50 VJ20" + self.raw_model = "M50 VJ20" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M50 VJ20, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -141,7 +141,7 @@ class M50VJ30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50 VJ30" + self.raw_model = "M50 VJ30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M50 VJ30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." diff --git a/pyasic/miners/types/whatsminer/M5X/M50S.py b/pyasic/miners/types/whatsminer/M5X/M50S.py index bbf5f732..370fb9dd 100644 --- a/pyasic/miners/types/whatsminer/M5X/M50S.py +++ b/pyasic/miners/types/whatsminer/M5X/M50S.py @@ -23,7 +23,7 @@ class M50SVJ10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50S VJ10" + self.raw_model = "M50S VJ10" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M50S VJ10, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -35,7 +35,7 @@ class M50SVJ20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50S VJ20" + self.raw_model = "M50S VJ20" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M50S VJ20, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -47,7 +47,7 @@ class M50SVJ30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50S VJ30" + self.raw_model = "M50S VJ30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M50S VJ30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -59,7 +59,7 @@ class M50SVH10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50S VH10" + self.raw_model = "M50S VH10" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M50S VH10, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -71,7 +71,7 @@ class M50SVH20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50S VH20" + self.raw_model = "M50S VH20" self.expected_chips = 135 self.fan_count = 2 @@ -80,7 +80,7 @@ class M50SVH30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50S VH30" + self.raw_model = "M50S VH30" self.expected_chips = 156 self.fan_count = 2 @@ -89,7 +89,7 @@ class M50SVH40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50S VH40" + self.raw_model = "M50S VH40" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M50S VH40, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -101,7 +101,7 @@ class M50SVH50(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50S VH50" + self.raw_model = "M50S VH50" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M50S VH50, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." diff --git a/pyasic/miners/types/whatsminer/M5X/M50S_Plus.py b/pyasic/miners/types/whatsminer/M5X/M50S_Plus.py index 03ab6316..54479080 100644 --- a/pyasic/miners/types/whatsminer/M5X/M50S_Plus.py +++ b/pyasic/miners/types/whatsminer/M5X/M50S_Plus.py @@ -23,7 +23,7 @@ class M50SPlusVH30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50S+ VH30" + self.raw_model = "M50S+ VH30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M50S+ VH30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -35,7 +35,7 @@ class M50SPlusVH40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50S+ VH40" + self.raw_model = "M50S+ VH40" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M50S+ VH40, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -47,7 +47,7 @@ class M50SPlusVJ30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50S+ VJ30" + self.raw_model = "M50S+ VJ30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M50S+ VJ30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -59,6 +59,6 @@ class M50SPlusVK20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50S+ VK20" + self.raw_model = "M50S+ VK20" self.expected_chips = 117 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M5X/M50S_Plus_Plus.py b/pyasic/miners/types/whatsminer/M5X/M50S_Plus_Plus.py index 10b93b64..ba5ae6c5 100644 --- a/pyasic/miners/types/whatsminer/M5X/M50S_Plus_Plus.py +++ b/pyasic/miners/types/whatsminer/M5X/M50S_Plus_Plus.py @@ -23,7 +23,7 @@ class M50SPlusPlusVK10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50S++ VK10" + self.raw_model = "M50S++ VK10" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M50S+ VK10, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -35,7 +35,7 @@ class M50SPlusPlusVK20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50S++ VK20" + self.raw_model = "M50S++ VK20" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M50S+ VK20, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -47,6 +47,6 @@ class M50SPlusPlusVK30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M50S++ VK30" + self.raw_model = "M50S++ VK30" self.expected_chips = 76 self.fan_count = 2 diff --git a/pyasic/miners/types/whatsminer/M5X/M53.py b/pyasic/miners/types/whatsminer/M5X/M53.py index e385141a..9e85eccc 100644 --- a/pyasic/miners/types/whatsminer/M5X/M53.py +++ b/pyasic/miners/types/whatsminer/M5X/M53.py @@ -23,7 +23,7 @@ class M53VH30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M53 VH30" + self.raw_model = "M53 VH30" self.expected_hashboards = 4 self.expected_chips = 128 self.fan_count = 0 diff --git a/pyasic/miners/types/whatsminer/M5X/M53S.py b/pyasic/miners/types/whatsminer/M5X/M53S.py index 34156587..61eca632 100644 --- a/pyasic/miners/types/whatsminer/M5X/M53S.py +++ b/pyasic/miners/types/whatsminer/M5X/M53S.py @@ -23,7 +23,7 @@ class M53SVH30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M53S VH30" + self.raw_model = "M53S VH30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M53S VH30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." diff --git a/pyasic/miners/types/whatsminer/M5X/M53S_Plus.py b/pyasic/miners/types/whatsminer/M5X/M53S_Plus.py index 2cead1f2..a48b697d 100644 --- a/pyasic/miners/types/whatsminer/M5X/M53S_Plus.py +++ b/pyasic/miners/types/whatsminer/M5X/M53S_Plus.py @@ -23,7 +23,7 @@ class M53SPlusVJ30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M53S+ VJ30" + self.raw_model = "M53S+ VJ30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M53S+ VJ30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." diff --git a/pyasic/miners/types/whatsminer/M5X/M56.py b/pyasic/miners/types/whatsminer/M5X/M56.py index 1c0980cb..29326152 100644 --- a/pyasic/miners/types/whatsminer/M5X/M56.py +++ b/pyasic/miners/types/whatsminer/M5X/M56.py @@ -23,7 +23,7 @@ class M56VH30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M56 VH30" + self.raw_model = "M56 VH30" self.expected_hashboards = 4 self.expected_chips = 108 self.fan_count = 0 diff --git a/pyasic/miners/types/whatsminer/M5X/M56S.py b/pyasic/miners/types/whatsminer/M5X/M56S.py index b6c5ef78..87ea2f46 100644 --- a/pyasic/miners/types/whatsminer/M5X/M56S.py +++ b/pyasic/miners/types/whatsminer/M5X/M56S.py @@ -23,7 +23,7 @@ class M56SVH30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M56S VH30" + self.raw_model = "M56S VH30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M56S VH30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." diff --git a/pyasic/miners/types/whatsminer/M5X/M56S_Plus.py b/pyasic/miners/types/whatsminer/M5X/M56S_Plus.py index 0bbeacd9..3addcf4d 100644 --- a/pyasic/miners/types/whatsminer/M5X/M56S_Plus.py +++ b/pyasic/miners/types/whatsminer/M5X/M56S_Plus.py @@ -23,7 +23,7 @@ class M56SPlusVJ30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M56S+ VJ30" + self.raw_model = "M56S+ VJ30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M56S+ VJ30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." diff --git a/pyasic/miners/types/whatsminer/M5X/M59.py b/pyasic/miners/types/whatsminer/M5X/M59.py index b33e03cf..5333dd79 100644 --- a/pyasic/miners/types/whatsminer/M5X/M59.py +++ b/pyasic/miners/types/whatsminer/M5X/M59.py @@ -23,7 +23,7 @@ class M59VH30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M59 VH30" + self.raw_model = "M59 VH30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M59 VH30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." diff --git a/pyasic/miners/types/whatsminer/M6X/M60.py b/pyasic/miners/types/whatsminer/M6X/M60.py index 652c1c15..635d42ae 100644 --- a/pyasic/miners/types/whatsminer/M6X/M60.py +++ b/pyasic/miners/types/whatsminer/M6X/M60.py @@ -23,7 +23,7 @@ class M60VK10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M60 VK10" + self.raw_model = "M60 VK10" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M60 VK10, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -35,7 +35,7 @@ class M60VK20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M60 VK20" + self.raw_model = "M60 VK20" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M60 VK20, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -47,7 +47,7 @@ class M60VK30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M60 VK30" + self.raw_model = "M60 VK30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M60 VK30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -59,7 +59,7 @@ class M60VK40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M60 VK40" + self.raw_model = "M60 VK40" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M60 VK40, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." diff --git a/pyasic/miners/types/whatsminer/M6X/M60S.py b/pyasic/miners/types/whatsminer/M6X/M60S.py index 8f735838..a349cd7f 100644 --- a/pyasic/miners/types/whatsminer/M6X/M60S.py +++ b/pyasic/miners/types/whatsminer/M6X/M60S.py @@ -23,7 +23,7 @@ class M60SVK10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M60S VK10" + self.raw_model = "M60S VK10" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M60S VK10, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -35,7 +35,7 @@ class M60SVK20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M60S VK20" + self.raw_model = "M60S VK20" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M60S VK20, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -47,7 +47,7 @@ class M60SVK30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M60S VK30" + self.raw_model = "M60S VK30" self.expected_hashboards = 3 self.expected_chips = 78 self.fan_count = 2 @@ -57,7 +57,7 @@ class M60SVK40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M60S VK40" + self.raw_model = "M60S VK40" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M60S VK40, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." diff --git a/pyasic/miners/types/whatsminer/M6X/M63.py b/pyasic/miners/types/whatsminer/M6X/M63.py index b1075dd1..939b229d 100644 --- a/pyasic/miners/types/whatsminer/M6X/M63.py +++ b/pyasic/miners/types/whatsminer/M6X/M63.py @@ -23,7 +23,7 @@ class M63VK10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M63 VK10" + self.raw_model = "M63 VK10" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M63 VK10, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -35,7 +35,7 @@ class M63VK20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M63 VK20" + self.raw_model = "M63 VK20" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M63 VK20, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -47,7 +47,7 @@ class M63VK30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M63 VK30" + self.raw_model = "M63 VK30" self.expected_chips = 68 self.expected_hashboards = 4 self.fan_count = 0 diff --git a/pyasic/miners/types/whatsminer/M6X/M63S.py b/pyasic/miners/types/whatsminer/M6X/M63S.py index 90c20291..06abf024 100644 --- a/pyasic/miners/types/whatsminer/M6X/M63S.py +++ b/pyasic/miners/types/whatsminer/M6X/M63S.py @@ -23,7 +23,7 @@ class M63SVK10(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M63S VK10" + self.raw_model = "M63S VK10" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M63S VK10, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -35,7 +35,7 @@ class M63SVK20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M63S VK20" + self.raw_model = "M63S VK20" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M63S VK20, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -47,7 +47,7 @@ class M63SVK30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M63S VK30" + self.raw_model = "M63S VK30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M63S VK30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." diff --git a/pyasic/miners/types/whatsminer/M6X/M66.py b/pyasic/miners/types/whatsminer/M6X/M66.py index c006aa06..f13dd83d 100644 --- a/pyasic/miners/types/whatsminer/M6X/M66.py +++ b/pyasic/miners/types/whatsminer/M6X/M66.py @@ -23,7 +23,7 @@ class M66VK20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M66 VK20" + self.raw_model = "M66 VK20" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M66 VK20, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -35,7 +35,7 @@ class M66VK30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M66 VK30" + self.raw_model = "M66 VK30" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M66 VK30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." diff --git a/pyasic/miners/types/whatsminer/M6X/M66S.py b/pyasic/miners/types/whatsminer/M6X/M66S.py index 70137a95..05b05ba2 100644 --- a/pyasic/miners/types/whatsminer/M6X/M66S.py +++ b/pyasic/miners/types/whatsminer/M6X/M66S.py @@ -23,7 +23,7 @@ class M66SVK20(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M66S VK20" + self.raw_model = "M66S VK20" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M66S VK20, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." @@ -35,7 +35,7 @@ class M66SVK30(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M66S VK30" + self.raw_model = "M66S VK30" self.expected_chips = 96 self.expected_hashboards = 4 self.fan_count = 0 @@ -45,7 +45,7 @@ class M66SVK40(WhatsMiner): # noqa - ignore ABC method implementation def __init__(self, ip: str, api_ver: str = "0.0.0"): super().__init__(ip, api_ver) self.ip = ip - self.model = "M66S VK40" + self.raw_model = "M66S VK40" self.expected_chips = 0 warnings.warn( "Unknown chip count for miner type M66 VK30, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." diff --git a/tests/miners_tests/__init__.py b/tests/miners_tests/__init__.py index 1247fc7d..1f77c638 100644 --- a/tests/miners_tests/__init__.py +++ b/tests/miners_tests/__init__.py @@ -56,7 +56,6 @@ class MinersTest(unittest.TestCase): "hostname", "is_mining", "mac", - "model", "expected_hashrate", "uptime", "wattage", From c80ca1415ab9fb553aa1ed81fc361a1a77e2f3e6 Mon Sep 17 00:00:00 2001 From: snyk-bot Date: Thu, 11 Jan 2024 16:00:03 +0000 Subject: [PATCH 02/14] fix: docs/requirements.txt to reduce vulnerabilities The following vulnerabilities are fixed by pinning transitive dependencies: - https://snyk.io/vuln/SNYK-PYTHON-JINJA2-6150717 --- docs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 464409ee..f27379a8 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,3 +1,3 @@ -jinja2<3.1.0 +jinja2<3.1.3 mkdocs mkdocstrings[python] From 4156f93c0db92fc09bbe66c19e19339c69b88e47 Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Thu, 11 Jan 2024 15:00:48 -0700 Subject: [PATCH 03/14] refactor: optimize imports. --- pyasic/miners/backends/bfgminer.py | 3 +-- pyasic/miners/backends/bmminer.py | 3 +-- pyasic/miners/backends/btminer.py | 4 +--- pyasic/miners/backends/cgminer.py | 3 +-- pyasic/miners/backends/cgminer_avalon.py | 1 - pyasic/miners/backends/epic.py | 5 ++--- pyasic/miners/backends/hiveon.py | 2 -- pyasic/miners/backends/luxminer.py | 10 +--------- pyasic/miners/innosilicon/cgminer/T3X/T3H.py | 1 - pyasic/miners/types/avalonminer/A11X/A1166.py | 1 - pyasic/miners/types/avalonminer/A12X/A1246.py | 1 - pyasic/miners/types/whatsminer/M2X/M20S.py | 2 -- pyasic/miners/types/whatsminer/M2X/M21.py | 2 -- pyasic/miners/types/whatsminer/M2X/M21S.py | 2 -- pyasic/miners/types/whatsminer/M2X/M29.py | 2 -- pyasic/miners/types/whatsminer/M3X/M30.py | 2 -- pyasic/miners/types/whatsminer/M3X/M30K.py | 2 -- pyasic/miners/types/whatsminer/M3X/M30L.py | 2 -- pyasic/miners/types/whatsminer/M3X/M31.py | 2 -- pyasic/miners/types/whatsminer/M3X/M31H.py | 2 -- pyasic/miners/types/whatsminer/M3X/M31L.py | 2 -- pyasic/miners/types/whatsminer/M3X/M31SE.py | 2 -- pyasic/miners/types/whatsminer/M3X/M32.py | 2 -- pyasic/miners/types/whatsminer/M3X/M33.py | 2 -- pyasic/miners/types/whatsminer/M3X/M33S.py | 2 -- pyasic/miners/types/whatsminer/M3X/M36S.py | 2 -- pyasic/miners/types/whatsminer/M3X/M36S_Plus.py | 2 -- pyasic/miners/types/whatsminer/M3X/M36S_Plus_Plus.py | 2 -- pyasic/miners/types/whatsminer/M3X/M39.py | 2 -- pyasic/miners/types/whatsminer/M5X/M53.py | 2 -- pyasic/miners/types/whatsminer/M5X/M56.py | 2 -- pyasic/miners/unknown.py | 1 - pyasic/web/__init__.py | 1 - pyasic/web/epic.py | 3 +-- tests/miners_tests/__init__.py | 6 +----- 35 files changed, 9 insertions(+), 76 deletions(-) diff --git a/pyasic/miners/backends/bfgminer.py b/pyasic/miners/backends/bfgminer.py index 71d36d46..78fdb5e4 100644 --- a/pyasic/miners/backends/bfgminer.py +++ b/pyasic/miners/backends/bfgminer.py @@ -14,8 +14,7 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -from collections import namedtuple -from typing import List, Optional, Tuple +from typing import List, Optional from pyasic.API.bfgminer import BFGMinerAPI from pyasic.config import MinerConfig diff --git a/pyasic/miners/backends/bmminer.py b/pyasic/miners/backends/bmminer.py index a1b32f7e..92b84851 100644 --- a/pyasic/miners/backends/bmminer.py +++ b/pyasic/miners/backends/bmminer.py @@ -15,8 +15,7 @@ # ------------------------------------------------------------------------------ import logging -from collections import namedtuple -from typing import List, Optional, Tuple +from typing import List, Optional from pyasic.API.bmminer import BMMinerAPI from pyasic.config import MinerConfig diff --git a/pyasic/miners/backends/btminer.py b/pyasic/miners/backends/btminer.py index 68f3a966..4e75071d 100644 --- a/pyasic/miners/backends/btminer.py +++ b/pyasic/miners/backends/btminer.py @@ -15,8 +15,7 @@ # ------------------------------------------------------------------------------ import logging -from collections import namedtuple -from typing import List, Optional, Tuple +from typing import List, Optional from pyasic.API.btminer import BTMinerAPI from pyasic.config import MinerConfig, MiningModeConfig @@ -29,7 +28,6 @@ from pyasic.miners.base import ( DataLocations, DataOptions, RPCAPICommand, - WebAPICommand, ) BTMINER_DATA_LOC = DataLocations( diff --git a/pyasic/miners/backends/cgminer.py b/pyasic/miners/backends/cgminer.py index 927ed852..f44829bc 100644 --- a/pyasic/miners/backends/cgminer.py +++ b/pyasic/miners/backends/cgminer.py @@ -15,8 +15,7 @@ # ------------------------------------------------------------------------------ import logging -from collections import namedtuple -from typing import List, Optional, Tuple +from typing import List, Optional from pyasic.API.cgminer import CGMinerAPI from pyasic.config import MinerConfig diff --git a/pyasic/miners/backends/cgminer_avalon.py b/pyasic/miners/backends/cgminer_avalon.py index ebc7b716..23bae3f0 100644 --- a/pyasic/miners/backends/cgminer_avalon.py +++ b/pyasic/miners/backends/cgminer_avalon.py @@ -14,7 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import logging import re from typing import List, Optional diff --git a/pyasic/miners/backends/epic.py b/pyasic/miners/backends/epic.py index 0914d0f8..83452263 100644 --- a/pyasic/miners/backends/epic.py +++ b/pyasic/miners/backends/epic.py @@ -14,10 +14,9 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -from typing import List, Optional, Tuple +from typing import List, Optional -from pyasic import MinerConfig -from pyasic.config import MinerConfig, MiningModeConfig +from pyasic.config import MinerConfig from pyasic.data import Fan, HashBoard from pyasic.data.error_codes import MinerErrorData, X19Error from pyasic.errors import APIError diff --git a/pyasic/miners/backends/hiveon.py b/pyasic/miners/backends/hiveon.py index 3b99bcf6..1ce6c12b 100644 --- a/pyasic/miners/backends/hiveon.py +++ b/pyasic/miners/backends/hiveon.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -from typing import Optional - from pyasic.miners.backends import BMMiner diff --git a/pyasic/miners/backends/luxminer.py b/pyasic/miners/backends/luxminer.py index 5f0b0863..b22260b9 100644 --- a/pyasic/miners/backends/luxminer.py +++ b/pyasic/miners/backends/luxminer.py @@ -13,18 +13,12 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ -import asyncio -import logging -from collections import namedtuple from typing import List, Optional, Tuple, Union -import toml - -from pyasic.API.bosminer import BOSMinerAPI from pyasic.API.luxminer import LUXMinerAPI from pyasic.config import MinerConfig from pyasic.data import Fan, HashBoard -from pyasic.data.error_codes import BraiinsOSError, MinerErrorData +from pyasic.data.error_codes import MinerErrorData from pyasic.errors import APIError from pyasic.miners.base import ( BaseMiner, @@ -32,9 +26,7 @@ from pyasic.miners.base import ( DataLocations, DataOptions, RPCAPICommand, - WebAPICommand, ) -from pyasic.web.bosminer import BOSMinerWebAPI LUXMINER_DATA_LOC = DataLocations( **{ diff --git a/pyasic/miners/innosilicon/cgminer/T3X/T3H.py b/pyasic/miners/innosilicon/cgminer/T3X/T3H.py index 321c151a..ccb5c275 100644 --- a/pyasic/miners/innosilicon/cgminer/T3X/T3H.py +++ b/pyasic/miners/innosilicon/cgminer/T3X/T3H.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ -import logging from typing import List, Optional from pyasic.config import MinerConfig diff --git a/pyasic/miners/types/avalonminer/A11X/A1166.py b/pyasic/miners/types/avalonminer/A11X/A1166.py index e26136f7..685a0f53 100644 --- a/pyasic/miners/types/avalonminer/A11X/A1166.py +++ b/pyasic/miners/types/avalonminer/A11X/A1166.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings from pyasic.miners.makes import AvalonMiner diff --git a/pyasic/miners/types/avalonminer/A12X/A1246.py b/pyasic/miners/types/avalonminer/A12X/A1246.py index 98b3dd1a..b066a02b 100644 --- a/pyasic/miners/types/avalonminer/A12X/A1246.py +++ b/pyasic/miners/types/avalonminer/A12X/A1246.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings from pyasic.miners.makes import AvalonMiner diff --git a/pyasic/miners/types/whatsminer/M2X/M20S.py b/pyasic/miners/types/whatsminer/M2X/M20S.py index ccfa4d80..cbefb29d 100644 --- a/pyasic/miners/types/whatsminer/M2X/M20S.py +++ b/pyasic/miners/types/whatsminer/M2X/M20S.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M2X/M21.py b/pyasic/miners/types/whatsminer/M2X/M21.py index 1a2f811c..5b274895 100644 --- a/pyasic/miners/types/whatsminer/M2X/M21.py +++ b/pyasic/miners/types/whatsminer/M2X/M21.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M2X/M21S.py b/pyasic/miners/types/whatsminer/M2X/M21S.py index dd224341..7c63a150 100644 --- a/pyasic/miners/types/whatsminer/M2X/M21S.py +++ b/pyasic/miners/types/whatsminer/M2X/M21S.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M2X/M29.py b/pyasic/miners/types/whatsminer/M2X/M29.py index e3cd9d34..1d31fcfe 100644 --- a/pyasic/miners/types/whatsminer/M2X/M29.py +++ b/pyasic/miners/types/whatsminer/M2X/M29.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M30.py b/pyasic/miners/types/whatsminer/M3X/M30.py index 4e1aaf0d..a2ea42a6 100644 --- a/pyasic/miners/types/whatsminer/M3X/M30.py +++ b/pyasic/miners/types/whatsminer/M3X/M30.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M30K.py b/pyasic/miners/types/whatsminer/M3X/M30K.py index b951c10b..3177ef08 100644 --- a/pyasic/miners/types/whatsminer/M3X/M30K.py +++ b/pyasic/miners/types/whatsminer/M3X/M30K.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M30L.py b/pyasic/miners/types/whatsminer/M3X/M30L.py index 191b5e60..743ccc69 100644 --- a/pyasic/miners/types/whatsminer/M3X/M30L.py +++ b/pyasic/miners/types/whatsminer/M3X/M30L.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M31.py b/pyasic/miners/types/whatsminer/M3X/M31.py index 0e5b7003..405d64aa 100644 --- a/pyasic/miners/types/whatsminer/M3X/M31.py +++ b/pyasic/miners/types/whatsminer/M3X/M31.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M31H.py b/pyasic/miners/types/whatsminer/M3X/M31H.py index 64612a1b..f86e3467 100644 --- a/pyasic/miners/types/whatsminer/M3X/M31H.py +++ b/pyasic/miners/types/whatsminer/M3X/M31H.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M31L.py b/pyasic/miners/types/whatsminer/M3X/M31L.py index 7b30e980..8981b94e 100644 --- a/pyasic/miners/types/whatsminer/M3X/M31L.py +++ b/pyasic/miners/types/whatsminer/M3X/M31L.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M31SE.py b/pyasic/miners/types/whatsminer/M3X/M31SE.py index 5f6aff90..d8207ab6 100644 --- a/pyasic/miners/types/whatsminer/M3X/M31SE.py +++ b/pyasic/miners/types/whatsminer/M3X/M31SE.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M32.py b/pyasic/miners/types/whatsminer/M3X/M32.py index 15d066d3..01bc0078 100644 --- a/pyasic/miners/types/whatsminer/M3X/M32.py +++ b/pyasic/miners/types/whatsminer/M3X/M32.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M33.py b/pyasic/miners/types/whatsminer/M3X/M33.py index 373a79a8..c8955ea6 100644 --- a/pyasic/miners/types/whatsminer/M3X/M33.py +++ b/pyasic/miners/types/whatsminer/M3X/M33.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M33S.py b/pyasic/miners/types/whatsminer/M3X/M33S.py index 98390fc3..65d846ee 100644 --- a/pyasic/miners/types/whatsminer/M3X/M33S.py +++ b/pyasic/miners/types/whatsminer/M3X/M33S.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M36S.py b/pyasic/miners/types/whatsminer/M3X/M36S.py index b100851b..2bc177dc 100644 --- a/pyasic/miners/types/whatsminer/M3X/M36S.py +++ b/pyasic/miners/types/whatsminer/M3X/M36S.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M36S_Plus.py b/pyasic/miners/types/whatsminer/M3X/M36S_Plus.py index a1dc8826..27d169d2 100644 --- a/pyasic/miners/types/whatsminer/M3X/M36S_Plus.py +++ b/pyasic/miners/types/whatsminer/M3X/M36S_Plus.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M36S_Plus_Plus.py b/pyasic/miners/types/whatsminer/M3X/M36S_Plus_Plus.py index 6ce8dae9..e7e54d0c 100644 --- a/pyasic/miners/types/whatsminer/M3X/M36S_Plus_Plus.py +++ b/pyasic/miners/types/whatsminer/M3X/M36S_Plus_Plus.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M39.py b/pyasic/miners/types/whatsminer/M3X/M39.py index 6f8b24e1..ebefbc56 100644 --- a/pyasic/miners/types/whatsminer/M3X/M39.py +++ b/pyasic/miners/types/whatsminer/M3X/M39.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M5X/M53.py b/pyasic/miners/types/whatsminer/M5X/M53.py index 9e85eccc..d65c6500 100644 --- a/pyasic/miners/types/whatsminer/M5X/M53.py +++ b/pyasic/miners/types/whatsminer/M5X/M53.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M5X/M56.py b/pyasic/miners/types/whatsminer/M5X/M56.py index 29326152..3d4e07b4 100644 --- a/pyasic/miners/types/whatsminer/M5X/M56.py +++ b/pyasic/miners/types/whatsminer/M5X/M56.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/unknown.py b/pyasic/miners/unknown.py index c1b1cf97..ddffdc2c 100644 --- a/pyasic/miners/unknown.py +++ b/pyasic/miners/unknown.py @@ -20,7 +20,6 @@ from pyasic.API.unknown import UnknownAPI from pyasic.config import MinerConfig from pyasic.data import Fan, HashBoard, MinerData from pyasic.data.error_codes import MinerErrorData -from pyasic.errors import APIError from pyasic.miners.base import BaseMiner diff --git a/pyasic/web/__init__.py b/pyasic/web/__init__.py index c31c2e9b..72774619 100644 --- a/pyasic/web/__init__.py +++ b/pyasic/web/__init__.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ -import ipaddress import warnings from abc import ABC, abstractmethod from typing import Union diff --git a/pyasic/web/epic.py b/pyasic/web/epic.py index 2784edee..6482bdc5 100644 --- a/pyasic/web/epic.py +++ b/pyasic/web/epic.py @@ -14,13 +14,12 @@ # limitations under the License. - # ------------------------------------------------------------------------------ import json -import warnings from typing import Union import httpx from pyasic import settings -from pyasic.errors import APIError, APIWarning +from pyasic.errors import APIError from pyasic.web import BaseWebAPI diff --git a/tests/miners_tests/__init__.py b/tests/miners_tests/__init__.py index 1f77c638..82d8a246 100644 --- a/tests/miners_tests/__init__.py +++ b/tests/miners_tests/__init__.py @@ -13,16 +13,12 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ -import asyncio -import inspect -import sys import unittest import warnings from dataclasses import asdict from pyasic.miners.backends import CGMiner # noqa -from pyasic.miners.base import BaseMiner -from pyasic.miners.miner_factory import MINER_CLASSES, MinerFactory +from pyasic.miners.miner_factory import MINER_CLASSES class MinersTest(unittest.TestCase): From a094d28a36336798796eefba8e8ef65f81ef43c1 Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Thu, 11 Jan 2024 15:20:33 -0700 Subject: [PATCH 04/14] refactor: swap (KeyError, IndexError) for LookupError. --- pyasic/miners/antminer/hiveon/X9/T9.py | 8 +++--- pyasic/miners/backends/antminer.py | 8 +++--- pyasic/miners/backends/bfgminer.py | 12 ++++---- pyasic/miners/backends/bmminer.py | 10 +++---- pyasic/miners/backends/bosminer.py | 28 +++++++++---------- pyasic/miners/backends/btminer.py | 22 +++++++-------- pyasic/miners/backends/cgminer.py | 12 ++++---- pyasic/miners/backends/cgminer_avalon.py | 14 +++++----- pyasic/miners/backends/epic.py | 2 +- pyasic/miners/backends/luxminer.py | 12 ++++---- pyasic/miners/backends/vnish.py | 2 +- .../miners/innosilicon/cgminer/A10X/A10X.py | 4 +-- pyasic/miners/innosilicon/cgminer/T3X/T3H.py | 2 +- 13 files changed, 68 insertions(+), 68 deletions(-) diff --git a/pyasic/miners/antminer/hiveon/X9/T9.py b/pyasic/miners/antminer/hiveon/X9/T9.py index 33e4e77d..691d150c 100644 --- a/pyasic/miners/antminer/hiveon/X9/T9.py +++ b/pyasic/miners/antminer/hiveon/X9/T9.py @@ -62,14 +62,14 @@ class HiveonT9(Hiveon, T9): try: hashboard.board_temp = api_stats["STATS"][1][f"temp{chipset}"] hashboard.chip_temp = api_stats["STATS"][1][f"temp2_{chipset}"] - except (KeyError, IndexError): + except LookupError: pass else: hashboard.missing = False try: hashrate += api_stats["STATS"][1][f"chain_rate{chipset}"] chips += api_stats["STATS"][1][f"chain_acn{chipset}"] - except (KeyError, IndexError): + except LookupError: pass hashboard.hashrate = round(hashrate / 1000, 2) hashboard.chips = chips @@ -88,7 +88,7 @@ class HiveonT9(Hiveon, T9): boards = api_stats.get("STATS") try: wattage_raw = boards[1]["chain_power"] - except (KeyError, IndexError): + except LookupError: pass else: # parse wattage position out of raw data @@ -113,7 +113,7 @@ class HiveonT9(Hiveon, T9): env_temp = api_stats["STATS"][1][f"temp3_{chipset}"] if not env_temp == 0: env_temp_list.append(int(env_temp)) - except (KeyError, IndexError): + except LookupError: pass if not env_temp_list == []: diff --git a/pyasic/miners/backends/antminer.py b/pyasic/miners/backends/antminer.py index 1de438e9..7e7d5c33 100644 --- a/pyasic/miners/backends/antminer.py +++ b/pyasic/miners/backends/antminer.py @@ -189,7 +189,7 @@ class AntminerModern(BMMiner): errors.append(X19Error(item["msg"])) except KeyError: continue - except (KeyError, IndexError): + except LookupError: pass return errors @@ -266,7 +266,7 @@ class AntminerModern(BMMiner): return round(expected_rate / 1000000, 2) else: return round(expected_rate, 2) - except (KeyError, IndexError): + except LookupError: pass async def set_static_ip( @@ -497,7 +497,7 @@ class AntminerOld(CGMiner): fans_data[fan].speed = api_stats["STATS"][1].get( f"fan{fan_offset+fan}", 0 ) - except (KeyError, IndexError): + except LookupError: pass return fans_data @@ -550,7 +550,7 @@ class AntminerOld(CGMiner): if (not chips) or (not chips > 0): hashboard.missing = True hashboards.append(hashboard) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass return hashboards diff --git a/pyasic/miners/backends/bfgminer.py b/pyasic/miners/backends/bfgminer.py index 78fdb5e4..8dfb1499 100644 --- a/pyasic/miners/backends/bfgminer.py +++ b/pyasic/miners/backends/bfgminer.py @@ -128,7 +128,7 @@ class BFGMiner(BaseMiner): if api_version: try: self.api_ver = api_version["VERSION"][0]["API"] - except (KeyError, IndexError): + except LookupError: pass return self.api_ver @@ -143,7 +143,7 @@ class BFGMiner(BaseMiner): if api_version: try: self.fw_ver = api_version["VERSION"][0]["CompileTime"] - except (KeyError, IndexError): + except LookupError: pass return self.fw_ver @@ -168,7 +168,7 @@ class BFGMiner(BaseMiner): if api_summary: try: return round(float(api_summary["SUMMARY"][0]["MHS 20s"] / 1000000), 2) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: @@ -220,7 +220,7 @@ class BFGMiner(BaseMiner): if (not chips) or (not chips > 0): hashboard.missing = True hashboards.append(hashboard) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass return hashboards @@ -258,7 +258,7 @@ class BFGMiner(BaseMiner): fans_data[fan] = api_stats["STATS"][1].get( f"fan{fan_offset+fan}", 0 ) - except (KeyError, IndexError): + except LookupError: pass fans = [Fan(speed=d) if d else Fan() for d in fans_data] @@ -291,7 +291,7 @@ class BFGMiner(BaseMiner): return round(expected_rate / 1000000, 2) else: return round(expected_rate, 2) - except (KeyError, IndexError): + except LookupError: pass async def _is_mining(self, *args, **kwargs) -> Optional[bool]: diff --git a/pyasic/miners/backends/bmminer.py b/pyasic/miners/backends/bmminer.py index 92b84851..9d2b71f7 100644 --- a/pyasic/miners/backends/bmminer.py +++ b/pyasic/miners/backends/bmminer.py @@ -167,7 +167,7 @@ class BMMiner(BaseMiner): if api_version: try: self.api_ver = api_version["VERSION"][0]["API"] - except (KeyError, IndexError): + except LookupError: pass return self.api_ver @@ -182,7 +182,7 @@ class BMMiner(BaseMiner): if api_version: try: self.fw_ver = api_version["VERSION"][0]["CompileTime"] - except (KeyError, IndexError): + except LookupError: pass return self.fw_ver @@ -205,7 +205,7 @@ class BMMiner(BaseMiner): if api_summary: try: return round(float(api_summary["SUMMARY"][0]["GHS 5s"] / 1000), 2) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: @@ -308,7 +308,7 @@ class BMMiner(BaseMiner): fans[fan].speed = api_stats["STATS"][1].get( f"fan{fan_offset+fan}", 0 ) - except (KeyError, IndexError): + except LookupError: pass return fans @@ -340,7 +340,7 @@ class BMMiner(BaseMiner): return round(expected_rate / 1000000, 2) else: return round(expected_rate, 2) - except (KeyError, IndexError): + except LookupError: pass async def _is_mining(self, *args, **kwargs) -> Optional[bool]: diff --git a/pyasic/miners/backends/bosminer.py b/pyasic/miners/backends/bosminer.py index 7307233d..84df4a05 100644 --- a/pyasic/miners/backends/bosminer.py +++ b/pyasic/miners/backends/bosminer.py @@ -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]: diff --git a/pyasic/miners/backends/btminer.py b/pyasic/miners/backends/btminer.py index 4e75071d..fa9085df 100644 --- a/pyasic/miners/backends/btminer.py +++ b/pyasic/miners/backends/btminer.py @@ -306,7 +306,7 @@ class BTMiner(BaseMiner): try: mac = api_summary["SUMMARY"][0]["MAC"] return str(mac).upper() - except (KeyError, IndexError): + except LookupError: pass async def _get_api_ver(self, api_get_version: dict = None) -> Optional[str]: @@ -362,7 +362,7 @@ class BTMiner(BaseMiner): self.fw_ver = api_summary["SUMMARY"][0]["Firmware Version"].replace( "'", "" ) - except (KeyError, IndexError): + except LookupError: pass return self.fw_ver @@ -394,7 +394,7 @@ class BTMiner(BaseMiner): if api_summary: try: return round(float(api_summary["SUMMARY"][0]["MHS 1m"] / 1000000), 2) - except (KeyError, IndexError): + except LookupError: pass async def _get_hashboards(self, api_devs: dict = None) -> List[HashBoard]: @@ -427,7 +427,7 @@ class BTMiner(BaseMiner): hashboards[board["ASC"]].chips = board["Effective Chips"] hashboards[board["ASC"]].serial_number = board["PCB SN"] hashboards[board["ASC"]].missing = False - except (KeyError, IndexError): + except LookupError: pass return hashboards @@ -442,7 +442,7 @@ class BTMiner(BaseMiner): if api_summary: try: return api_summary["SUMMARY"][0]["Env Temp"] - except (KeyError, IndexError): + except LookupError: pass async def _get_wattage(self, api_summary: dict = None) -> Optional[int]: @@ -456,7 +456,7 @@ class BTMiner(BaseMiner): try: wattage = api_summary["SUMMARY"][0]["Power"] return wattage if not wattage == -1 else None - except (KeyError, IndexError): + except LookupError: pass async def _get_wattage_limit(self, api_summary: dict = None) -> Optional[int]: @@ -469,7 +469,7 @@ class BTMiner(BaseMiner): if api_summary: try: return api_summary["SUMMARY"][0]["Power Limit"] - except (KeyError, IndexError): + except LookupError: pass async def _get_fans( @@ -489,7 +489,7 @@ class BTMiner(BaseMiner): Fan(api_summary["SUMMARY"][0].get("Fan Speed In", 0)), Fan(api_summary["SUMMARY"][0].get("Fan Speed Out", 0)), ] - except (KeyError, IndexError): + except LookupError: pass return fans @@ -506,7 +506,7 @@ class BTMiner(BaseMiner): if api_summary: try: return int(api_summary["SUMMARY"][0]["Power Fanspeed"]) - except (KeyError, IndexError): + except LookupError: pass if not api_get_psu: @@ -537,7 +537,7 @@ class BTMiner(BaseMiner): err = api_summary["SUMMARY"][0].get(f"Error Code {i}") if err: errors.append(WhatsminerError(error_code=err)) - except (KeyError, IndexError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass if not api_get_error_code: @@ -568,7 +568,7 @@ class BTMiner(BaseMiner): expected_hashrate = api_summary["SUMMARY"][0]["Factory GHS"] if expected_hashrate: return round(expected_hashrate / 1000, 2) - except (KeyError, IndexError): + except LookupError: pass async def _get_fault_light(self, api_get_miner_info: dict = None) -> bool: diff --git a/pyasic/miners/backends/cgminer.py b/pyasic/miners/backends/cgminer.py index f44829bc..9e56d119 100644 --- a/pyasic/miners/backends/cgminer.py +++ b/pyasic/miners/backends/cgminer.py @@ -192,7 +192,7 @@ class CGMiner(BaseMiner): if api_version: try: self.api_ver = api_version["VERSION"][0]["API"] - except (KeyError, IndexError): + except LookupError: pass return self.api_ver @@ -207,7 +207,7 @@ class CGMiner(BaseMiner): if api_version: try: self.fw_ver = api_version["VERSION"][0]["CGMiner"] - except (KeyError, IndexError): + except LookupError: pass return self.fw_ver @@ -229,7 +229,7 @@ class CGMiner(BaseMiner): return round( float(float(api_summary["SUMMARY"][0]["GHS 5s"]) / 1000), 2 ) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: @@ -281,7 +281,7 @@ class CGMiner(BaseMiner): if (not chips) or (not chips > 0): hashboard.missing = True hashboards.append(hashboard) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass return hashboards @@ -319,7 +319,7 @@ class CGMiner(BaseMiner): fans[fan].speed = api_stats["STATS"][1].get( f"fan{fan_offset+fan}", 0 ) - except (KeyError, IndexError): + except LookupError: pass return fans @@ -353,7 +353,7 @@ class CGMiner(BaseMiner): return round(expected_rate / 1000000, 2) else: return round(expected_rate, 2) - except (KeyError, IndexError): + except LookupError: pass async def _is_mining(self, *args, **kwargs) -> Optional[bool]: diff --git a/pyasic/miners/backends/cgminer_avalon.py b/pyasic/miners/backends/cgminer_avalon.py index 23bae3f0..9b4ce6b9 100644 --- a/pyasic/miners/backends/cgminer_avalon.py +++ b/pyasic/miners/backends/cgminer_avalon.py @@ -210,7 +210,7 @@ class CGMinerAvalon(CGMiner): if api_devs: try: return round(float(api_devs["DEVS"][0]["MHS 1m"] / 1000000), 2) - except (KeyError, IndexError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: @@ -229,7 +229,7 @@ class CGMinerAvalon(CGMiner): try: unparsed_stats = api_stats["STATS"][0]["MM ID0"] parsed_stats = self.parse_stats(unparsed_stats) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): return hashboards for board in range(self.expected_hashboards): @@ -273,7 +273,7 @@ class CGMinerAvalon(CGMiner): unparsed_stats = api_stats["STATS"][0]["MM ID0"] parsed_stats = self.parse_stats(unparsed_stats) return round(float(parsed_stats["GHSmm"]) / 1000, 2) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass async def _get_env_temp(self, api_stats: dict = None) -> Optional[float]: @@ -288,7 +288,7 @@ class CGMinerAvalon(CGMiner): unparsed_stats = api_stats["STATS"][0]["MM ID0"] parsed_stats = self.parse_stats(unparsed_stats) return float(parsed_stats["Temp"]) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass async def _get_wattage(self) -> Optional[int]: @@ -306,7 +306,7 @@ class CGMinerAvalon(CGMiner): unparsed_stats = api_stats["STATS"][0]["MM ID0"] parsed_stats = self.parse_stats(unparsed_stats) return int(parsed_stats["MPO"]) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass async def _get_fans(self, api_stats: dict = None) -> List[Fan]: @@ -327,7 +327,7 @@ class CGMinerAvalon(CGMiner): for fan in range(self.expected_fans): try: fans_data[fan].speed = int(parsed_stats[f"Fan{fan + 1}"]) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass return fans_data @@ -349,7 +349,7 @@ class CGMinerAvalon(CGMiner): parsed_stats = self.parse_stats(unparsed_stats) led = int(parsed_stats["Led"]) return True if led == 1 else False - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass try: diff --git a/pyasic/miners/backends/epic.py b/pyasic/miners/backends/epic.py index 83452263..a4519133 100644 --- a/pyasic/miners/backends/epic.py +++ b/pyasic/miners/backends/epic.py @@ -216,7 +216,7 @@ class ePIC(BaseMiner): hashrate += hb["Hashrate"][0] / ideal return round(float(float(hashrate / 1000000)), 2) - except (IndexError, KeyError, ValueError, TypeError) as e: + except (LookupError, ValueError, TypeError) as e: logger.error(e) pass diff --git a/pyasic/miners/backends/luxminer.py b/pyasic/miners/backends/luxminer.py index b22260b9..7e1d6499 100644 --- a/pyasic/miners/backends/luxminer.py +++ b/pyasic/miners/backends/luxminer.py @@ -211,7 +211,7 @@ class LUXMiner(BaseMiner): if api_summary: try: return round(float(api_summary["SUMMARY"][0]["GHS 5s"] / 1000), 2) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: @@ -263,7 +263,7 @@ class LUXMiner(BaseMiner): if (not chips) or (not chips > 0): hashboard.missing = True hashboards.append(hashboard) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass return hashboards @@ -281,7 +281,7 @@ class LUXMiner(BaseMiner): if api_power: try: return api_power["POWER"][0]["Watts"] - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass async def _get_wattage_limit(self) -> Optional[int]: @@ -299,8 +299,8 @@ class LUXMiner(BaseMiner): if api_fans: for fan in range(self.expected_fans): try: - fans.append(Fan(api_fans["FANS"][0]["RPM"])) - except (IndexError, KeyError, ValueError, TypeError): + fans.append(Fan(api_fans["FANS"][fan]["RPM"])) + except (LookupError, ValueError, TypeError): fans.append(Fan()) return fans @@ -333,7 +333,7 @@ class LUXMiner(BaseMiner): return round(expected_rate / 1000000, 2) else: return round(expected_rate, 2) - except (KeyError, IndexError): + except LookupError: pass async def _is_mining(self) -> Optional[bool]: diff --git a/pyasic/miners/backends/vnish.py b/pyasic/miners/backends/vnish.py index f2af26a2..7fafba06 100644 --- a/pyasic/miners/backends/vnish.py +++ b/pyasic/miners/backends/vnish.py @@ -181,7 +181,7 @@ class VNish(BMMiner): return round( float(float(api_summary["SUMMARY"][0]["GHS 5s"]) / 1000), 2 ) - except (IndexError, KeyError, ValueError, TypeError) as e: + except (LookupError, ValueError, TypeError) as e: logger.error(e) pass diff --git a/pyasic/miners/innosilicon/cgminer/A10X/A10X.py b/pyasic/miners/innosilicon/cgminer/A10X/A10X.py index bb1890d2..7f626bf0 100644 --- a/pyasic/miners/innosilicon/cgminer/A10X/A10X.py +++ b/pyasic/miners/innosilicon/cgminer/A10X/A10X.py @@ -145,7 +145,7 @@ class CGMinerA10X(CGMiner, A10X): return round( float(api_summary["SUMMARY"][0]["MHS 1m"] / 1000000000000), 5 ) - except (KeyError, IndexError): + except LookupError: pass async def get_hashboards( @@ -303,7 +303,7 @@ class CGMinerA10X(CGMiner, A10X): if api_version: try: self.fw_ver = api_version["VERSION"][0]["CGMiner"].split("-")[-1:][0] - except (KeyError, IndexError): + except LookupError: pass return self.fw_ver diff --git a/pyasic/miners/innosilicon/cgminer/T3X/T3H.py b/pyasic/miners/innosilicon/cgminer/T3X/T3H.py index ccb5c275..593ef039 100644 --- a/pyasic/miners/innosilicon/cgminer/T3X/T3H.py +++ b/pyasic/miners/innosilicon/cgminer/T3X/T3H.py @@ -122,7 +122,7 @@ class CGMinerT3HPlus(CGMiner, T3HPlus): if api_summary: try: return round(float(api_summary["SUMMARY"][0]["MHS 1m"] / 1000000), 2) - except (KeyError, IndexError): + except LookupError: pass async def get_hashboards( From be67ef3471c89aa04249d6e2d208b210e1756049 Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Thu, 11 Jan 2024 15:29:29 -0700 Subject: [PATCH 05/14] refactor: remove bad function. --- pyasic/miners/backends/bosminer.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pyasic/miners/backends/bosminer.py b/pyasic/miners/backends/bosminer.py index 84df4a05..f2e98828 100644 --- a/pyasic/miners/backends/bosminer.py +++ b/pyasic/miners/backends/bosminer.py @@ -458,15 +458,6 @@ class BOSMiner(BaseMiner): return self.raw_model + " (BOS)" return "? (BOS)" - async def get_version( - self, api_version: dict = None, graphql_version: dict = None - ) -> Tuple[Optional[str], Optional[str]]: - # check if version is cached - miner_version = namedtuple("MinerVersion", "api_ver fw_ver") - api_ver = await self.get_api_ver(api_version) - fw_ver = await self.get_fw_ver(graphql_version) - return miner_version(api_ver, fw_ver) - async def _get_api_ver(self, api_version: dict = None) -> Optional[str]: if not api_version: try: From ff4dfa124b575e191807ac08bfaa2531fe1f0e52 Mon Sep 17 00:00:00 2001 From: fdeh Date: Sun, 14 Jan 2024 19:53:47 +0300 Subject: [PATCH 06/14] Fix VNish get_hashrate and get_fans errors Update vnish.py. Fix data locations according to the method arguments --- pyasic/miners/backends/vnish.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyasic/miners/backends/vnish.py b/pyasic/miners/backends/vnish.py index 7fafba06..13d8cef5 100644 --- a/pyasic/miners/backends/vnish.py +++ b/pyasic/miners/backends/vnish.py @@ -44,7 +44,7 @@ VNISH_DATA_LOC = DataLocations( "_get_hostname", [WebAPICommand("web_summary", "summary")] ), str(DataOptions.HASHRATE): DataFunction( - "_get_hashrate", [WebAPICommand("web_summary", "summary")] + "_get_hashrate", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( "_get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] @@ -60,7 +60,7 @@ VNISH_DATA_LOC = DataLocations( "_get_wattage_limit", [WebAPICommand("web_settings", "settings")] ), str(DataOptions.FANS): DataFunction( - "_get_fans", [WebAPICommand("web_summary", "summary")] + "_get_fans", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.FAN_PSU): DataFunction("_get_fan_psu"), str(DataOptions.ERRORS): DataFunction("_get_errors"), From e4c6d751a1cb941fe02cac85456ecb3329096ae0 Mon Sep 17 00:00:00 2001 From: b-rowan Date: Sun, 14 Jan 2024 09:59:06 -0700 Subject: [PATCH 07/14] version: bump version number. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ea795a2e..b94204ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pyasic" -version = "0.46.0" +version = "0.46.1" description = "A simplified and standardized interface for Bitcoin ASICs." authors = ["UpstreamData "] repository = "https://github.com/UpstreamData/pyasic" From c5224b808ea5a982500764c60c3dfce48e30e4be Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Thu, 11 Jan 2024 11:33:44 -0700 Subject: [PATCH 08/14] refactor: remove parameters from `get_{x}` functions and move them to `_get_{x}(**params)`. Add `miner.fw_str`, and `miner.raw_model`. Remove `model` from `get_data` exclude. Swap `fan_count` to `expected_fans`. --- pyasic/miners/backends/bosminer.py | 37 +++++++++++++++++++----------- pyasic/miners/backends/epic.py | 7 +++--- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/pyasic/miners/backends/bosminer.py b/pyasic/miners/backends/bosminer.py index f2e98828..7307233d 100644 --- a/pyasic/miners/backends/bosminer.py +++ b/pyasic/miners/backends/bosminer.py @@ -458,6 +458,15 @@ class BOSMiner(BaseMiner): return self.raw_model + " (BOS)" return "? (BOS)" + async def get_version( + self, api_version: dict = None, graphql_version: dict = None + ) -> Tuple[Optional[str], Optional[str]]: + # check if version is cached + miner_version = namedtuple("MinerVersion", "api_ver fw_ver") + api_ver = await self.get_api_ver(api_version) + fw_ver = await self.get_fw_ver(graphql_version) + return miner_version(api_ver, fw_ver) + async def _get_api_ver(self, api_version: dict = None) -> Optional[str]: if not api_version: try: @@ -469,7 +478,7 @@ class BOSMiner(BaseMiner): if api_version: try: api_ver = api_version["VERSION"][0]["API"] - except LookupError: + except (KeyError, IndexError): api_ver = None self.api_ver = api_ver self.api.api_ver = self.api_ver @@ -571,7 +580,7 @@ class BOSMiner(BaseMiner): if api_summary: try: return round(float(api_summary["SUMMARY"][0]["MHS 1m"] / 1000000), 2) - except (LookupError, ValueError, TypeError): + except (KeyError, IndexError, ValueError, TypeError): pass async def _get_hashboards( @@ -633,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 (LookupError, TypeError, ValueError): + except (TypeError, KeyError, ValueError, IndexError): pass details = hb.get("hwDetails") if details: @@ -657,15 +666,15 @@ class BOSMiner(BaseMiner): d = {} try: api_temps = d["temps"][0] - except LookupError: + except (KeyError, IndexError): api_temps = None try: api_devdetails = d["devdetails"][0] - except LookupError: + except (KeyError, IndexError): api_devdetails = None try: api_devs = d["devs"][0] - except LookupError: + except (KeyError, IndexError): api_devs = None if api_temps: try: @@ -677,7 +686,7 @@ class BOSMiner(BaseMiner): board_temp = round(board["Board"]) hashboards[_id].chip_temp = chip_temp hashboards[_id].temp = board_temp - except (LookupError, ValueError, TypeError): + except (IndexError, KeyError, ValueError, TypeError): pass if api_devdetails: @@ -689,7 +698,7 @@ class BOSMiner(BaseMiner): chips = board["Chips"] hashboards[_id].chips = chips hashboards[_id].missing = False - except LookupError: + except (IndexError, KeyError): pass if api_devs: @@ -700,7 +709,7 @@ class BOSMiner(BaseMiner): _id = board["ID"] - offset hashrate = round(float(board["MHS 1m"] / 1000000), 2) hashboards[_id].hashrate = hashrate - except LookupError: + except (IndexError, KeyError): pass return hashboards @@ -741,7 +750,7 @@ class BOSMiner(BaseMiner): return api_tunerstatus["TUNERSTATUS"][0][ "ApproximateMinerPowerConsumption" ] - except LookupError: + except (KeyError, IndexError): pass async def _get_wattage_limit( @@ -772,7 +781,7 @@ class BOSMiner(BaseMiner): if api_tunerstatus: try: return api_tunerstatus["TUNERSTATUS"][0]["PowerLimit"] - except LookupError: + except (KeyError, IndexError): pass async def _get_fans( @@ -811,7 +820,7 @@ class BOSMiner(BaseMiner): for n in range(self.expected_fans): try: fans.append(Fan(api_fans["FANS"][n]["RPM"])) - except LookupError: + except (IndexError, KeyError): pass return fans return [Fan() for _ in range(self.expected_fans)] @@ -895,7 +904,7 @@ class BOSMiner(BaseMiner): _error = _error[0].lower() + _error[1:] errors.append(BraiinsOSError(f"Slot {_id} {_error}")) return errors - except LookupError: + except (KeyError, IndexError): pass async def _get_fault_light(self, graphql_fault_light: dict = None) -> bool: @@ -978,7 +987,7 @@ class BOSMiner(BaseMiner): return round( (sum(hr_list) / len(hr_list)) * self.expected_hashboards, 2 ) - except LookupError: + except (IndexError, KeyError): pass async def _is_mining(self, api_devdetails: dict = None) -> Optional[bool]: diff --git a/pyasic/miners/backends/epic.py b/pyasic/miners/backends/epic.py index a4519133..0914d0f8 100644 --- a/pyasic/miners/backends/epic.py +++ b/pyasic/miners/backends/epic.py @@ -14,9 +14,10 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -from typing import List, Optional +from typing import List, Optional, Tuple -from pyasic.config import MinerConfig +from pyasic import MinerConfig +from pyasic.config import MinerConfig, MiningModeConfig from pyasic.data import Fan, HashBoard from pyasic.data.error_codes import MinerErrorData, X19Error from pyasic.errors import APIError @@ -216,7 +217,7 @@ class ePIC(BaseMiner): hashrate += hb["Hashrate"][0] / ideal return round(float(float(hashrate / 1000000)), 2) - except (LookupError, ValueError, TypeError) as e: + except (IndexError, KeyError, ValueError, TypeError) as e: logger.error(e) pass From 8fb357544ba6fd8c153a2b096aa418d07262bf6d Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Mon, 15 Jan 2024 10:16:47 -0700 Subject: [PATCH 09/14] bug: add test to cross check function arguments, and fix some method implementations and naming. --- docs/miners/innosilicon/A10X.md | 3 +- docs/miners/innosilicon/T3X.md | 3 +- pyasic/miners/antminer/hiveon/X9/T9.py | 40 +- pyasic/miners/backends/btminer.py | 149 ++++--- pyasic/miners/backends/cgminer_avalon.py | 81 ++-- pyasic/miners/backends/hiveon.py | 63 ++- pyasic/miners/backends/innosilicon.py | 404 ++++++++++++++++++ .../miners/innosilicon/cgminer/A10X/A10X.py | 316 +------------- .../innosilicon/cgminer/A10X/__init__.py | 2 +- pyasic/miners/innosilicon/cgminer/T3X/T3H.py | 276 +----------- .../innosilicon/cgminer/T3X/__init__.py | 2 +- pyasic/miners/miner_factory.py | 4 +- pyasic/web/{inno.py => innosilicon.py} | 0 tests/miners_tests/__init__.py | 25 ++ 14 files changed, 655 insertions(+), 713 deletions(-) create mode 100644 pyasic/miners/backends/innosilicon.py rename pyasic/web/{inno.py => innosilicon.py} (100%) diff --git a/docs/miners/innosilicon/A10X.md b/docs/miners/innosilicon/A10X.md index b3e5bf03..62dc9450 100644 --- a/docs/miners/innosilicon/A10X.md +++ b/docs/miners/innosilicon/A10X.md @@ -2,9 +2,8 @@ ## A10X Models ## A10X -::: pyasic.miners.innosilicon.cgminer.A10X.A10X.CGMinerA10X +::: pyasic.miners.innosilicon.cgminer.A10X.A10X.InnosiliconA10X handler: python options: show_root_heading: false heading_level: 4 - diff --git a/docs/miners/innosilicon/T3X.md b/docs/miners/innosilicon/T3X.md index 47fd870e..bd877b5a 100644 --- a/docs/miners/innosilicon/T3X.md +++ b/docs/miners/innosilicon/T3X.md @@ -2,9 +2,8 @@ ## T3X Models ## T3H+ -::: pyasic.miners.innosilicon.cgminer.T3X.T3H.CGMinerT3HPlus +::: pyasic.miners.innosilicon.cgminer.T3X.T3H.InnosiliconT3HPlus handler: python options: show_root_heading: false heading_level: 4 - diff --git a/pyasic/miners/antminer/hiveon/X9/T9.py b/pyasic/miners/antminer/hiveon/X9/T9.py index 691d150c..f7194624 100644 --- a/pyasic/miners/antminer/hiveon/X9/T9.py +++ b/pyasic/miners/antminer/hiveon/X9/T9.py @@ -25,10 +25,6 @@ from pyasic.miners.types import T9 class HiveonT9(Hiveon, T9): - def __init__(self, ip: str, api_ver: str = "0.0.0") -> None: - super().__init__(ip, api_ver=api_ver) - self.ip = ip - self.pwd = "admin" ################################################## ### DATA GATHERING FUNCTIONS (get_{some_data}) ### @@ -46,34 +42,44 @@ class HiveonT9(Hiveon, T9): pass async def get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: + hashboards = [ + HashBoard(slot=board, expected_chips=self.expected_chips) + for board in range(self.expected_hashboards) + ] + + if api_stats is None: + try: + api_stats = self.api.stats() + except APIError: + return [] + board_map = { 0: [2, 9, 10], 1: [3, 11, 12], 2: [4, 13, 14], } - hashboards = [] for board in board_map: - hashboard = HashBoard(slot=board, expected_chips=self.expected_chips) hashrate = 0 chips = 0 for chipset in board_map[board]: - if hashboard.chip_temp == None: + if hashboards[board].chip_temp is None: try: - hashboard.board_temp = api_stats["STATS"][1][f"temp{chipset}"] - hashboard.chip_temp = api_stats["STATS"][1][f"temp2_{chipset}"] - except LookupError: + hashboards[board].temp = api_stats["STATS"][1][f"temp{chipset}"] + hashboards[board].chip_temp = api_stats["STATS"][1][ + f"temp2_{chipset}" + ] + except (KeyError, IndexError): pass else: - hashboard.missing = False + hashboards[board].missing = False try: hashrate += api_stats["STATS"][1][f"chain_rate{chipset}"] chips += api_stats["STATS"][1][f"chain_acn{chipset}"] - except LookupError: + except (KeyError, IndexError): pass - hashboard.hashrate = round(hashrate / 1000, 2) - hashboard.chips = chips - hashboards.append(hashboard) + hashboards[board].hashrate = round(hashrate / 1000, 2) + hashboards[board].chips = chips return hashboards @@ -88,7 +94,7 @@ class HiveonT9(Hiveon, T9): boards = api_stats.get("STATS") try: wattage_raw = boards[1]["chain_power"] - except LookupError: + except (KeyError, IndexError): pass else: # parse wattage position out of raw data @@ -113,7 +119,7 @@ class HiveonT9(Hiveon, T9): env_temp = api_stats["STATS"][1][f"temp3_{chipset}"] if not env_temp == 0: env_temp_list.append(int(env_temp)) - except LookupError: + except (KeyError, IndexError): pass if not env_temp_list == []: diff --git a/pyasic/miners/backends/btminer.py b/pyasic/miners/backends/btminer.py index fa9085df..de3ef732 100644 --- a/pyasic/miners/backends/btminer.py +++ b/pyasic/miners/backends/btminer.py @@ -15,7 +15,8 @@ # ------------------------------------------------------------------------------ import logging -from typing import List, Optional +from collections import namedtuple +from typing import List, Optional, Tuple from pyasic.API.btminer import BTMinerAPI from pyasic.config import MinerConfig, MiningModeConfig @@ -28,74 +29,80 @@ from pyasic.miners.base import ( DataLocations, DataOptions, RPCAPICommand, + WebAPICommand, ) BTMINER_DATA_LOC = DataLocations( **{ str(DataOptions.MAC): DataFunction( - "_get_mac", + "get_mac", [ RPCAPICommand("api_summary", "summary"), RPCAPICommand("api_get_miner_info", "get_miner_info"), ], ), + str(DataOptions.MODEL): DataFunction("get_model"), str(DataOptions.API_VERSION): DataFunction( - "_get_api_ver", [RPCAPICommand("api_get_version", "get_version")] + "get_api_ver", [RPCAPICommand("api_get_version", "get_version")] ), str(DataOptions.FW_VERSION): DataFunction( - "_get_fw_ver", + "get_fw_ver", [ RPCAPICommand("api_get_version", "get_version"), RPCAPICommand("api_summary", "summary"), ], ), str(DataOptions.HOSTNAME): DataFunction( - "_get_hostname", [RPCAPICommand("api_get_miner_info", "get_miner_info")] + "get_hostname", [RPCAPICommand("api_get_miner_info", "get_miner_info")] ), str(DataOptions.HASHRATE): DataFunction( - "_get_hashrate", [RPCAPICommand("api_summary", "summary")] + "get_hashrate", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "_get_expected_hashrate", [RPCAPICommand("api_summary", "summary")] + "get_expected_hashrate", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.HASHBOARDS): DataFunction( - "_get_hashboards", [RPCAPICommand("api_devs", "devs")] + "get_hashboards", [RPCAPICommand("api_devs", "devs")] ), str(DataOptions.ENVIRONMENT_TEMP): DataFunction( - "_get_env_temp", [RPCAPICommand("api_summary", "summary")] + "get_env_temp", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.WATTAGE): DataFunction( - "_get_wattage", [RPCAPICommand("api_summary", "summary")] + "get_wattage", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.WATTAGE_LIMIT): DataFunction( - "_get_wattage_limit", [RPCAPICommand("api_summary", "summary")] + "get_wattage_limit", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.FANS): DataFunction( - "_get_fans", + "get_fans", [ RPCAPICommand("api_summary", "summary"), RPCAPICommand("api_get_psu", "get_psu"), ], ), str(DataOptions.FAN_PSU): DataFunction( - "_get_fan_psu", + "get_fan_psu", [ RPCAPICommand("api_summary", "summary"), RPCAPICommand("api_get_psu", "get_psu"), ], ), str(DataOptions.ERRORS): DataFunction( - "_get_errors", [RPCAPICommand("api_get_error_code", "get_error_code")] + "get_errors", + [ + RPCAPICommand("api_get_error_code", "get_error_code"), + RPCAPICommand("api_summary", "summary"), + ], ), str(DataOptions.FAULT_LIGHT): DataFunction( - "_get_fault_light", + "get_fault_light", [RPCAPICommand("api_get_miner_info", "get_miner_info")], ), str(DataOptions.IS_MINING): DataFunction( - "_is_mining", [RPCAPICommand("api_status", "status")] + "is_mining", [RPCAPICommand("api_status", "status")] ), str(DataOptions.UPTIME): DataFunction( - "_get_uptime", [RPCAPICommand("api_summary", "summary")] + "get_uptime", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.CONFIG): DataFunction("get_config"), } @@ -236,7 +243,7 @@ class BTMiner(BaseMiner): else: cfg = MinerConfig() - is_mining = await self._is_mining(status) + is_mining = await self.is_mining(status) if not is_mining: cfg.mining_mode = MiningModeConfig.sleep() return cfg @@ -280,7 +287,7 @@ class BTMiner(BaseMiner): ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## - async def _get_mac( + async def get_mac( self, api_summary: dict = None, api_get_miner_info: dict = None ) -> Optional[str]: if not api_get_miner_info: @@ -306,10 +313,24 @@ class BTMiner(BaseMiner): try: mac = api_summary["SUMMARY"][0]["MAC"] return str(mac).upper() - except LookupError: + except (KeyError, IndexError): pass - async def _get_api_ver(self, api_get_version: dict = None) -> Optional[str]: + async def get_version( + self, api_get_version: dict = None, api_summary: dict = None + ) -> Tuple[Optional[str], Optional[str]]: + miner_version = namedtuple("MinerVersion", "api_ver fw_ver") + api_ver = await self.get_api_ver(api_get_version=api_get_version) + fw_ver = await self.get_fw_ver( + api_get_version=api_get_version, api_summary=api_summary + ) + return miner_version(api_ver, fw_ver) + + async def get_api_ver(self, api_get_version: dict = None) -> Optional[str]: + # Check to see if the version info is already cached + if self.api_ver: + return self.api_ver + if not api_get_version: try: api_get_version = await self.api.get_version() @@ -332,9 +353,13 @@ class BTMiner(BaseMiner): return self.api_ver - async def _get_fw_ver( + async def get_fw_ver( self, api_get_version: dict = None, api_summary: dict = None ) -> Optional[str]: + # Check to see if the version info is already cached + if self.fw_ver: + return self.fw_ver + if not api_get_version: try: api_get_version = await self.api.get_version() @@ -362,12 +387,12 @@ class BTMiner(BaseMiner): self.fw_ver = api_summary["SUMMARY"][0]["Firmware Version"].replace( "'", "" ) - except LookupError: + except (KeyError, IndexError): pass return self.fw_ver - async def _get_hostname(self, api_get_miner_info: dict = None) -> Optional[str]: + async def get_hostname(self, api_get_miner_info: dict = None) -> Optional[str]: hostname = None if not api_get_miner_info: try: @@ -383,7 +408,7 @@ class BTMiner(BaseMiner): return hostname - async def _get_hashrate(self, api_summary: dict = None) -> Optional[float]: + async def get_hashrate(self, api_summary: dict = None) -> Optional[float]: # get hr from API if not api_summary: try: @@ -394,10 +419,10 @@ class BTMiner(BaseMiner): if api_summary: try: return round(float(api_summary["SUMMARY"][0]["MHS 1m"] / 1000000), 2) - except LookupError: + except (KeyError, IndexError): pass - async def _get_hashboards(self, api_devs: dict = None) -> List[HashBoard]: + async def get_hashboards(self, api_devs: dict = None) -> List[HashBoard]: hashboards = [ HashBoard(slot=i, expected_chips=self.expected_chips) for i in range(self.expected_hashboards) @@ -427,12 +452,12 @@ class BTMiner(BaseMiner): hashboards[board["ASC"]].chips = board["Effective Chips"] hashboards[board["ASC"]].serial_number = board["PCB SN"] hashboards[board["ASC"]].missing = False - except LookupError: + except (KeyError, IndexError): pass return hashboards - async def _get_env_temp(self, api_summary: dict = None) -> Optional[float]: + async def get_env_temp(self, api_summary: dict = None) -> Optional[float]: if not api_summary: try: api_summary = await self.api.summary() @@ -442,10 +467,10 @@ class BTMiner(BaseMiner): if api_summary: try: return api_summary["SUMMARY"][0]["Env Temp"] - except LookupError: + except (KeyError, IndexError): pass - async def _get_wattage(self, api_summary: dict = None) -> Optional[int]: + async def get_wattage(self, api_summary: dict = None) -> Optional[int]: if not api_summary: try: api_summary = await self.api.summary() @@ -456,10 +481,10 @@ class BTMiner(BaseMiner): try: wattage = api_summary["SUMMARY"][0]["Power"] return wattage if not wattage == -1 else None - except LookupError: + except (KeyError, IndexError): pass - async def _get_wattage_limit(self, api_summary: dict = None) -> Optional[int]: + async def get_wattage_limit(self, api_summary: dict = None) -> Optional[int]: if not api_summary: try: api_summary = await self.api.summary() @@ -469,10 +494,10 @@ class BTMiner(BaseMiner): if api_summary: try: return api_summary["SUMMARY"][0]["Power Limit"] - except LookupError: + except (KeyError, IndexError): pass - async def _get_fans( + async def get_fans( self, api_summary: dict = None, api_get_psu: dict = None ) -> List[Fan]: if not api_summary: @@ -481,20 +506,20 @@ class BTMiner(BaseMiner): except APIError: pass - fans = [Fan() for _ in range(self.expected_fans)] + fans = [Fan() for _ in range(self.fan_count)] if api_summary: try: - if self.expected_fans > 0: + if self.fan_count > 0: fans = [ Fan(api_summary["SUMMARY"][0].get("Fan Speed In", 0)), Fan(api_summary["SUMMARY"][0].get("Fan Speed Out", 0)), ] - except LookupError: + except (KeyError, IndexError): pass return fans - async def _get_fan_psu( + async def get_fan_psu( self, api_summary: dict = None, api_get_psu: dict = None ) -> Optional[int]: if not api_summary: @@ -506,7 +531,7 @@ class BTMiner(BaseMiner): if api_summary: try: return int(api_summary["SUMMARY"][0]["Power Fanspeed"]) - except LookupError: + except (KeyError, IndexError): pass if not api_get_psu: @@ -521,26 +546,11 @@ class BTMiner(BaseMiner): except (KeyError, TypeError): pass - async def _get_errors( + async def get_errors( self, api_summary: dict = None, api_get_error_code: dict = None ) -> List[MinerErrorData]: errors = [] - if not api_summary and not api_get_error_code: - try: - api_summary = await self.api.summary() - except APIError: - pass - - if api_summary: - try: - for i in range(api_summary["SUMMARY"][0]["Error Code Count"]): - err = api_summary["SUMMARY"][0].get(f"Error Code {i}") - if err: - errors.append(WhatsminerError(error_code=err)) - except (LookupError, ValueError, TypeError): - pass - - if not api_get_error_code: + if not api_get_error_code and not api_summary: try: api_get_error_code = await self.api.get_error_code() except APIError: @@ -554,9 +564,24 @@ class BTMiner(BaseMiner): else: errors.append(WhatsminerError(error_code=int(err))) + if not api_summary: + try: + api_summary = await self.api.summary() + except APIError: + pass + + if api_summary: + try: + for i in range(api_summary["SUMMARY"][0]["Error Code Count"]): + err = api_summary["SUMMARY"][0].get(f"Error Code {i}") + if err: + errors.append(WhatsminerError(error_code=err)) + except (KeyError, IndexError, ValueError, TypeError): + pass + return errors - async def _get_expected_hashrate(self, api_summary: dict = None): + async def get_expected_hashrate(self, api_summary: dict = None): if not api_summary: try: api_summary = await self.api.summary() @@ -568,10 +593,10 @@ class BTMiner(BaseMiner): expected_hashrate = api_summary["SUMMARY"][0]["Factory GHS"] if expected_hashrate: return round(expected_hashrate / 1000, 2) - except LookupError: + except (KeyError, IndexError): pass - async def _get_fault_light(self, api_get_miner_info: dict = None) -> bool: + async def get_fault_light(self, api_get_miner_info: dict = None) -> bool: if not api_get_miner_info: try: api_get_miner_info = await self.api.get_miner_info() @@ -609,7 +634,7 @@ class BTMiner(BaseMiner): async def set_hostname(self, hostname: str): await self.api.set_hostname(hostname) - async def _is_mining(self, api_status: dict = None) -> Optional[bool]: + async def is_mining(self, api_status: dict = None) -> Optional[bool]: if not api_status: try: api_status = await self.api.status() @@ -628,7 +653,7 @@ class BTMiner(BaseMiner): except LookupError: pass - async def _get_uptime(self, api_summary: dict = None) -> Optional[int]: + async def get_uptime(self, api_summary: dict = None) -> Optional[int]: if not api_summary: try: api_summary = await self.api.summary() diff --git a/pyasic/miners/backends/cgminer_avalon.py b/pyasic/miners/backends/cgminer_avalon.py index 9b4ce6b9..216087b5 100644 --- a/pyasic/miners/backends/cgminer_avalon.py +++ b/pyasic/miners/backends/cgminer_avalon.py @@ -14,6 +14,7 @@ # limitations under the License. - # ------------------------------------------------------------------------------ +import logging import re from typing import List, Optional @@ -27,43 +28,42 @@ from pyasic.miners.base import DataFunction, DataLocations, DataOptions, RPCAPIC AVALON_DATA_LOC = DataLocations( **{ str(DataOptions.MAC): DataFunction( - "_get_mac", [RPCAPICommand("api_version", "version")] + "get_mac", [RPCAPICommand("api_version", "version")] ), + str(DataOptions.MODEL): DataFunction("get_model"), str(DataOptions.API_VERSION): DataFunction( - "_get_api_ver", [RPCAPICommand("api_version", "version")] + "get_api_ver", [RPCAPICommand("api_version", "version")] ), str(DataOptions.FW_VERSION): DataFunction( - "_get_fw_ver", [RPCAPICommand("api_version", "version")] - ), - str(DataOptions.HOSTNAME): DataFunction( - "_get_hostname", [RPCAPICommand("api_version", "version")] + "get_fw_ver", [RPCAPICommand("api_version", "version")] ), + str(DataOptions.HOSTNAME): DataFunction("get_hostname"), str(DataOptions.HASHRATE): DataFunction( - "_get_hashrate", [RPCAPICommand("api_devs", "devs")] + "get_hashrate", [RPCAPICommand("api_devs", "devs")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "_get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] + "get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.HASHBOARDS): DataFunction( - "_get_hashboards", [RPCAPICommand("api_stats", "stats")] + "get_hashboards", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.ENVIRONMENT_TEMP): DataFunction( - "_get_env_temp", [RPCAPICommand("api_stats", "stats")] + "get_env_temp", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.WATTAGE): DataFunction("_get_wattage"), + str(DataOptions.WATTAGE): DataFunction("get_wattage"), str(DataOptions.WATTAGE_LIMIT): DataFunction( - "_get_wattage_limit", [RPCAPICommand("api_stats", "stats")] + "get_wattage_limit", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.FANS): DataFunction( - "_get_fans", [RPCAPICommand("api_stats", "stats")] + "get_fans", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.FAN_PSU): DataFunction("_get_fan_psu"), - str(DataOptions.ERRORS): DataFunction("_get_errors"), + str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), + str(DataOptions.ERRORS): DataFunction("get_errors"), str(DataOptions.FAULT_LIGHT): DataFunction( - "_get_fault_light", [RPCAPICommand("api_stats", "stats")] + "get_fault_light", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.IS_MINING): DataFunction("_is_mining"), - str(DataOptions.UPTIME): DataFunction("_get_uptime"), + str(DataOptions.IS_MINING): DataFunction("is_mining"), + str(DataOptions.UPTIME): DataFunction("get_uptime"), str(DataOptions.CONFIG): DataFunction("get_config"), } ) @@ -174,7 +174,7 @@ class CGMinerAvalon(CGMiner): ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## - async def _get_mac(self, api_version: dict = None) -> Optional[str]: + async def get_mac(self, api_version: dict = None) -> Optional[str]: if not api_version: try: api_version = await self.api.version() @@ -192,7 +192,7 @@ class CGMinerAvalon(CGMiner): except (KeyError, ValueError): pass - async def _get_hostname(self, mac: str = None) -> Optional[str]: + async def get_hostname(self) -> Optional[str]: return None # if not mac: # mac = await self.get_mac() @@ -200,7 +200,7 @@ class CGMinerAvalon(CGMiner): # if mac: # return f"Avalon{mac.replace(':', '')[-6:]}" - async def _get_hashrate(self, api_devs: dict = None) -> Optional[float]: + async def get_hashrate(self, api_devs: dict = None) -> Optional[float]: if not api_devs: try: api_devs = await self.api.devs() @@ -210,10 +210,10 @@ class CGMinerAvalon(CGMiner): if api_devs: try: return round(float(api_devs["DEVS"][0]["MHS 1m"] / 1000000), 2) - except (LookupError, ValueError, TypeError): + except (KeyError, IndexError, ValueError, TypeError): pass - async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: + async def get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: hashboards = [ HashBoard(slot=i, expected_chips=self.expected_chips) for i in range(self.expected_hashboards) @@ -229,7 +229,7 @@ class CGMinerAvalon(CGMiner): try: unparsed_stats = api_stats["STATS"][0]["MM ID0"] parsed_stats = self.parse_stats(unparsed_stats) - except (LookupError, ValueError, TypeError): + except (IndexError, KeyError, ValueError, TypeError): return hashboards for board in range(self.expected_hashboards): @@ -261,7 +261,7 @@ class CGMinerAvalon(CGMiner): return hashboards - async def _get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]: + async def get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]: if not api_stats: try: api_stats = await self.api.stats() @@ -273,10 +273,10 @@ class CGMinerAvalon(CGMiner): unparsed_stats = api_stats["STATS"][0]["MM ID0"] parsed_stats = self.parse_stats(unparsed_stats) return round(float(parsed_stats["GHSmm"]) / 1000, 2) - except (LookupError, ValueError, TypeError): + except (IndexError, KeyError, ValueError, TypeError): pass - async def _get_env_temp(self, api_stats: dict = None) -> Optional[float]: + async def get_env_temp(self, api_stats: dict = None) -> Optional[float]: if not api_stats: try: api_stats = await self.api.stats() @@ -288,13 +288,13 @@ class CGMinerAvalon(CGMiner): unparsed_stats = api_stats["STATS"][0]["MM ID0"] parsed_stats = self.parse_stats(unparsed_stats) return float(parsed_stats["Temp"]) - except (LookupError, ValueError, TypeError): + except (IndexError, KeyError, ValueError, TypeError): pass - async def _get_wattage(self) -> Optional[int]: + async def get_wattage(self) -> Optional[int]: return None - async def _get_wattage_limit(self, api_stats: dict = None) -> Optional[int]: + async def get_wattage_limit(self, api_stats: dict = None) -> Optional[int]: if not api_stats: try: api_stats = await self.api.stats() @@ -306,17 +306,17 @@ class CGMinerAvalon(CGMiner): unparsed_stats = api_stats["STATS"][0]["MM ID0"] parsed_stats = self.parse_stats(unparsed_stats) return int(parsed_stats["MPO"]) - except (LookupError, ValueError, TypeError): + except (IndexError, KeyError, ValueError, TypeError): pass - async def _get_fans(self, api_stats: dict = None) -> List[Fan]: + async def get_fans(self, api_stats: dict = None) -> List[Fan]: if not api_stats: try: api_stats = await self.api.stats() except APIError: pass - fans_data = [Fan() for _ in range(self.expected_fans)] + fans_data = [Fan() for _ in range(self.fan_count)] if api_stats: try: unparsed_stats = api_stats["STATS"][0]["MM ID0"] @@ -324,17 +324,17 @@ class CGMinerAvalon(CGMiner): except LookupError: return fans_data - for fan in range(self.expected_fans): + for fan in range(self.fan_count): try: fans_data[fan].speed = int(parsed_stats[f"Fan{fan + 1}"]) - except (LookupError, ValueError, TypeError): + except (IndexError, KeyError, ValueError, TypeError): pass return fans_data - async def _get_errors(self) -> List[MinerErrorData]: + async def get_errors(self) -> List[MinerErrorData]: return [] - async def _get_fault_light(self, api_stats: dict = None) -> bool: # noqa + async def get_fault_light(self, api_stats: dict = None) -> bool: # noqa if self.light: return self.light if not api_stats: @@ -349,7 +349,7 @@ class CGMinerAvalon(CGMiner): parsed_stats = self.parse_stats(unparsed_stats) led = int(parsed_stats["Led"]) return True if led == 1 else False - except (LookupError, ValueError, TypeError): + except (IndexError, KeyError, ValueError, TypeError): pass try: @@ -363,5 +363,8 @@ class CGMinerAvalon(CGMiner): pass return False - async def _is_mining(self, *args, **kwargs) -> Optional[bool]: + async def is_mining(self, *args, **kwargs) -> Optional[bool]: + return None + + async def get_uptime(self) -> Optional[int]: return None diff --git a/pyasic/miners/backends/hiveon.py b/pyasic/miners/backends/hiveon.py index 1ce6c12b..600eb41c 100644 --- a/pyasic/miners/backends/hiveon.py +++ b/pyasic/miners/backends/hiveon.py @@ -14,12 +14,73 @@ # limitations under the License. - # ------------------------------------------------------------------------------ +from typing import List, Optional + +from pyasic.data import HashBoard from pyasic.miners.backends import BMMiner +from pyasic.miners.base import DataFunction, DataLocations, DataOptions, RPCAPICommand + +HIVEON_DATA_LOC = DataLocations( + **{ + str(DataOptions.MAC): DataFunction("get_mac"), + str(DataOptions.MODEL): DataFunction("get_model"), + str(DataOptions.API_VERSION): DataFunction( + "get_api_ver", [RPCAPICommand("api_version", "version")] + ), + str(DataOptions.FW_VERSION): DataFunction( + "get_fw_ver", [RPCAPICommand("api_version", "version")] + ), + str(DataOptions.HOSTNAME): DataFunction("get_hostname"), + str(DataOptions.HASHRATE): DataFunction( + "get_hashrate", [RPCAPICommand("api_summary", "summary")] + ), + str(DataOptions.EXPECTED_HASHRATE): DataFunction( + "get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] + ), + str(DataOptions.HASHBOARDS): DataFunction( + "get_hashboards", [RPCAPICommand("api_stats", "stats")] + ), + str(DataOptions.ENVIRONMENT_TEMP): DataFunction( + "get_env_temp", [RPCAPICommand("api_stats", "stats")] + ), + str(DataOptions.WATTAGE): DataFunction( + "get_wattage", [RPCAPICommand("api_stats", "stats")] + ), + str(DataOptions.WATTAGE_LIMIT): DataFunction("get_wattage_limit"), + str(DataOptions.FANS): DataFunction( + "get_fans", [RPCAPICommand("api_stats", "stats")] + ), + str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), + str(DataOptions.ERRORS): DataFunction("get_errors"), + str(DataOptions.FAULT_LIGHT): DataFunction("get_fault_light"), + str(DataOptions.IS_MINING): DataFunction("is_mining"), + str(DataOptions.UPTIME): DataFunction( + "get_uptime", [RPCAPICommand("api_stats", "stats")] + ), + str(DataOptions.CONFIG): DataFunction("get_config"), + } +) class Hiveon(BMMiner): def __init__(self, ip: str, api_ver: str = "0.0.0") -> None: super().__init__(ip, api_ver) + self.pwd = "admin" # static data self.api_type = "Hiveon" - self.fw_str = "Hive" + # data gathering locations + self.data_locations = HIVEON_DATA_LOC + + async def get_model(self) -> Optional[str]: + if self.model is not None: + return self.model + " (Hiveon)" + return "? (Hiveon)" + + async def get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: + pass + + async def get_wattage(self, api_stats: dict = None) -> Optional[int]: + pass + + async def get_env_temp(self, api_stats: dict = None) -> Optional[float]: + pass diff --git a/pyasic/miners/backends/innosilicon.py b/pyasic/miners/backends/innosilicon.py new file mode 100644 index 00000000..192bfeb6 --- /dev/null +++ b/pyasic/miners/backends/innosilicon.py @@ -0,0 +1,404 @@ +# ------------------------------------------------------------------------------ +# Copyright 2022 Upstream Data Inc - +# - +# Licensed under the Apache License, Version 2.0 (the "License"); - +# you may not use this file except in compliance with the License. - +# You may obtain a copy of the License at - +# - +# http://www.apache.org/licenses/LICENSE-2.0 - +# - +# Unless required by applicable law or agreed to in writing, software - +# distributed under the License is distributed on an "AS IS" BASIS, - +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - +# See the License for the specific language governing permissions and - +# limitations under the License. - +# ------------------------------------------------------------------------------ +from typing import List, Optional + +from pyasic.config import MinerConfig +from pyasic.data import Fan, HashBoard +from pyasic.data.error_codes import MinerErrorData +from pyasic.data.error_codes.innosilicon import InnosiliconError +from pyasic.errors import APIError +from pyasic.miners.backends import CGMiner +from pyasic.miners.base import ( + DataFunction, + DataLocations, + DataOptions, + RPCAPICommand, + WebAPICommand, +) +from pyasic.web.innosilicon import InnosiliconWebAPI + +INNOSILICON_DATA_LOC = DataLocations( + **{ + str(DataOptions.MAC): DataFunction( + "get_mac", + [ + WebAPICommand("web_get_all", "getAll"), + WebAPICommand("web_overview", "overview"), + ], + ), + str(DataOptions.MODEL): DataFunction("get_model"), + str(DataOptions.API_VERSION): DataFunction( + "get_api_ver", [RPCAPICommand("api_version", "version")] + ), + str(DataOptions.FW_VERSION): DataFunction( + "get_fw_ver", [RPCAPICommand("api_version", "version")] + ), + str(DataOptions.HOSTNAME): DataFunction("get_hostname"), + str(DataOptions.HASHRATE): DataFunction( + "get_hashrate", + [ + RPCAPICommand("api_summary", "summary"), + WebAPICommand("web_get_all", "getAll"), + ], + ), + str(DataOptions.EXPECTED_HASHRATE): DataFunction( + "get_expected_hashrate", + ), + str(DataOptions.HASHBOARDS): DataFunction( + "get_hashboards", + [ + RPCAPICommand("api_stats", "stats"), + WebAPICommand("web_get_all", "getAll"), + ], + ), + str(DataOptions.ENVIRONMENT_TEMP): DataFunction("get_env_temp"), + str(DataOptions.WATTAGE): DataFunction( + "get_wattage", + [ + WebAPICommand("web_get_all", "getAll"), + RPCAPICommand("api_stats", "stats"), + ], + ), + str(DataOptions.WATTAGE_LIMIT): DataFunction( + "get_wattage_limit", + [ + WebAPICommand("web_get_all", "getAll"), + ], + ), + str(DataOptions.FANS): DataFunction( + "get_fans", + [ + WebAPICommand("web_get_all", "getAll"), + ], + ), + str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), + str(DataOptions.ERRORS): DataFunction( + "get_errors", + [ + WebAPICommand("web_get_error_detail", "getErrorDetail"), + ], + ), + str(DataOptions.FAULT_LIGHT): DataFunction("get_fault_light"), + str(DataOptions.IS_MINING): DataFunction("is_mining"), + str(DataOptions.UPTIME): DataFunction( + "get_uptime", [RPCAPICommand("api_stats", "stats")] + ), + str(DataOptions.CONFIG): DataFunction("get_config"), + } +) + + +class Innosilicon(CGMiner): + def __init__(self, ip: str, api_ver: str = "0.0.0") -> None: + super().__init__(ip, api_ver=api_ver) + # interfaces + self.web = InnosiliconWebAPI(ip) + + # static data + # data gathering locations + self.data_locations = INNOSILICON_DATA_LOC + # autotuning/shutdown support + self.supports_shutdown = True + + # data storage + self.api_ver = api_ver + + async def fault_light_on(self) -> bool: + return False + + async def fault_light_off(self) -> bool: + return False + + async def get_config(self) -> MinerConfig: + # get pool data + try: + pools = await self.web.pools() + except APIError: + return self.config + + self.config = MinerConfig.from_inno(pools) + return self.config + + async def reboot(self) -> bool: + try: + data = await self.web.reboot() + except APIError: + pass + else: + return data["success"] + + async def restart_cgminer(self) -> bool: + try: + data = await self.web.restart_cgminer() + except APIError: + pass + else: + return data["success"] + + async def restart_backend(self) -> bool: + return await self.restart_cgminer() + + async def stop_mining(self) -> bool: + return False + # data = await self.web.poweroff() + # try: + # return data["success"] + # except KeyError: + # return False + + async def resume_mining(self) -> bool: + return False + # data = await self.web.restart_cgminer() + # print(data) + # try: + # return data["success"] + # except KeyError: + # return False + + async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None: + self.config = config + await self.web.update_pools(config.as_inno(user_suffix=user_suffix)) + + ################################################## + ### DATA GATHERING FUNCTIONS (get_{some_data}) ### + ################################################## + + async def get_mac( + self, web_get_all: dict = None, web_overview: dict = None + ) -> Optional[str]: + if web_get_all: + web_get_all = web_get_all["all"] + + if not web_get_all and not web_overview: + try: + web_overview = await self.web.overview() + except APIError: + pass + + if web_get_all: + try: + mac = web_get_all["mac"] + return mac.upper() + except KeyError: + pass + + if web_overview: + try: + mac = web_overview["version"]["ethaddr"] + return mac.upper() + except KeyError: + pass + + async def get_hashrate( + self, api_summary: dict = None, web_get_all: dict = None + ) -> Optional[float]: + if web_get_all: + web_get_all = web_get_all["all"] + + if not api_summary and not web_get_all: + try: + api_summary = await self.api.summary() + except APIError: + pass + + if web_get_all: + try: + if "Hash Rate H" in web_get_all["total_hash"].keys(): + return round( + float(web_get_all["total_hash"]["Hash Rate H"] / 1000000000000), + 2, + ) + elif "Hash Rate" in web_get_all["total_hash"].keys(): + return round( + float(web_get_all["total_hash"]["Hash Rate"] / 1000000), 5 + ) + except KeyError: + pass + + if api_summary: + try: + return round(float(api_summary["SUMMARY"][0]["MHS 1m"] / 1000000), 2) + except (KeyError, IndexError): + pass + + async def get_hashboards( + self, api_stats: dict = None, web_get_all: dict = None + ) -> List[HashBoard]: + if web_get_all: + web_get_all = web_get_all["all"] + + hashboards = [ + HashBoard(slot=i, expected_chips=self.expected_chips) + for i in range(self.expected_hashboards) + ] + + if not api_stats: + try: + api_stats = await self.api.stats() + except APIError: + pass + + if not web_get_all: + try: + web_get_all = await self.web.get_all() + except APIError: + pass + else: + web_get_all = web_get_all["all"] + + if api_stats: + if api_stats.get("STATS"): + for board in api_stats["STATS"]: + try: + idx = board["Chain ID"] + chips = board["Num active chips"] + except KeyError: + pass + else: + hashboards[idx].chips = chips + hashboards[idx].missing = False + + if web_get_all: + if web_get_all.get("chain"): + for board in web_get_all["chain"]: + idx = board.get("ASC") + if idx is not None: + temp = board.get("Temp min") + if temp: + hashboards[idx].temp = round(temp) + + hashrate = board.get("Hash Rate H") + if hashrate: + hashboards[idx].hashrate = round( + hashrate / 1000000000000, 2 + ) + + chip_temp = board.get("Temp max") + if chip_temp: + hashboards[idx].chip_temp = round(chip_temp) + + return hashboards + + async def get_wattage( + self, web_get_all: dict = None, api_stats: dict = None + ) -> Optional[int]: + if web_get_all: + web_get_all = web_get_all["all"] + + if not web_get_all: + try: + web_get_all = await self.web.get_all() + except APIError: + pass + else: + web_get_all = web_get_all["all"] + + if web_get_all: + try: + return web_get_all["power"] + except KeyError: + pass + + if not api_stats: + try: + api_stats = await self.api.stats() + except APIError: + pass + + if api_stats: + if api_stats.get("STATS"): + for board in api_stats["STATS"]: + try: + wattage = board["power"] + except KeyError: + pass + else: + wattage = int(wattage) + return wattage + + async def get_fans(self, web_get_all: dict = None) -> List[Fan]: + if web_get_all: + web_get_all = web_get_all["all"] + + if not web_get_all: + try: + web_get_all = await self.web.get_all() + except APIError: + pass + else: + web_get_all = web_get_all["all"] + + fans = [Fan() for _ in range(self.fan_count)] + if web_get_all: + try: + spd = web_get_all["fansSpeed"] + except KeyError: + pass + else: + round((int(spd) * 6000) / 100) + for i in range(self.fan_count): + fans[i].speed = spd + + return fans + + async def get_errors( + self, web_get_error_detail: dict = None + ) -> List[MinerErrorData]: + errors = [] + if not web_get_error_detail: + try: + web_get_error_detail = await self.web.get_error_detail() + except APIError: + pass + + if web_get_error_detail: + try: + # only 1 error? + # TODO: check if this should be a loop, can't remember. + err = web_get_error_detail["code"] + except KeyError: + pass + else: + err = int(err) + if not err == 0: + errors.append(InnosiliconError(error_code=err)) + return errors + + async def get_wattage_limit(self, web_get_all: dict = None) -> Optional[int]: + if web_get_all: + web_get_all = web_get_all["all"] + + if not web_get_all: + try: + web_get_all = await self.web.get_all() + except APIError: + pass + else: + web_get_all = web_get_all["all"] + + if web_get_all: + try: + level = web_get_all["running_mode"]["level"] + except KeyError: + pass + else: + # this is very possibly not correct. + level = int(level) + limit = 1250 + (250 * level) + return limit + + async def get_expected_hashrate(self) -> Optional[float]: + pass diff --git a/pyasic/miners/innosilicon/cgminer/A10X/A10X.py b/pyasic/miners/innosilicon/cgminer/A10X/A10X.py index 7f626bf0..54394037 100644 --- a/pyasic/miners/innosilicon/cgminer/A10X/A10X.py +++ b/pyasic/miners/innosilicon/cgminer/A10X/A10X.py @@ -13,320 +13,10 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ -import logging -from typing import List, Optional -from pyasic.config import MinerConfig -from pyasic.data import Fan, HashBoard -from pyasic.data.error_codes import InnosiliconError, MinerErrorData -from pyasic.errors import APIError -from pyasic.miners.backends import CGMiner +from pyasic.miners.backends.innosilicon import Innosilicon from pyasic.miners.types import A10X -from pyasic.web.inno import InnosiliconWebAPI -class CGMinerA10X(CGMiner, A10X): - def __init__(self, ip: str, api_ver: str = "0.0.0") -> None: - super().__init__(ip, api_ver=api_ver) - self.ip = ip - self.web = InnosiliconWebAPI(ip) - - async def fault_light_on(self) -> bool: - return False - - async def fault_light_off(self) -> bool: - return False - - async def get_config(self, web_pools: dict = None) -> MinerConfig: - if not web_pools: - try: - web_pools = await self.web.pools() - except APIError as e: - logging.warning(e) - - if web_pools: - if "pools" in web_pools.keys(): - cfg = MinerConfig().from_raw(web_pools) - self.config = cfg - return self.config - - async def reboot(self) -> bool: - try: - data = await self.web.reboot() - except APIError: - pass - else: - return data["success"] - - async def restart_cgminer(self) -> bool: - try: - data = await self.web.restart_cgminer() - except APIError: - pass - else: - return data["success"] - - async def restart_backend(self) -> bool: - return await self.restart_cgminer() - - async def stop_mining(self) -> bool: - return False - # data = await self.web.poweroff() - # try: - # return data["success"] - # except KeyError: - # return False - - async def resume_mining(self) -> bool: - return False - # data = await self.web.restart_cgminer() - # print(data) - # try: - # return data["success"] - # except KeyError: - # return False - - async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None: - pass - # doesnt work for some reason - # self.config = config - # await self.web.update_pools(config.as_inno(user_suffix=user_suffix)) - - ################################################## - ### DATA GATHERING FUNCTIONS (get_{some_data}) ### - ################################################## - - async def get_mac( - self, web_get_all: dict = None, web_overview: dict = None - ) -> Optional[str]: - if web_get_all: - web_get_all = web_get_all["all"] - - if not web_get_all and not web_overview: - try: - web_overview = await self.web.overview() - except APIError: - pass - - if web_get_all: - try: - mac = web_get_all["mac"] - return mac.upper() - except KeyError: - pass - - if web_overview: - try: - mac = web_overview["version"]["ethaddr"] - return mac.upper() - except KeyError: - pass - - async def get_hashrate( - self, api_summary: dict = None, web_get_all: dict = None - ) -> Optional[float]: - if web_get_all: - web_get_all = web_get_all["all"] - - if not api_summary and not web_get_all: - try: - api_summary = await self.api.summary() - except APIError: - pass - - if web_get_all: - try: - return round(float(web_get_all["total_hash"]["Hash Rate"] / 1000000), 5) - except KeyError: - pass - - if api_summary: - try: - return round( - float(api_summary["SUMMARY"][0]["MHS 1m"] / 1000000000000), 5 - ) - except LookupError: - pass - - async def get_hashboards( - self, api_stats: dict = None, web_get_all: dict = None - ) -> List[HashBoard]: - hashboards = [ - HashBoard(slot=i, expected_chips=self.expected_chips) - for i in range(self.expected_hashboards) - ] - if web_get_all: - web_get_all = web_get_all["all"] - - if not api_stats: - try: - api_stats = await self.api.stats() - except APIError: - pass - - if not web_get_all: - try: - web_get_all = await self.web.get_all() - except APIError: - pass - else: - web_get_all = web_get_all["all"] - - if api_stats: - if api_stats.get("STATS"): - for board in api_stats["STATS"]: - try: - idx = board["Chain ID"] - chips = board["Num active chips"] - except KeyError: - pass - else: - hashboards[idx].chips = chips - hashboards[idx].missing = False - - if web_get_all: - if web_get_all.get("chain"): - for board in web_get_all["chain"]: - idx = board.get("ASC") - if idx is not None: - temp = board.get("Temp min") - if temp: - hashboards[idx].temp = round(temp) - - hashrate = board.get("Hash Rate H") - if hashrate: - hashboards[idx].hashrate = round( - hashrate / 1000000000000, 5 - ) - - chip_temp = board.get("Temp max") - if chip_temp: - hashboards[idx].chip_temp = round(chip_temp) - - return hashboards - - async def get_wattage( - self, web_get_all: dict = None, api_stats: dict = None - ) -> Optional[int]: - if web_get_all: - web_get_all = web_get_all["all"] - - if not web_get_all: - try: - web_get_all = await self.web.get_all() - except APIError: - pass - else: - web_get_all = web_get_all["all"] - - if web_get_all: - try: - return web_get_all["power"] - except KeyError: - pass - - if not api_stats: - try: - api_stats = await self.api.stats() - except APIError: - pass - - if api_stats: - if api_stats.get("STATS"): - for board in api_stats["STATS"]: - try: - wattage = board["power"] - except KeyError: - pass - else: - wattage = int(wattage) - return wattage - - async def get_fans(self, web_get_all: dict = None) -> List[Fan]: - if web_get_all: - web_get_all = web_get_all["all"] - - if not web_get_all: - try: - web_get_all = await self.web.get_all() - except APIError: - pass - else: - web_get_all = web_get_all["all"] - - fans = [Fan() for _ in range(self.expected_fans)] - if web_get_all: - try: - spd = web_get_all["fansSpeed"] - except KeyError: - pass - else: - round((int(spd) * 6000) / 100) - for i in range(self.expected_fans): - fans[i].speed = spd - - return fans - - async def get_errors( - self, web_get_error_detail: dict = None - ) -> List[MinerErrorData]: # noqa: named this way for automatic functionality - errors = [] - if not web_get_error_detail: - try: - web_get_error_detail = await self.web.get_error_detail() - except APIError: - pass - - if web_get_error_detail: - try: - # only 1 error? - # TODO: check if this should be a loop, can't remember. - err = web_get_error_detail["code"] - except KeyError: - pass - else: - err = int(err) - if not err == 0: - errors.append(InnosiliconError(error_code=err)) - return errors - - async def get_fw_ver(self, api_version: dict = None) -> Optional[str]: - if self.fw_ver: - return self.fw_ver - - if not api_version: - try: - api_version = await self.api.version() - except APIError: - pass - - if api_version: - try: - self.fw_ver = api_version["VERSION"][0]["CGMiner"].split("-")[-1:][0] - except LookupError: - pass - - return self.fw_ver - - async def get_wattage_limit(self, web_get_all: dict = None) -> Optional[int]: - if web_get_all: - web_get_all = web_get_all["all"] - - if not web_get_all: - try: - web_get_all = await self.web.get_all() - except APIError: - pass - else: - web_get_all = web_get_all["all"] - - if web_get_all: - try: - level = web_get_all["running_mode"]["level"] - except KeyError: - pass - else: - # this is very possibly not correct. - level = int(level) - limit = 1250 + (250 * level) - return limit +class InnosiliconA10X(Innosilicon, A10X): + pass diff --git a/pyasic/miners/innosilicon/cgminer/A10X/__init__.py b/pyasic/miners/innosilicon/cgminer/A10X/__init__.py index 9d7075b9..e18c86d7 100644 --- a/pyasic/miners/innosilicon/cgminer/A10X/__init__.py +++ b/pyasic/miners/innosilicon/cgminer/A10X/__init__.py @@ -14,4 +14,4 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -from .A10X import CGMinerA10X +from .A10X import InnosiliconA10X diff --git a/pyasic/miners/innosilicon/cgminer/T3X/T3H.py b/pyasic/miners/innosilicon/cgminer/T3X/T3H.py index 593ef039..5e34366a 100644 --- a/pyasic/miners/innosilicon/cgminer/T3X/T3H.py +++ b/pyasic/miners/innosilicon/cgminer/T3X/T3H.py @@ -13,280 +13,10 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ -from typing import List, Optional -from pyasic.config import MinerConfig -from pyasic.data import Fan, HashBoard -from pyasic.data.error_codes import InnosiliconError, MinerErrorData -from pyasic.errors import APIError -from pyasic.miners.backends import CGMiner +from pyasic.miners.backends.innosilicon import Innosilicon from pyasic.miners.types import T3HPlus -from pyasic.web.inno import InnosiliconWebAPI -class CGMinerT3HPlus(CGMiner, T3HPlus): - def __init__(self, ip: str, api_ver: str = "0.0.0") -> None: - super().__init__(ip, api_ver=api_ver) - self.ip = ip - self.web = InnosiliconWebAPI(ip) - - async def fault_light_on(self) -> bool: - return False - - async def fault_light_off(self) -> bool: - return False - - async def get_config(self, api_pools: dict = None) -> MinerConfig: - # get pool data - try: - pools = await self.api.pools() - except APIError: - return self.config - - self.config = MinerConfig.from_api(pools) - return self.config - - async def reboot(self) -> bool: - try: - data = await self.web.reboot() - except APIError: - pass - else: - return data["success"] - - async def restart_cgminer(self) -> bool: - try: - data = await self.web.restart_cgminer() - except APIError: - pass - else: - return data["success"] - - async def restart_backend(self) -> bool: - return await self.restart_cgminer() - - async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None: - self.config = config - await self.web.update_pools(config.as_inno(user_suffix=user_suffix)) - - ################################################## - ### DATA GATHERING FUNCTIONS (get_{some_data}) ### - ################################################## - - async def get_mac( - self, web_get_all: dict = None, web_overview: dict = None - ) -> Optional[str]: - if web_get_all: - web_get_all = web_get_all["all"] - - if not web_get_all and not web_overview: - try: - web_overview = await self.web.overview() - except APIError: - pass - - if web_get_all: - try: - mac = web_get_all["mac"] - return mac.upper() - except KeyError: - pass - - if web_overview: - try: - mac = web_overview["version"]["ethaddr"] - return mac.upper() - except KeyError: - pass - - async def get_hashrate( - self, api_summary: dict = None, web_get_all: dict = None - ) -> Optional[float]: - if web_get_all: - web_get_all = web_get_all["all"] - - if not api_summary and not web_get_all: - try: - api_summary = await self.api.summary() - except APIError: - pass - - if web_get_all: - try: - return round( - float(web_get_all["total_hash"]["Hash Rate H"] / 1000000000000), 2 - ) - except KeyError: - pass - - if api_summary: - try: - return round(float(api_summary["SUMMARY"][0]["MHS 1m"] / 1000000), 2) - except LookupError: - pass - - async def get_hashboards( - self, api_stats: dict = None, web_get_all: dict = None - ) -> List[HashBoard]: - if web_get_all: - web_get_all = web_get_all["all"] - - hashboards = [ - HashBoard(slot=i, expected_chips=self.expected_chips) - for i in range(self.expected_hashboards) - ] - - if not api_stats: - try: - api_stats = await self.api.stats() - except APIError: - pass - - if not web_get_all: - try: - web_get_all = await self.web.get_all() - except APIError: - pass - else: - web_get_all = web_get_all["all"] - - if api_stats: - if api_stats.get("STATS"): - for board in api_stats["STATS"]: - try: - idx = board["Chain ID"] - chips = board["Num active chips"] - except KeyError: - pass - else: - hashboards[idx].chips = chips - hashboards[idx].missing = False - - if web_get_all: - if web_get_all.get("chain"): - for board in web_get_all["chain"]: - idx = board.get("ASC") - if idx is not None: - temp = board.get("Temp min") - if temp: - hashboards[idx].temp = round(temp) - - hashrate = board.get("Hash Rate H") - if hashrate: - hashboards[idx].hashrate = round( - hashrate / 1000000000000, 2 - ) - - chip_temp = board.get("Temp max") - if chip_temp: - hashboards[idx].chip_temp = round(chip_temp) - - return hashboards - - async def get_wattage( - self, web_get_all: dict = None, api_stats: dict = None - ) -> Optional[int]: - if web_get_all: - web_get_all = web_get_all["all"] - - if not web_get_all: - try: - web_get_all = await self.web.get_all() - except APIError: - pass - else: - web_get_all = web_get_all["all"] - - if web_get_all: - try: - return web_get_all["power"] - except KeyError: - pass - - if not api_stats: - try: - api_stats = await self.api.stats() - except APIError: - pass - - if api_stats: - if api_stats.get("STATS"): - for board in api_stats["STATS"]: - try: - wattage = board["power"] - except KeyError: - pass - else: - wattage = int(wattage) - return wattage - - async def get_fans(self, web_get_all: dict = None) -> List[Fan]: - if web_get_all: - web_get_all = web_get_all["all"] - - if not web_get_all: - try: - web_get_all = await self.web.get_all() - except APIError: - pass - else: - web_get_all = web_get_all["all"] - - fans = [Fan() for _ in range(self.fan_count)] - if web_get_all: - try: - spd = web_get_all["fansSpeed"] - except KeyError: - pass - else: - round((int(spd) * 6000) / 100) - for i in range(self.fan_count): - fans[i].speed = spd - - return fans - - async def get_errors( - self, web_get_error_detail: dict = None - ) -> List[MinerErrorData]: # noqa: named this way for automatic functionality - errors = [] - if not web_get_error_detail: - try: - web_get_error_detail = await self.web.get_error_detail() - except APIError: - pass - - if web_get_error_detail: - try: - # only 1 error? - # TODO: check if this should be a loop, can't remember. - err = web_get_error_detail["code"] - except KeyError: - pass - else: - err = int(err) - if not err == 0: - errors.append(InnosiliconError(error_code=err)) - return errors - - async def get_wattage_limit(self, web_get_all: dict = None) -> Optional[int]: - if web_get_all: - web_get_all = web_get_all["all"] - - if not web_get_all: - try: - web_get_all = await self.web.get_all() - except APIError: - pass - else: - web_get_all = web_get_all["all"] - - if web_get_all: - try: - level = web_get_all["running_mode"]["level"] - except KeyError: - pass - else: - # this is very possibly not correct. - level = int(level) - limit = 1250 + (250 * level) - return limit +class InnosiliconT3HPlus(Innosilicon, T3HPlus): + pass diff --git a/pyasic/miners/innosilicon/cgminer/T3X/__init__.py b/pyasic/miners/innosilicon/cgminer/T3X/__init__.py index f2a2eb8b..ebfb0337 100644 --- a/pyasic/miners/innosilicon/cgminer/T3X/__init__.py +++ b/pyasic/miners/innosilicon/cgminer/T3X/__init__.py @@ -14,4 +14,4 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -from .T3H import CGMinerT3HPlus +from .T3H import InnosiliconT3HPlus diff --git a/pyasic/miners/miner_factory.py b/pyasic/miners/miner_factory.py index c35e05c6..0f4fca15 100644 --- a/pyasic/miners/miner_factory.py +++ b/pyasic/miners/miner_factory.py @@ -326,8 +326,8 @@ MINER_CLASSES = { }, MinerTypes.INNOSILICON: { None: CGMiner, - "T3H+": CGMinerT3HPlus, - "A10X": CGMinerA10X, + "T3H+": InnosiliconT3HPlus, + "A10X": InnosiliconA10X, }, MinerTypes.GOLDSHELL: { None: BFGMiner, diff --git a/pyasic/web/inno.py b/pyasic/web/innosilicon.py similarity index 100% rename from pyasic/web/inno.py rename to pyasic/web/innosilicon.py diff --git a/tests/miners_tests/__init__.py b/tests/miners_tests/__init__.py index 82d8a246..e0e700a6 100644 --- a/tests/miners_tests/__init__.py +++ b/tests/miners_tests/__init__.py @@ -72,6 +72,31 @@ class MinersTest(unittest.TestCase): ) self.assertEqual(miner_keys, keys) + def test_data_locations_match_signatures_command(self): + warnings.filterwarnings("ignore") + for miner_model in MINER_CLASSES.keys(): + for miner_api in MINER_CLASSES[miner_model].keys(): + miner = MINER_CLASSES[miner_model][miner_api]("127.0.0.1") + for data_point in asdict(miner.data_locations).values(): + with self.subTest( + msg=f"Test {data_point['cmd']} signature matches with model={miner_model}, api={miner_api}", + miner_model=miner_model, + miner_api=miner_api, + ): + func = getattr(miner, data_point["cmd"]) + signature = inspect.signature(func) + parameters = signature.parameters + param_names = list(parameters.keys()) + for arg in ["kwargs", "args"]: + try: + param_names.remove(arg) + except ValueError: + pass + self.assertEqual( + set(param_names), + set([k["name"] for k in data_point["kwargs"]]), + ) + if __name__ == "__main__": unittest.main() From 3234f7e06fd43ad1ef1c79c64ddc7f4e02d215e9 Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Thu, 11 Jan 2024 11:33:44 -0700 Subject: [PATCH 10/14] refactor: remove parameters from `get_{x}` functions and move them to `_get_{x}(**params)`. Add `miner.fw_str`, and `miner.raw_model`. Remove `model` from `get_data` exclude. Swap `fan_count` to `expected_fans`. --- pyasic/miners/backends/btminer.py | 89 ++++++++++-------------- pyasic/miners/backends/cgminer_avalon.py | 61 ++++++++-------- pyasic/miners/backends/hiveon.py | 6 +- 3 files changed, 66 insertions(+), 90 deletions(-) diff --git a/pyasic/miners/backends/btminer.py b/pyasic/miners/backends/btminer.py index de3ef732..f647077e 100644 --- a/pyasic/miners/backends/btminer.py +++ b/pyasic/miners/backends/btminer.py @@ -35,74 +35,73 @@ from pyasic.miners.base import ( BTMINER_DATA_LOC = DataLocations( **{ str(DataOptions.MAC): DataFunction( - "get_mac", + "_get_mac", [ RPCAPICommand("api_summary", "summary"), RPCAPICommand("api_get_miner_info", "get_miner_info"), ], ), - str(DataOptions.MODEL): DataFunction("get_model"), str(DataOptions.API_VERSION): DataFunction( - "get_api_ver", [RPCAPICommand("api_get_version", "get_version")] + "_get_api_ver", [RPCAPICommand("api_get_version", "get_version")] ), str(DataOptions.FW_VERSION): DataFunction( - "get_fw_ver", + "_get_fw_ver", [ RPCAPICommand("api_get_version", "get_version"), RPCAPICommand("api_summary", "summary"), ], ), str(DataOptions.HOSTNAME): DataFunction( - "get_hostname", [RPCAPICommand("api_get_miner_info", "get_miner_info")] + "_get_hostname", [RPCAPICommand("api_get_miner_info", "get_miner_info")] ), str(DataOptions.HASHRATE): DataFunction( - "get_hashrate", [RPCAPICommand("api_summary", "summary")] + "_get_hashrate", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "get_expected_hashrate", [RPCAPICommand("api_summary", "summary")] + "_get_expected_hashrate", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.HASHBOARDS): DataFunction( - "get_hashboards", [RPCAPICommand("api_devs", "devs")] + "_get_hashboards", [RPCAPICommand("api_devs", "devs")] ), str(DataOptions.ENVIRONMENT_TEMP): DataFunction( - "get_env_temp", [RPCAPICommand("api_summary", "summary")] + "_get_env_temp", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.WATTAGE): DataFunction( - "get_wattage", [RPCAPICommand("api_summary", "summary")] + "_get_wattage", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.WATTAGE_LIMIT): DataFunction( - "get_wattage_limit", [RPCAPICommand("api_summary", "summary")] + "_get_wattage_limit", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.FANS): DataFunction( - "get_fans", + "_get_fans", [ RPCAPICommand("api_summary", "summary"), RPCAPICommand("api_get_psu", "get_psu"), ], ), str(DataOptions.FAN_PSU): DataFunction( - "get_fan_psu", + "_get_fan_psu", [ RPCAPICommand("api_summary", "summary"), RPCAPICommand("api_get_psu", "get_psu"), ], ), str(DataOptions.ERRORS): DataFunction( - "get_errors", + "_get_errors", [ RPCAPICommand("api_get_error_code", "get_error_code"), RPCAPICommand("api_summary", "summary"), ], ), str(DataOptions.FAULT_LIGHT): DataFunction( - "get_fault_light", + "_get_fault_light", [RPCAPICommand("api_get_miner_info", "get_miner_info")], ), str(DataOptions.IS_MINING): DataFunction( - "is_mining", [RPCAPICommand("api_status", "status")] + "_is_mining", [RPCAPICommand("api_status", "status")] ), str(DataOptions.UPTIME): DataFunction( - "get_uptime", [RPCAPICommand("api_summary", "summary")] + "_get_uptime", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.CONFIG): DataFunction("get_config"), } @@ -243,7 +242,7 @@ class BTMiner(BaseMiner): else: cfg = MinerConfig() - is_mining = await self.is_mining(status) + is_mining = await self._is_mining(status) if not is_mining: cfg.mining_mode = MiningModeConfig.sleep() return cfg @@ -287,7 +286,7 @@ class BTMiner(BaseMiner): ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## - async def get_mac( + async def _get_mac( self, api_summary: dict = None, api_get_miner_info: dict = None ) -> Optional[str]: if not api_get_miner_info: @@ -316,21 +315,7 @@ class BTMiner(BaseMiner): except (KeyError, IndexError): pass - async def get_version( - self, api_get_version: dict = None, api_summary: dict = None - ) -> Tuple[Optional[str], Optional[str]]: - miner_version = namedtuple("MinerVersion", "api_ver fw_ver") - api_ver = await self.get_api_ver(api_get_version=api_get_version) - fw_ver = await self.get_fw_ver( - api_get_version=api_get_version, api_summary=api_summary - ) - return miner_version(api_ver, fw_ver) - - async def get_api_ver(self, api_get_version: dict = None) -> Optional[str]: - # Check to see if the version info is already cached - if self.api_ver: - return self.api_ver - + async def _get_api_ver(self, api_get_version: dict = None) -> Optional[str]: if not api_get_version: try: api_get_version = await self.api.get_version() @@ -353,13 +338,9 @@ class BTMiner(BaseMiner): return self.api_ver - async def get_fw_ver( + async def _get_fw_ver( self, api_get_version: dict = None, api_summary: dict = None ) -> Optional[str]: - # Check to see if the version info is already cached - if self.fw_ver: - return self.fw_ver - if not api_get_version: try: api_get_version = await self.api.get_version() @@ -392,7 +373,7 @@ class BTMiner(BaseMiner): return self.fw_ver - async def get_hostname(self, api_get_miner_info: dict = None) -> Optional[str]: + async def _get_hostname(self, api_get_miner_info: dict = None) -> Optional[str]: hostname = None if not api_get_miner_info: try: @@ -408,7 +389,7 @@ class BTMiner(BaseMiner): return hostname - async def get_hashrate(self, api_summary: dict = None) -> Optional[float]: + async def _get_hashrate(self, api_summary: dict = None) -> Optional[float]: # get hr from API if not api_summary: try: @@ -422,7 +403,7 @@ class BTMiner(BaseMiner): except (KeyError, IndexError): pass - async def get_hashboards(self, api_devs: dict = None) -> List[HashBoard]: + async def _get_hashboards(self, api_devs: dict = None) -> List[HashBoard]: hashboards = [ HashBoard(slot=i, expected_chips=self.expected_chips) for i in range(self.expected_hashboards) @@ -457,7 +438,7 @@ class BTMiner(BaseMiner): return hashboards - async def get_env_temp(self, api_summary: dict = None) -> Optional[float]: + async def _get_env_temp(self, api_summary: dict = None) -> Optional[float]: if not api_summary: try: api_summary = await self.api.summary() @@ -470,7 +451,7 @@ class BTMiner(BaseMiner): except (KeyError, IndexError): pass - async def get_wattage(self, api_summary: dict = None) -> Optional[int]: + async def _get_wattage(self, api_summary: dict = None) -> Optional[int]: if not api_summary: try: api_summary = await self.api.summary() @@ -484,7 +465,7 @@ class BTMiner(BaseMiner): except (KeyError, IndexError): pass - async def get_wattage_limit(self, api_summary: dict = None) -> Optional[int]: + async def _get_wattage_limit(self, api_summary: dict = None) -> Optional[int]: if not api_summary: try: api_summary = await self.api.summary() @@ -497,7 +478,7 @@ class BTMiner(BaseMiner): except (KeyError, IndexError): pass - async def get_fans( + async def _get_fans( self, api_summary: dict = None, api_get_psu: dict = None ) -> List[Fan]: if not api_summary: @@ -506,10 +487,10 @@ class BTMiner(BaseMiner): except APIError: pass - fans = [Fan() for _ in range(self.fan_count)] + fans = [Fan() for _ in range(self.expected_fans)] if api_summary: try: - if self.fan_count > 0: + if self.expected_fans > 0: fans = [ Fan(api_summary["SUMMARY"][0].get("Fan Speed In", 0)), Fan(api_summary["SUMMARY"][0].get("Fan Speed Out", 0)), @@ -519,7 +500,7 @@ class BTMiner(BaseMiner): return fans - async def get_fan_psu( + async def _get_fan_psu( self, api_summary: dict = None, api_get_psu: dict = None ) -> Optional[int]: if not api_summary: @@ -546,7 +527,7 @@ class BTMiner(BaseMiner): except (KeyError, TypeError): pass - async def get_errors( + async def _get_errors( self, api_summary: dict = None, api_get_error_code: dict = None ) -> List[MinerErrorData]: errors = [] @@ -581,7 +562,7 @@ class BTMiner(BaseMiner): return errors - async def get_expected_hashrate(self, api_summary: dict = None): + async def _get_expected_hashrate(self, api_summary: dict = None): if not api_summary: try: api_summary = await self.api.summary() @@ -596,7 +577,7 @@ class BTMiner(BaseMiner): except (KeyError, IndexError): pass - async def get_fault_light(self, api_get_miner_info: dict = None) -> bool: + async def _get_fault_light(self, api_get_miner_info: dict = None) -> bool: if not api_get_miner_info: try: api_get_miner_info = await self.api.get_miner_info() @@ -634,7 +615,7 @@ class BTMiner(BaseMiner): async def set_hostname(self, hostname: str): await self.api.set_hostname(hostname) - async def is_mining(self, api_status: dict = None) -> Optional[bool]: + async def _is_mining(self, api_status: dict = None) -> Optional[bool]: if not api_status: try: api_status = await self.api.status() @@ -653,7 +634,7 @@ class BTMiner(BaseMiner): except LookupError: pass - async def get_uptime(self, api_summary: dict = None) -> Optional[int]: + async def _get_uptime(self, api_summary: dict = None) -> Optional[int]: if not api_summary: try: api_summary = await self.api.summary() diff --git a/pyasic/miners/backends/cgminer_avalon.py b/pyasic/miners/backends/cgminer_avalon.py index 216087b5..51e34ff7 100644 --- a/pyasic/miners/backends/cgminer_avalon.py +++ b/pyasic/miners/backends/cgminer_avalon.py @@ -28,42 +28,41 @@ from pyasic.miners.base import DataFunction, DataLocations, DataOptions, RPCAPIC AVALON_DATA_LOC = DataLocations( **{ str(DataOptions.MAC): DataFunction( - "get_mac", [RPCAPICommand("api_version", "version")] + "_get_mac", [RPCAPICommand("api_version", "version")] ), - str(DataOptions.MODEL): DataFunction("get_model"), str(DataOptions.API_VERSION): DataFunction( - "get_api_ver", [RPCAPICommand("api_version", "version")] + "_get_api_ver", [RPCAPICommand("api_version", "version")] ), str(DataOptions.FW_VERSION): DataFunction( - "get_fw_ver", [RPCAPICommand("api_version", "version")] + "_get_fw_ver", [RPCAPICommand("api_version", "version")] ), - str(DataOptions.HOSTNAME): DataFunction("get_hostname"), + str(DataOptions.HOSTNAME): DataFunction("_get_hostname"), str(DataOptions.HASHRATE): DataFunction( - "get_hashrate", [RPCAPICommand("api_devs", "devs")] + "_get_hashrate", [RPCAPICommand("api_devs", "devs")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] + "_get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.HASHBOARDS): DataFunction( - "get_hashboards", [RPCAPICommand("api_stats", "stats")] + "_get_hashboards", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.ENVIRONMENT_TEMP): DataFunction( - "get_env_temp", [RPCAPICommand("api_stats", "stats")] + "_get_env_temp", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.WATTAGE): DataFunction("get_wattage"), + str(DataOptions.WATTAGE): DataFunction("_get_wattage"), str(DataOptions.WATTAGE_LIMIT): DataFunction( - "get_wattage_limit", [RPCAPICommand("api_stats", "stats")] + "_get_wattage_limit", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.FANS): DataFunction( - "get_fans", [RPCAPICommand("api_stats", "stats")] + "_get_fans", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), - str(DataOptions.ERRORS): DataFunction("get_errors"), + str(DataOptions.FAN_PSU): DataFunction("_get_fan_psu"), + str(DataOptions.ERRORS): DataFunction("_get_errors"), str(DataOptions.FAULT_LIGHT): DataFunction( - "get_fault_light", [RPCAPICommand("api_stats", "stats")] + "_get_fault_light", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.IS_MINING): DataFunction("is_mining"), - str(DataOptions.UPTIME): DataFunction("get_uptime"), + str(DataOptions.IS_MINING): DataFunction("_is_mining"), + str(DataOptions.UPTIME): DataFunction("_get_uptime"), str(DataOptions.CONFIG): DataFunction("get_config"), } ) @@ -174,7 +173,7 @@ class CGMinerAvalon(CGMiner): ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## - async def get_mac(self, api_version: dict = None) -> Optional[str]: + async def _get_mac(self, api_version: dict = None) -> Optional[str]: if not api_version: try: api_version = await self.api.version() @@ -192,7 +191,7 @@ class CGMinerAvalon(CGMiner): except (KeyError, ValueError): pass - async def get_hostname(self) -> Optional[str]: + async def _get_hostname(self) -> Optional[str]: return None # if not mac: # mac = await self.get_mac() @@ -200,7 +199,7 @@ class CGMinerAvalon(CGMiner): # if mac: # return f"Avalon{mac.replace(':', '')[-6:]}" - async def get_hashrate(self, api_devs: dict = None) -> Optional[float]: + async def _get_hashrate(self, api_devs: dict = None) -> Optional[float]: if not api_devs: try: api_devs = await self.api.devs() @@ -213,7 +212,7 @@ class CGMinerAvalon(CGMiner): except (KeyError, IndexError, ValueError, TypeError): pass - async def get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: + async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: hashboards = [ HashBoard(slot=i, expected_chips=self.expected_chips) for i in range(self.expected_hashboards) @@ -261,7 +260,7 @@ class CGMinerAvalon(CGMiner): return hashboards - async def get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]: + async def _get_expected_hashrate(self, api_stats: dict = None) -> Optional[float]: if not api_stats: try: api_stats = await self.api.stats() @@ -276,7 +275,7 @@ class CGMinerAvalon(CGMiner): except (IndexError, KeyError, ValueError, TypeError): pass - async def get_env_temp(self, api_stats: dict = None) -> Optional[float]: + async def _get_env_temp(self, api_stats: dict = None) -> Optional[float]: if not api_stats: try: api_stats = await self.api.stats() @@ -291,10 +290,10 @@ class CGMinerAvalon(CGMiner): except (IndexError, KeyError, ValueError, TypeError): pass - async def get_wattage(self) -> Optional[int]: + async def _get_wattage(self) -> Optional[int]: return None - async def get_wattage_limit(self, api_stats: dict = None) -> Optional[int]: + async def _get_wattage_limit(self, api_stats: dict = None) -> Optional[int]: if not api_stats: try: api_stats = await self.api.stats() @@ -309,14 +308,14 @@ class CGMinerAvalon(CGMiner): except (IndexError, KeyError, ValueError, TypeError): pass - async def get_fans(self, api_stats: dict = None) -> List[Fan]: + async def _get_fans(self, api_stats: dict = None) -> List[Fan]: if not api_stats: try: api_stats = await self.api.stats() except APIError: pass - fans_data = [Fan() for _ in range(self.fan_count)] + fans_data = [Fan() for _ in range(self.expected_fans)] if api_stats: try: unparsed_stats = api_stats["STATS"][0]["MM ID0"] @@ -324,17 +323,17 @@ class CGMinerAvalon(CGMiner): except LookupError: return fans_data - for fan in range(self.fan_count): + for fan in range(self.expected_fans): try: fans_data[fan].speed = int(parsed_stats[f"Fan{fan + 1}"]) except (IndexError, KeyError, ValueError, TypeError): pass return fans_data - async def get_errors(self) -> List[MinerErrorData]: + async def _get_errors(self) -> List[MinerErrorData]: return [] - async def get_fault_light(self, api_stats: dict = None) -> bool: # noqa + async def _get_fault_light(self, api_stats: dict = None) -> bool: # noqa if self.light: return self.light if not api_stats: @@ -363,7 +362,7 @@ class CGMinerAvalon(CGMiner): pass return False - async def is_mining(self, *args, **kwargs) -> Optional[bool]: + async def _is_mining(self, *args, **kwargs) -> Optional[bool]: return None async def get_uptime(self) -> Optional[int]: diff --git a/pyasic/miners/backends/hiveon.py b/pyasic/miners/backends/hiveon.py index 600eb41c..7cc6cfd7 100644 --- a/pyasic/miners/backends/hiveon.py +++ b/pyasic/miners/backends/hiveon.py @@ -68,14 +68,10 @@ class Hiveon(BMMiner): self.pwd = "admin" # static data self.api_type = "Hiveon" + self.fw_str = "Hive" # data gathering locations self.data_locations = HIVEON_DATA_LOC - async def get_model(self) -> Optional[str]: - if self.model is not None: - return self.model + " (Hiveon)" - return "? (Hiveon)" - async def get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: pass From 416ea2964b39f50404efa070e849f8a6f86ac020 Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Thu, 11 Jan 2024 15:00:48 -0700 Subject: [PATCH 11/14] refactor: optimize imports. --- pyasic/miners/backends/btminer.py | 4 +--- pyasic/miners/backends/cgminer_avalon.py | 1 - pyasic/miners/backends/epic.py | 5 ++--- pyasic/miners/backends/hiveon.py | 1 - 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/pyasic/miners/backends/btminer.py b/pyasic/miners/backends/btminer.py index f647077e..39fd3786 100644 --- a/pyasic/miners/backends/btminer.py +++ b/pyasic/miners/backends/btminer.py @@ -15,8 +15,7 @@ # ------------------------------------------------------------------------------ import logging -from collections import namedtuple -from typing import List, Optional, Tuple +from typing import List, Optional from pyasic.API.btminer import BTMinerAPI from pyasic.config import MinerConfig, MiningModeConfig @@ -29,7 +28,6 @@ from pyasic.miners.base import ( DataLocations, DataOptions, RPCAPICommand, - WebAPICommand, ) BTMINER_DATA_LOC = DataLocations( diff --git a/pyasic/miners/backends/cgminer_avalon.py b/pyasic/miners/backends/cgminer_avalon.py index 51e34ff7..cd78e6b1 100644 --- a/pyasic/miners/backends/cgminer_avalon.py +++ b/pyasic/miners/backends/cgminer_avalon.py @@ -14,7 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import logging import re from typing import List, Optional diff --git a/pyasic/miners/backends/epic.py b/pyasic/miners/backends/epic.py index 0914d0f8..83452263 100644 --- a/pyasic/miners/backends/epic.py +++ b/pyasic/miners/backends/epic.py @@ -14,10 +14,9 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -from typing import List, Optional, Tuple +from typing import List, Optional -from pyasic import MinerConfig -from pyasic.config import MinerConfig, MiningModeConfig +from pyasic.config import MinerConfig from pyasic.data import Fan, HashBoard from pyasic.data.error_codes import MinerErrorData, X19Error from pyasic.errors import APIError diff --git a/pyasic/miners/backends/hiveon.py b/pyasic/miners/backends/hiveon.py index 7cc6cfd7..40a32406 100644 --- a/pyasic/miners/backends/hiveon.py +++ b/pyasic/miners/backends/hiveon.py @@ -23,7 +23,6 @@ from pyasic.miners.base import DataFunction, DataLocations, DataOptions, RPCAPIC HIVEON_DATA_LOC = DataLocations( **{ str(DataOptions.MAC): DataFunction("get_mac"), - str(DataOptions.MODEL): DataFunction("get_model"), str(DataOptions.API_VERSION): DataFunction( "get_api_ver", [RPCAPICommand("api_version", "version")] ), From 194fb539a1d3e9695809cdaefaade7e237425e20 Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Thu, 11 Jan 2024 15:20:33 -0700 Subject: [PATCH 12/14] refactor: swap (KeyError, IndexError) for LookupError. --- pyasic/miners/antminer/hiveon/X9/T9.py | 8 +++---- pyasic/miners/backends/bosminer.py | 28 ++++++++++++------------ pyasic/miners/backends/btminer.py | 22 +++++++++---------- pyasic/miners/backends/cgminer_avalon.py | 14 ++++++------ pyasic/miners/backends/epic.py | 2 +- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/pyasic/miners/antminer/hiveon/X9/T9.py b/pyasic/miners/antminer/hiveon/X9/T9.py index f7194624..d9dd4832 100644 --- a/pyasic/miners/antminer/hiveon/X9/T9.py +++ b/pyasic/miners/antminer/hiveon/X9/T9.py @@ -69,14 +69,14 @@ class HiveonT9(Hiveon, T9): hashboards[board].chip_temp = api_stats["STATS"][1][ f"temp2_{chipset}" ] - except (KeyError, IndexError): + except LookupError: pass else: hashboards[board].missing = False try: hashrate += api_stats["STATS"][1][f"chain_rate{chipset}"] chips += api_stats["STATS"][1][f"chain_acn{chipset}"] - except (KeyError, IndexError): + except LookupError: pass hashboards[board].hashrate = round(hashrate / 1000, 2) hashboards[board].chips = chips @@ -94,7 +94,7 @@ class HiveonT9(Hiveon, T9): boards = api_stats.get("STATS") try: wattage_raw = boards[1]["chain_power"] - except (KeyError, IndexError): + except LookupError: pass else: # parse wattage position out of raw data @@ -119,7 +119,7 @@ class HiveonT9(Hiveon, T9): env_temp = api_stats["STATS"][1][f"temp3_{chipset}"] if not env_temp == 0: env_temp_list.append(int(env_temp)) - except (KeyError, IndexError): + except LookupError: pass if not env_temp_list == []: diff --git a/pyasic/miners/backends/bosminer.py b/pyasic/miners/backends/bosminer.py index 7307233d..84df4a05 100644 --- a/pyasic/miners/backends/bosminer.py +++ b/pyasic/miners/backends/bosminer.py @@ -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]: diff --git a/pyasic/miners/backends/btminer.py b/pyasic/miners/backends/btminer.py index 39fd3786..543c8419 100644 --- a/pyasic/miners/backends/btminer.py +++ b/pyasic/miners/backends/btminer.py @@ -310,7 +310,7 @@ class BTMiner(BaseMiner): try: mac = api_summary["SUMMARY"][0]["MAC"] return str(mac).upper() - except (KeyError, IndexError): + except LookupError: pass async def _get_api_ver(self, api_get_version: dict = None) -> Optional[str]: @@ -366,7 +366,7 @@ class BTMiner(BaseMiner): self.fw_ver = api_summary["SUMMARY"][0]["Firmware Version"].replace( "'", "" ) - except (KeyError, IndexError): + except LookupError: pass return self.fw_ver @@ -398,7 +398,7 @@ class BTMiner(BaseMiner): if api_summary: try: return round(float(api_summary["SUMMARY"][0]["MHS 1m"] / 1000000), 2) - except (KeyError, IndexError): + except LookupError: pass async def _get_hashboards(self, api_devs: dict = None) -> List[HashBoard]: @@ -431,7 +431,7 @@ class BTMiner(BaseMiner): hashboards[board["ASC"]].chips = board["Effective Chips"] hashboards[board["ASC"]].serial_number = board["PCB SN"] hashboards[board["ASC"]].missing = False - except (KeyError, IndexError): + except LookupError: pass return hashboards @@ -446,7 +446,7 @@ class BTMiner(BaseMiner): if api_summary: try: return api_summary["SUMMARY"][0]["Env Temp"] - except (KeyError, IndexError): + except LookupError: pass async def _get_wattage(self, api_summary: dict = None) -> Optional[int]: @@ -460,7 +460,7 @@ class BTMiner(BaseMiner): try: wattage = api_summary["SUMMARY"][0]["Power"] return wattage if not wattage == -1 else None - except (KeyError, IndexError): + except LookupError: pass async def _get_wattage_limit(self, api_summary: dict = None) -> Optional[int]: @@ -473,7 +473,7 @@ class BTMiner(BaseMiner): if api_summary: try: return api_summary["SUMMARY"][0]["Power Limit"] - except (KeyError, IndexError): + except LookupError: pass async def _get_fans( @@ -493,7 +493,7 @@ class BTMiner(BaseMiner): Fan(api_summary["SUMMARY"][0].get("Fan Speed In", 0)), Fan(api_summary["SUMMARY"][0].get("Fan Speed Out", 0)), ] - except (KeyError, IndexError): + except LookupError: pass return fans @@ -510,7 +510,7 @@ class BTMiner(BaseMiner): if api_summary: try: return int(api_summary["SUMMARY"][0]["Power Fanspeed"]) - except (KeyError, IndexError): + except LookupError: pass if not api_get_psu: @@ -555,7 +555,7 @@ class BTMiner(BaseMiner): err = api_summary["SUMMARY"][0].get(f"Error Code {i}") if err: errors.append(WhatsminerError(error_code=err)) - except (KeyError, IndexError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass return errors @@ -572,7 +572,7 @@ class BTMiner(BaseMiner): expected_hashrate = api_summary["SUMMARY"][0]["Factory GHS"] if expected_hashrate: return round(expected_hashrate / 1000, 2) - except (KeyError, IndexError): + except LookupError: pass async def _get_fault_light(self, api_get_miner_info: dict = None) -> bool: diff --git a/pyasic/miners/backends/cgminer_avalon.py b/pyasic/miners/backends/cgminer_avalon.py index cd78e6b1..893ceaa1 100644 --- a/pyasic/miners/backends/cgminer_avalon.py +++ b/pyasic/miners/backends/cgminer_avalon.py @@ -208,7 +208,7 @@ class CGMinerAvalon(CGMiner): if api_devs: try: return round(float(api_devs["DEVS"][0]["MHS 1m"] / 1000000), 2) - except (KeyError, IndexError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: @@ -227,7 +227,7 @@ class CGMinerAvalon(CGMiner): try: unparsed_stats = api_stats["STATS"][0]["MM ID0"] parsed_stats = self.parse_stats(unparsed_stats) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): return hashboards for board in range(self.expected_hashboards): @@ -271,7 +271,7 @@ class CGMinerAvalon(CGMiner): unparsed_stats = api_stats["STATS"][0]["MM ID0"] parsed_stats = self.parse_stats(unparsed_stats) return round(float(parsed_stats["GHSmm"]) / 1000, 2) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass async def _get_env_temp(self, api_stats: dict = None) -> Optional[float]: @@ -286,7 +286,7 @@ class CGMinerAvalon(CGMiner): unparsed_stats = api_stats["STATS"][0]["MM ID0"] parsed_stats = self.parse_stats(unparsed_stats) return float(parsed_stats["Temp"]) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass async def _get_wattage(self) -> Optional[int]: @@ -304,7 +304,7 @@ class CGMinerAvalon(CGMiner): unparsed_stats = api_stats["STATS"][0]["MM ID0"] parsed_stats = self.parse_stats(unparsed_stats) return int(parsed_stats["MPO"]) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass async def _get_fans(self, api_stats: dict = None) -> List[Fan]: @@ -325,7 +325,7 @@ class CGMinerAvalon(CGMiner): for fan in range(self.expected_fans): try: fans_data[fan].speed = int(parsed_stats[f"Fan{fan + 1}"]) - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass return fans_data @@ -347,7 +347,7 @@ class CGMinerAvalon(CGMiner): parsed_stats = self.parse_stats(unparsed_stats) led = int(parsed_stats["Led"]) return True if led == 1 else False - except (IndexError, KeyError, ValueError, TypeError): + except (LookupError, ValueError, TypeError): pass try: diff --git a/pyasic/miners/backends/epic.py b/pyasic/miners/backends/epic.py index 83452263..a4519133 100644 --- a/pyasic/miners/backends/epic.py +++ b/pyasic/miners/backends/epic.py @@ -216,7 +216,7 @@ class ePIC(BaseMiner): hashrate += hb["Hashrate"][0] / ideal return round(float(float(hashrate / 1000000)), 2) - except (IndexError, KeyError, ValueError, TypeError) as e: + except (LookupError, ValueError, TypeError) as e: logger.error(e) pass From e7d30aad84aba02cb8c589948edac63d10bae7f4 Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Mon, 15 Jan 2024 10:29:39 -0700 Subject: [PATCH 13/14] bug: make sure all data locations are accurate. --- pyasic/miners/antminer/hiveon/X9/T9.py | 8 ++-- pyasic/miners/backends/cgminer_avalon.py | 2 +- pyasic/miners/backends/hiveon.py | 38 +++++++++---------- pyasic/miners/backends/innosilicon.py | 47 ++++++++++++------------ tests/__init__.py | 2 + tests/miners_tests/__init__.py | 1 + 6 files changed, 50 insertions(+), 48 deletions(-) diff --git a/pyasic/miners/antminer/hiveon/X9/T9.py b/pyasic/miners/antminer/hiveon/X9/T9.py index d9dd4832..3f806626 100644 --- a/pyasic/miners/antminer/hiveon/X9/T9.py +++ b/pyasic/miners/antminer/hiveon/X9/T9.py @@ -30,7 +30,7 @@ class HiveonT9(Hiveon, T9): ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## - async def get_mac(self): + async def _get_mac(self): try: mac = ( (await self.send_ssh_command("cat /sys/class/net/eth0/address")) @@ -41,7 +41,7 @@ class HiveonT9(Hiveon, T9): except (TypeError, ValueError, asyncssh.Error, OSError, AttributeError): pass - async def get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: + async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: hashboards = [ HashBoard(slot=board, expected_chips=self.expected_chips) for board in range(self.expected_hashboards) @@ -83,7 +83,7 @@ class HiveonT9(Hiveon, T9): return hashboards - async def get_wattage(self, api_stats: dict = None) -> Optional[int]: + async def _get_wattage(self, api_stats: dict = None) -> Optional[int]: if not api_stats: try: api_stats = await self.api.stats() @@ -100,7 +100,7 @@ class HiveonT9(Hiveon, T9): # parse wattage position out of raw data return round(float(wattage_raw.split(" ")[0])) - async def get_env_temp(self, api_stats: dict = None) -> Optional[float]: + async def _get_env_temp(self, api_stats: dict = None) -> Optional[float]: env_temp_list = [] board_map = { 0: [2, 9, 10], diff --git a/pyasic/miners/backends/cgminer_avalon.py b/pyasic/miners/backends/cgminer_avalon.py index 893ceaa1..125472f8 100644 --- a/pyasic/miners/backends/cgminer_avalon.py +++ b/pyasic/miners/backends/cgminer_avalon.py @@ -364,5 +364,5 @@ class CGMinerAvalon(CGMiner): async def _is_mining(self, *args, **kwargs) -> Optional[bool]: return None - async def get_uptime(self) -> Optional[int]: + async def _get_uptime(self) -> Optional[int]: return None diff --git a/pyasic/miners/backends/hiveon.py b/pyasic/miners/backends/hiveon.py index 40a32406..22a6a48a 100644 --- a/pyasic/miners/backends/hiveon.py +++ b/pyasic/miners/backends/hiveon.py @@ -22,39 +22,39 @@ from pyasic.miners.base import DataFunction, DataLocations, DataOptions, RPCAPIC HIVEON_DATA_LOC = DataLocations( **{ - str(DataOptions.MAC): DataFunction("get_mac"), + str(DataOptions.MAC): DataFunction("_get_mac"), str(DataOptions.API_VERSION): DataFunction( - "get_api_ver", [RPCAPICommand("api_version", "version")] + "_get_api_ver", [RPCAPICommand("api_version", "version")] ), str(DataOptions.FW_VERSION): DataFunction( - "get_fw_ver", [RPCAPICommand("api_version", "version")] + "_get_fw_ver", [RPCAPICommand("api_version", "version")] ), - str(DataOptions.HOSTNAME): DataFunction("get_hostname"), + str(DataOptions.HOSTNAME): DataFunction("_get_hostname"), str(DataOptions.HASHRATE): DataFunction( - "get_hashrate", [RPCAPICommand("api_summary", "summary")] + "_get_hashrate", [RPCAPICommand("api_summary", "summary")] ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] + "_get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.HASHBOARDS): DataFunction( - "get_hashboards", [RPCAPICommand("api_stats", "stats")] + "_get_hashboards", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.ENVIRONMENT_TEMP): DataFunction( - "get_env_temp", [RPCAPICommand("api_stats", "stats")] + "_get_env_temp", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.WATTAGE): DataFunction( - "get_wattage", [RPCAPICommand("api_stats", "stats")] + "_get_wattage", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.WATTAGE_LIMIT): DataFunction("get_wattage_limit"), + str(DataOptions.WATTAGE_LIMIT): DataFunction("_get_wattage_limit"), str(DataOptions.FANS): DataFunction( - "get_fans", [RPCAPICommand("api_stats", "stats")] + "_get_fans", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), - str(DataOptions.ERRORS): DataFunction("get_errors"), - str(DataOptions.FAULT_LIGHT): DataFunction("get_fault_light"), - str(DataOptions.IS_MINING): DataFunction("is_mining"), + str(DataOptions.FAN_PSU): DataFunction("_get_fan_psu"), + str(DataOptions.ERRORS): DataFunction("_get_errors"), + str(DataOptions.FAULT_LIGHT): DataFunction("_get_fault_light"), + str(DataOptions.IS_MINING): DataFunction("_is_mining"), str(DataOptions.UPTIME): DataFunction( - "get_uptime", [RPCAPICommand("api_stats", "stats")] + "_get_uptime", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.CONFIG): DataFunction("get_config"), } @@ -71,11 +71,11 @@ class Hiveon(BMMiner): # data gathering locations self.data_locations = HIVEON_DATA_LOC - async def get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: + async def _get_hashboards(self, api_stats: dict = None) -> List[HashBoard]: pass - async def get_wattage(self, api_stats: dict = None) -> Optional[int]: + async def _get_wattage(self, api_stats: dict = None) -> Optional[int]: pass - async def get_env_temp(self, api_stats: dict = None) -> Optional[float]: + async def _get_env_temp(self, api_stats: dict = None) -> Optional[float]: pass diff --git a/pyasic/miners/backends/innosilicon.py b/pyasic/miners/backends/innosilicon.py index 192bfeb6..135c908e 100644 --- a/pyasic/miners/backends/innosilicon.py +++ b/pyasic/miners/backends/innosilicon.py @@ -33,68 +33,67 @@ from pyasic.web.innosilicon import InnosiliconWebAPI INNOSILICON_DATA_LOC = DataLocations( **{ str(DataOptions.MAC): DataFunction( - "get_mac", + "_get_mac", [ WebAPICommand("web_get_all", "getAll"), WebAPICommand("web_overview", "overview"), ], ), - str(DataOptions.MODEL): DataFunction("get_model"), str(DataOptions.API_VERSION): DataFunction( - "get_api_ver", [RPCAPICommand("api_version", "version")] + "_get_api_ver", [RPCAPICommand("api_version", "version")] ), str(DataOptions.FW_VERSION): DataFunction( - "get_fw_ver", [RPCAPICommand("api_version", "version")] + "_get_fw_ver", [RPCAPICommand("api_version", "version")] ), - str(DataOptions.HOSTNAME): DataFunction("get_hostname"), + str(DataOptions.HOSTNAME): DataFunction("_get_hostname"), str(DataOptions.HASHRATE): DataFunction( - "get_hashrate", + "_get_hashrate", [ RPCAPICommand("api_summary", "summary"), WebAPICommand("web_get_all", "getAll"), ], ), str(DataOptions.EXPECTED_HASHRATE): DataFunction( - "get_expected_hashrate", + "_get_expected_hashrate", ), str(DataOptions.HASHBOARDS): DataFunction( - "get_hashboards", + "_get_hashboards", [ RPCAPICommand("api_stats", "stats"), WebAPICommand("web_get_all", "getAll"), ], ), - str(DataOptions.ENVIRONMENT_TEMP): DataFunction("get_env_temp"), + str(DataOptions.ENVIRONMENT_TEMP): DataFunction("_get_env_temp"), str(DataOptions.WATTAGE): DataFunction( - "get_wattage", + "_get_wattage", [ WebAPICommand("web_get_all", "getAll"), RPCAPICommand("api_stats", "stats"), ], ), str(DataOptions.WATTAGE_LIMIT): DataFunction( - "get_wattage_limit", + "_get_wattage_limit", [ WebAPICommand("web_get_all", "getAll"), ], ), str(DataOptions.FANS): DataFunction( - "get_fans", + "_get_fans", [ WebAPICommand("web_get_all", "getAll"), ], ), - str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), + str(DataOptions.FAN_PSU): DataFunction("_get_fan_psu"), str(DataOptions.ERRORS): DataFunction( - "get_errors", + "_get_errors", [ WebAPICommand("web_get_error_detail", "getErrorDetail"), ], ), - str(DataOptions.FAULT_LIGHT): DataFunction("get_fault_light"), + str(DataOptions.FAULT_LIGHT): DataFunction("_get_fault_light"), str(DataOptions.IS_MINING): DataFunction("is_mining"), str(DataOptions.UPTIME): DataFunction( - "get_uptime", [RPCAPICommand("api_stats", "stats")] + "_get_uptime", [RPCAPICommand("api_stats", "stats")] ), str(DataOptions.CONFIG): DataFunction("get_config"), } @@ -176,7 +175,7 @@ class Innosilicon(CGMiner): ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## - async def get_mac( + async def _get_mac( self, web_get_all: dict = None, web_overview: dict = None ) -> Optional[str]: if web_get_all: @@ -202,7 +201,7 @@ class Innosilicon(CGMiner): except KeyError: pass - async def get_hashrate( + async def _get_hashrate( self, api_summary: dict = None, web_get_all: dict = None ) -> Optional[float]: if web_get_all: @@ -234,7 +233,7 @@ class Innosilicon(CGMiner): except (KeyError, IndexError): pass - async def get_hashboards( + async def _get_hashboards( self, api_stats: dict = None, web_get_all: dict = None ) -> List[HashBoard]: if web_get_all: @@ -292,7 +291,7 @@ class Innosilicon(CGMiner): return hashboards - async def get_wattage( + async def _get_wattage( self, web_get_all: dict = None, api_stats: dict = None ) -> Optional[int]: if web_get_all: @@ -329,7 +328,7 @@ class Innosilicon(CGMiner): wattage = int(wattage) return wattage - async def get_fans(self, web_get_all: dict = None) -> List[Fan]: + async def _get_fans(self, web_get_all: dict = None) -> List[Fan]: if web_get_all: web_get_all = web_get_all["all"] @@ -354,7 +353,7 @@ class Innosilicon(CGMiner): return fans - async def get_errors( + async def _get_errors( self, web_get_error_detail: dict = None ) -> List[MinerErrorData]: errors = [] @@ -377,7 +376,7 @@ class Innosilicon(CGMiner): errors.append(InnosiliconError(error_code=err)) return errors - async def get_wattage_limit(self, web_get_all: dict = None) -> Optional[int]: + async def _get_wattage_limit(self, web_get_all: dict = None) -> Optional[int]: if web_get_all: web_get_all = web_get_all["all"] @@ -400,5 +399,5 @@ class Innosilicon(CGMiner): limit = 1250 + (250 * level) return limit - async def get_expected_hashrate(self) -> Optional[float]: + async def _get_expected_hashrate(self) -> Optional[float]: pass diff --git a/tests/__init__.py b/tests/__init__.py index 23a60f58..0c5048c4 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -17,6 +17,8 @@ import unittest from tests.api_tests import * +from tests.config_tests import TestConfig +from tests.miners_tests import MinersTest from tests.network_tests import NetworkTest if __name__ == "__main__": diff --git a/tests/miners_tests/__init__.py b/tests/miners_tests/__init__.py index e0e700a6..104235ae 100644 --- a/tests/miners_tests/__init__.py +++ b/tests/miners_tests/__init__.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ +import inspect import unittest import warnings from dataclasses import asdict From b56e94ce8c816ea53aaef2158327acf5836cb57c Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Mon, 15 Jan 2024 10:35:15 -0700 Subject: [PATCH 14/14] bug: add more tests and finish renaming methods. --- pyasic/miners/backends/antminer.py | 2 +- pyasic/miners/backends/innosilicon.py | 2 +- tests/miners_tests/__init__.py | 22 +++++++++++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pyasic/miners/backends/antminer.py b/pyasic/miners/backends/antminer.py index 7e7d5c33..6dcbeedc 100644 --- a/pyasic/miners/backends/antminer.py +++ b/pyasic/miners/backends/antminer.py @@ -58,7 +58,7 @@ ANTMINER_MODERN_DATA_LOC = DataLocations( str(DataOptions.FANS): DataFunction( "_get_fans", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.FAN_PSU): DataFunction("get_fan_psu"), + str(DataOptions.FAN_PSU): DataFunction("_get_fan_psu"), str(DataOptions.ERRORS): DataFunction( "_get_errors", [WebAPICommand("web_summary", "summary")] ), diff --git a/pyasic/miners/backends/innosilicon.py b/pyasic/miners/backends/innosilicon.py index 135c908e..9e85525a 100644 --- a/pyasic/miners/backends/innosilicon.py +++ b/pyasic/miners/backends/innosilicon.py @@ -91,7 +91,7 @@ INNOSILICON_DATA_LOC = DataLocations( ], ), str(DataOptions.FAULT_LIGHT): DataFunction("_get_fault_light"), - str(DataOptions.IS_MINING): DataFunction("is_mining"), + str(DataOptions.IS_MINING): DataFunction("_is_mining"), str(DataOptions.UPTIME): DataFunction( "_get_uptime", [RPCAPICommand("api_stats", "stats")] ), diff --git a/tests/miners_tests/__init__.py b/tests/miners_tests/__init__.py index 104235ae..c1c4cfaa 100644 --- a/tests/miners_tests/__init__.py +++ b/tests/miners_tests/__init__.py @@ -28,7 +28,7 @@ class MinersTest(unittest.TestCase): for miner_model in MINER_CLASSES.keys(): for miner_api in MINER_CLASSES[miner_model].keys(): with self.subTest( - msg=f"Creation of miner using model={miner_model}, api={miner_api}", + msg=f"Test creation of miner", miner_model=miner_model, miner_api=miner_api, ): @@ -63,7 +63,7 @@ class MinersTest(unittest.TestCase): for miner_model in MINER_CLASSES.keys(): for miner_api in MINER_CLASSES[miner_model].keys(): with self.subTest( - msg=f"Data map key check of miner using model={miner_model}, api={miner_api}", + msg=f"Data map key check", miner_model=miner_model, miner_api=miner_api, ): @@ -80,7 +80,7 @@ class MinersTest(unittest.TestCase): miner = MINER_CLASSES[miner_model][miner_api]("127.0.0.1") for data_point in asdict(miner.data_locations).values(): with self.subTest( - msg=f"Test {data_point['cmd']} signature matches with model={miner_model}, api={miner_api}", + msg=f"Test {data_point['cmd']} signature matches", miner_model=miner_model, miner_api=miner_api, ): @@ -98,6 +98,22 @@ class MinersTest(unittest.TestCase): set([k["name"] for k in data_point["kwargs"]]), ) + def test_data_locations_use_private_funcs(self): + warnings.filterwarnings("ignore") + for miner_model in MINER_CLASSES.keys(): + for miner_api in MINER_CLASSES[miner_model].keys(): + miner = MINER_CLASSES[miner_model][miner_api]("127.0.0.1") + for data_point in asdict(miner.data_locations).values(): + with self.subTest( + msg=f"Test {data_point['cmd']} is private", + miner_model=miner_model, + miner_api=miner_api, + ): + self.assertTrue( + data_point["cmd"].startswith("_") + or data_point["cmd"] == "get_config" + ) + if __name__ == "__main__": unittest.main()