fixed a bug with multicommand on S19 where it doesnt work with the '+'.join(*commands)
This commit is contained in:
@@ -36,6 +36,7 @@ class BaseMinerAPI:
|
||||
commands = [*commands]
|
||||
for item in commands:
|
||||
if item not in self.get_commands():
|
||||
print(f"Removing command: {item}")
|
||||
commands.remove(item)
|
||||
command = "+".join(commands)
|
||||
return await self.send_command(command)
|
||||
@@ -83,6 +84,22 @@ class BaseMinerAPI:
|
||||
writer.close()
|
||||
await writer.wait_closed()
|
||||
|
||||
if not self.validate_command_output(data):
|
||||
try:
|
||||
data = {}
|
||||
for cmd in command.split("+"):
|
||||
data[cmd] = []
|
||||
data[cmd].append(await self.send_command(cmd))
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
# check again after second try
|
||||
if not self.validate_command_output(data):
|
||||
raise APIError(data["STATUS"][0]["Msg"])
|
||||
|
||||
return data
|
||||
|
||||
def validate_command_output(self, data):
|
||||
# check if the data returned is correct or an error
|
||||
# if status isn't a key, it is a multicommand
|
||||
if "STATUS" not in data.keys():
|
||||
@@ -93,12 +110,11 @@ class BaseMinerAPI:
|
||||
if "STATUS" in data.keys():
|
||||
if data[key][0]["STATUS"][0]["STATUS"] not in ["S", "I"]:
|
||||
# this is an error
|
||||
raise APIError(data["STATUS"][0]["Msg"])
|
||||
return False
|
||||
else:
|
||||
# make sure the command succeeded
|
||||
if data["STATUS"][0]["STATUS"] not in ("S", "I"):
|
||||
# this is an error
|
||||
raise APIError(data["STATUS"][0]["Msg"])
|
||||
|
||||
# return the data
|
||||
return data
|
||||
if data["STATUS"][0]["STATUS"] not in ("S", "I"):
|
||||
return False
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user