bug: fix some issues with rpc renaming.
This commit is contained in:
@@ -68,7 +68,7 @@ class BFGMiner(BaseMiner):
|
||||
except APIError:
|
||||
return self.config
|
||||
|
||||
self.config = MinerConfig.from_rpc(pools)
|
||||
self.config = MinerConfig.from_api(pools)
|
||||
return self.config
|
||||
|
||||
##################################################
|
||||
@@ -84,11 +84,11 @@ class BFGMiner(BaseMiner):
|
||||
|
||||
if rpc_version is not None:
|
||||
try:
|
||||
self.rpc_ver = rpc_version["VERSION"][0]["API"]
|
||||
self.api_ver = rpc_version["VERSION"][0]["API"]
|
||||
except LookupError:
|
||||
pass
|
||||
|
||||
return self.rpc_ver
|
||||
return self.api_ver
|
||||
|
||||
async def _get_fw_ver(self, rpc_version: dict = None) -> Optional[str]:
|
||||
if rpc_version is None:
|
||||
|
||||
@@ -72,7 +72,7 @@ class BMMiner(BaseMiner):
|
||||
except APIError:
|
||||
return self.config
|
||||
|
||||
self.config = MinerConfig.from_rpc(pools)
|
||||
self.config = MinerConfig.from_api(pools)
|
||||
return self.config
|
||||
|
||||
##################################################
|
||||
@@ -88,11 +88,11 @@ class BMMiner(BaseMiner):
|
||||
|
||||
if rpc_version is not None:
|
||||
try:
|
||||
self.rpc_ver = rpc_version["VERSION"][0]["API"]
|
||||
self.api_ver = rpc_version["VERSION"][0]["API"]
|
||||
except LookupError:
|
||||
pass
|
||||
|
||||
return self.rpc_ver
|
||||
return self.api_ver
|
||||
|
||||
async def _get_fw_ver(self, rpc_version: dict = None) -> Optional[str]:
|
||||
if rpc_version is None:
|
||||
|
||||
@@ -305,10 +305,10 @@ class BOSMiner(BaseMiner):
|
||||
rpc_ver = rpc_version["VERSION"][0]["API"]
|
||||
except LookupError:
|
||||
rpc_ver = None
|
||||
self.rpc_ver = rpc_ver
|
||||
self.rpc.rpc_ver = self.rpc_ver
|
||||
self.api_ver = rpc_ver
|
||||
self.rpc.rpc_ver = self.api_ver
|
||||
|
||||
return self.rpc_ver
|
||||
return self.api_ver
|
||||
|
||||
async def _get_fw_ver(self, web_bos_info: dict = None) -> Optional[str]:
|
||||
if web_bos_info is None:
|
||||
@@ -731,10 +731,10 @@ class BOSer(BaseMiner):
|
||||
rpc_ver = rpc_version["VERSION"][0]["API"]
|
||||
except LookupError:
|
||||
rpc_ver = None
|
||||
self.rpc_ver = rpc_ver
|
||||
self.rpc.rpc_ver = self.rpc_ver
|
||||
self.api_ver = rpc_ver
|
||||
self.rpc.rpc_ver = self.api_ver
|
||||
|
||||
return self.rpc_ver
|
||||
return self.api_ver
|
||||
|
||||
async def _get_fw_ver(self, grpc_miner_details: dict = None) -> Optional[str]:
|
||||
if grpc_miner_details is None:
|
||||
|
||||
@@ -234,7 +234,7 @@ class BTMiner(BaseMiner):
|
||||
pass
|
||||
|
||||
if pools is not None:
|
||||
cfg = MinerConfig.from_rpc(pools)
|
||||
cfg = MinerConfig.from_api(pools)
|
||||
else:
|
||||
cfg = MinerConfig()
|
||||
|
||||
@@ -325,14 +325,14 @@ class BTMiner(BaseMiner):
|
||||
rpc_ver = rpc_get_version["Msg"]
|
||||
if not isinstance(rpc_ver, str):
|
||||
rpc_ver = rpc_ver["rpc_ver"]
|
||||
self.rpc_ver = rpc_ver.replace("whatsminer v", "")
|
||||
self.api_ver = rpc_ver.replace("whatsminer v", "")
|
||||
except (KeyError, TypeError):
|
||||
pass
|
||||
else:
|
||||
self.rpc.rpc_ver = self.rpc_ver
|
||||
return self.rpc_ver
|
||||
self.rpc.rpc_ver = self.api_ver
|
||||
return self.api_ver
|
||||
|
||||
return self.rpc_ver
|
||||
return self.api_ver
|
||||
|
||||
async def _get_fw_ver(
|
||||
self, rpc_get_version: dict = None, rpc_summary: dict = None
|
||||
|
||||
@@ -71,7 +71,7 @@ class CGMiner(BaseMiner):
|
||||
except APIError:
|
||||
return self.config
|
||||
|
||||
self.config = MinerConfig.from_rpc(pools)
|
||||
self.config = MinerConfig.from_api(pools)
|
||||
return self.config
|
||||
|
||||
##################################################
|
||||
@@ -87,11 +87,11 @@ class CGMiner(BaseMiner):
|
||||
|
||||
if rpc_version is not None:
|
||||
try:
|
||||
self.rpc_ver = rpc_version["VERSION"][0]["API"]
|
||||
self.api_ver = rpc_version["VERSION"][0]["API"]
|
||||
except LookupError:
|
||||
pass
|
||||
|
||||
return self.rpc_ver
|
||||
return self.api_ver
|
||||
|
||||
async def _get_fw_ver(self, rpc_version: dict = None) -> Optional[str]:
|
||||
if rpc_version is None:
|
||||
|
||||
@@ -107,3 +107,4 @@ def validate_command_output(data: dict) -> tuple[bool, str | None]:
|
||||
if data[key][0]["STATUS"][0]["STATUS"] not in ["S", "I"]:
|
||||
# this is an error
|
||||
return False, f"{key}: " + data[key][0]["STATUS"][0]["Msg"]
|
||||
return True, None
|
||||
|
||||
@@ -90,7 +90,7 @@ class BaseMinerRPCAPI:
|
||||
if not validation[0]:
|
||||
if not ignore_errors:
|
||||
# validate the command succeeded
|
||||
raise APIError(validation[1])
|
||||
raise APIError(f"{command}: {validation[1]}")
|
||||
if allow_warning:
|
||||
logging.warning(
|
||||
f"{self.ip}: API Command Error: {command}: {validation[1]}"
|
||||
|
||||
Reference in New Issue
Block a user