added tags to board util bad miners, so when sorting they stay the same
This commit is contained in:
@@ -145,19 +145,19 @@ async def scan_and_get_data(network):
|
||||
if 0 in data_point["data"].keys():
|
||||
board_left = " ".join([chain["chip_status"] for chain in data_point["data"][0]]).replace("o", "•")
|
||||
else:
|
||||
row_colors.append((ip_table_index, "white", "red"))
|
||||
row_colors.append((ip_table_index, "bad"))
|
||||
if 1 in data_point["data"].keys():
|
||||
board_center = " ".join([chain["chip_status"] for chain in data_point["data"][1]]).replace("o", "•")
|
||||
else:
|
||||
row_colors.append((ip_table_index, "white", "red"))
|
||||
row_colors.append((ip_table_index, "bad"))
|
||||
if 2 in data_point["data"].keys():
|
||||
board_right = " ".join([chain["chip_status"] for chain in data_point["data"][2]]).replace("o", "•")
|
||||
else:
|
||||
row_colors.append((ip_table_index, "white", "red"))
|
||||
row_colors.append((ip_table_index, "bad"))
|
||||
if False in [chain["nominal"] for chain in [data_point["data"][key] for key in data_point["data"].keys()][0]]:
|
||||
row_colors.append((ip_table_index, "white", "red"))
|
||||
else:
|
||||
row_colors.append((ip_table_index, "white", "red"))
|
||||
row_colors.append((ip_table_index, "bad"))
|
||||
board_left_chips = "\n".join(split_chips(board_left, 3))
|
||||
board_center_chips = "\n".join(split_chips(board_center, 3))
|
||||
board_right_chips = "\n".join(split_chips(board_right, 3))
|
||||
@@ -173,7 +173,11 @@ async def scan_and_get_data(network):
|
||||
board_right_chips
|
||||
]
|
||||
ip_table_data[ip_table_index] = data
|
||||
window["ip_table"].update(ip_table_data, row_colors=row_colors)
|
||||
window["ip_table"].update(ip_table_data)
|
||||
table = window["ip_table"].Widget
|
||||
table.tag_configure("bad", foreground="white", background="red")
|
||||
for row in row_colors:
|
||||
table.item(row[0] + 1, tags=row[1])
|
||||
progress_bar_len += 1
|
||||
asyncio.create_task(update_prog_bar(progress_bar_len))
|
||||
await update_ui_with_data("status", "")
|
||||
@@ -189,5 +193,5 @@ async def get_formatted_data(ip: ipaddress.ip_address):
|
||||
model = await miner.get_model()
|
||||
warnings.filterwarnings('ignore')
|
||||
board_data = await miner.get_board_info()
|
||||
data = {"IP": str(ip), "model": model, "data": board_data}
|
||||
data = {"IP": str(ip), "model": str(model), "data": board_data}
|
||||
return data
|
||||
|
||||
@@ -51,31 +51,29 @@ async def set_progress_bar_len(amount):
|
||||
async def sort_data(index: int or str):
|
||||
await update_ui_with_data("status", "Sorting Data")
|
||||
data_list = window['ip_table'].Values
|
||||
|
||||
# wattage
|
||||
if re.match("[0-9]* W", str(data_list[0][index])):
|
||||
new_list = sorted(data_list, key=lambda x: int(x[index].replace(" W", "")))
|
||||
if data_list == new_list:
|
||||
new_list = sorted(data_list, reverse=True, key=lambda x: int(x[index].replace(" W", "")))
|
||||
|
||||
# hashrate
|
||||
elif re.match("[0-9]*\.?[0-9]* TH\/s", str(data_list[0][index])):
|
||||
new_list = sorted(data_list, key=lambda x: float(x[index].replace(" TH/s", "")))
|
||||
if data_list == new_list:
|
||||
new_list = sorted(data_list, reverse=True, key=lambda x: float(x[index].replace(" TH/s", "")))
|
||||
|
||||
table = window["ip_table"].Widget
|
||||
all_data = []
|
||||
for idx, item in enumerate(data_list):
|
||||
all_data.append({"data": item, "tags": table.item(int(idx) + 1)["tags"]})
|
||||
# ip addresses
|
||||
elif re.match("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",
|
||||
str(data_list[0][index])):
|
||||
new_list = sorted(data_list, key=lambda x: ipaddress.ip_address(x[index]))
|
||||
if data_list == new_list:
|
||||
new_list = sorted(data_list, reverse=True, key=lambda x: ipaddress.ip_address(x[index]))
|
||||
if re.match("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",
|
||||
str(all_data[0]["data"][index])):
|
||||
new_list = sorted(all_data, key=lambda x: ipaddress.ip_address(x["data"][index]))
|
||||
if all_data == new_list:
|
||||
new_list = sorted(all_data, reverse=True, key=lambda x: ipaddress.ip_address(x["data"][index]))
|
||||
|
||||
# everything else, hostname, temp, and user
|
||||
# everything else, model, chips
|
||||
else:
|
||||
new_list = sorted(data_list, key=lambda x: x[index])
|
||||
if data_list == new_list:
|
||||
new_list = sorted(data_list, reverse=True, key=lambda x: x[index])
|
||||
new_list = sorted(all_data, key=lambda x: x["data"][index])
|
||||
if all_data == new_list:
|
||||
new_list = sorted(all_data, reverse=True, key=lambda x: x["data"][index])
|
||||
|
||||
new_data = []
|
||||
for item in new_list:
|
||||
new_data.append(item["data"])
|
||||
|
||||
await update_ui_with_data("ip_table", new_data)
|
||||
for idx, item in enumerate(new_list):
|
||||
table.item(idx + 1, tags=item["tags"])
|
||||
|
||||
await update_ui_with_data("ip_table", new_list)
|
||||
await update_ui_with_data("status", "")
|
||||
|
||||
Reference in New Issue
Block a user