fixed json decoding error, now raises APIError, and sorted IP List same as data list

This commit is contained in:
UpstreamData
2021-10-26 11:40:17 -06:00
parent f4500b88ac
commit edbd1bbe94
2 changed files with 8 additions and 1 deletions

View File

@@ -71,7 +71,10 @@ class BaseMinerAPI:
except Exception as e:
print(e)
try:
data = json.loads(data.decode('utf-8')[:-1])
except json.decoder.JSONDecodeError:
raise APIError(f"Decode Error: {data}")
# close the connection
writer.close()

View File

@@ -247,6 +247,9 @@ async def sort_data(index: int or str):
new_data_list = sorted(new_list, key=lambda x: float(x[indexes[index]]))
else:
new_data_list = sorted(new_list, key=itemgetter(indexes[index]))
new_ip_list = []
for item in new_data_list:
new_ip_list.append(item[indexes['ip']])
new_data_list = [str(item[indexes['ip']]) + " | "
+ item[1] + " | "
+ item[indexes['hr']] + " TH/s | "
@@ -255,6 +258,7 @@ async def sort_data(index: int or str):
for item in new_data_list]
window["hr_list"].update(disabled=False)
window["hr_list"].update(new_data_list)
window['ip_list'].update(new_ip_list)
window["hr_list"].update(disabled=True)
await update_ui_with_data("status", "")