added fault light option to the board utility
This commit is contained in:
@@ -197,5 +197,5 @@ If you are sure you want to use this command please use API.send_command("{item}
|
|||||||
parsed_data = json.loads(str_data)
|
parsed_data = json.loads(str_data)
|
||||||
# handle bad json
|
# handle bad json
|
||||||
except json.decoder.JSONDecodeError as e:
|
except json.decoder.JSONDecodeError as e:
|
||||||
raise APIError(f"Decode Error: {str_data}")
|
raise APIError(f"Decode Error {e}: {str_data}")
|
||||||
return parsed_data
|
return parsed_data
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ def disable_buttons(func):
|
|||||||
"refresh_data",
|
"refresh_data",
|
||||||
"open_in_web",
|
"open_in_web",
|
||||||
"save_report_button",
|
"save_report_button",
|
||||||
|
"light",
|
||||||
]
|
]
|
||||||
|
|
||||||
# handle the inner function that the decorator is wrapping
|
# handle the inner function that the decorator is wrapping
|
||||||
|
|||||||
@@ -12,6 +12,32 @@ from miners.miner_factory import MinerFactory
|
|||||||
from tools.bad_board_util.func.decorators import disable_buttons
|
from tools.bad_board_util.func.decorators import disable_buttons
|
||||||
|
|
||||||
|
|
||||||
|
@disable_buttons
|
||||||
|
async def miner_light(ips: list):
|
||||||
|
await asyncio.gather(*[flip_light(ip) for ip in ips])
|
||||||
|
|
||||||
|
|
||||||
|
async def flip_light(ip):
|
||||||
|
ip_list = window["ip_table"].Widget
|
||||||
|
miner = await MinerFactory().get_miner(ip)
|
||||||
|
index = [item[0] for item in window["ip_table"].Values].index(ip)
|
||||||
|
index_tags = ip_list.item(index + 1)["tags"]
|
||||||
|
if "light" not in index_tags and "light+bad" not in index_tags:
|
||||||
|
tag = "light"
|
||||||
|
if "bad" in index_tags:
|
||||||
|
index_tags.remove("bad")
|
||||||
|
tag = "light+bad"
|
||||||
|
index_tags.append(tag)
|
||||||
|
ip_list.item(index + 1, tags=index_tags)
|
||||||
|
await miner.fault_light_on()
|
||||||
|
else:
|
||||||
|
if "light+bad" in index_tags:
|
||||||
|
index_tags.remove("light+bad")
|
||||||
|
index_tags.append("bad")
|
||||||
|
ip_list.item(index + 1, tags=index_tags)
|
||||||
|
await miner.fault_light_off()
|
||||||
|
|
||||||
|
|
||||||
@disable_buttons
|
@disable_buttons
|
||||||
async def scan_network(network):
|
async def scan_network(network):
|
||||||
await update_ui_with_data("status", "Scanning")
|
await update_ui_with_data("status", "Scanning")
|
||||||
@@ -266,7 +292,9 @@ async def scan_and_get_data(network):
|
|||||||
|
|
||||||
# configure "bad" tag to highlight red
|
# configure "bad" tag to highlight red
|
||||||
table = window["ip_table"].Widget
|
table = window["ip_table"].Widget
|
||||||
table.tag_configure("bad", foreground="white", background="red")
|
table.tag_configure("bad", foreground="white", background="orange")
|
||||||
|
table.tag_configure("light", foreground="white", background="red")
|
||||||
|
table.tag_configure("light+bad", foreground="white", background="red")
|
||||||
|
|
||||||
# set tags on the row if they have been set
|
# set tags on the row if they have been set
|
||||||
for row in row_colors:
|
for row in row_colors:
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ layout = [
|
|||||||
sg.Button("ALL", key="select_all_ips"),
|
sg.Button("ALL", key="select_all_ips"),
|
||||||
sg.Button("REFRESH DATA", key="refresh_data"),
|
sg.Button("REFRESH DATA", key="refresh_data"),
|
||||||
sg.Button("OPEN IN WEB", key="open_in_web"),
|
sg.Button("OPEN IN WEB", key="open_in_web"),
|
||||||
|
sg.Button("LIGHT", key="light"),
|
||||||
sg.Input(visible=False, enable_events=True, key="save_report"),
|
sg.Input(visible=False, enable_events=True, key="save_report"),
|
||||||
sg.SaveAs(
|
sg.SaveAs(
|
||||||
"SAVE REPORT",
|
"SAVE REPORT",
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import cProfile
|
|
||||||
import sys
|
import sys
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
import xlsxwriter
|
|
||||||
|
|
||||||
from tools.bad_board_util.layout import window
|
from tools.bad_board_util.layout import window
|
||||||
from tools.bad_board_util.func.miners import refresh_data, scan_and_get_data
|
from tools.bad_board_util.func.miners import (
|
||||||
|
refresh_data,
|
||||||
|
scan_and_get_data,
|
||||||
|
miner_light,
|
||||||
|
)
|
||||||
from tools.bad_board_util.func.files import import_iplist, export_iplist
|
from tools.bad_board_util.func.files import import_iplist, export_iplist
|
||||||
from tools.bad_board_util.func.pdf import save_report
|
from tools.bad_board_util.func.pdf import save_report
|
||||||
from tools.bad_board_util.func.ui import sort_data, copy_from_table, table_select_all
|
from tools.bad_board_util.func.ui import sort_data, copy_from_table, table_select_all
|
||||||
@@ -50,6 +52,17 @@ async def ui():
|
|||||||
window["ip_table"].update(
|
window["ip_table"].update(
|
||||||
select_rows=([row for row in range(len(window["ip_table"].Values))])
|
select_rows=([row for row in range(len(window["ip_table"].Values))])
|
||||||
)
|
)
|
||||||
|
if event == "light":
|
||||||
|
if len(window["ip_table"].Values) > 0:
|
||||||
|
asyncio.create_task(
|
||||||
|
miner_light(
|
||||||
|
[
|
||||||
|
window["ip_table"].Values[item][0]
|
||||||
|
for item in value["ip_table"]
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if event == "import_iplist":
|
if event == "import_iplist":
|
||||||
asyncio.create_task(import_iplist(value["file_iplist"]))
|
asyncio.create_task(import_iplist(value["file_iplist"]))
|
||||||
if event == "export_iplist":
|
if event == "export_iplist":
|
||||||
|
|||||||
Reference in New Issue
Block a user