disabled the buttons that can break each other when another coroutine is running
This commit is contained in:
@@ -364,9 +364,12 @@ class CGMinerAPI(BaseMinerAPI):
|
|||||||
:return: Confirmation of setting PGA n with opt[,val].
|
:return: Confirmation of setting PGA n with opt[,val].
|
||||||
"""
|
"""
|
||||||
if val:
|
if val:
|
||||||
return await self.send_command("pgaset", parameters=f"{n}, {opt}, {val}")
|
return await self.send_command("pgaset", parameters=f"{n}, "
|
||||||
|
f"{opt}, "
|
||||||
|
f"{val}")
|
||||||
else:
|
else:
|
||||||
return await self.send_command("pgaset", parameters=f"{n}, {opt}")
|
return await self.send_command("pgaset", parameters=f"{n}, "
|
||||||
|
f"{opt}")
|
||||||
|
|
||||||
async def zero(self, which: str, summary: bool) -> dict:
|
async def zero(self, which: str, summary: bool) -> dict:
|
||||||
"""Zero a device.
|
"""Zero a device.
|
||||||
@@ -381,7 +384,8 @@ class CGMinerAPI(BaseMinerAPI):
|
|||||||
:return: the STATUS section with info on the zero and optional
|
:return: the STATUS section with info on the zero and optional
|
||||||
summary.
|
summary.
|
||||||
"""
|
"""
|
||||||
return await self.send_command("zero", parameters=f"{which}, {summary}")
|
return await self.send_command("zero", parameters=f"{which}, "
|
||||||
|
f"{summary}")
|
||||||
|
|
||||||
async def hotplug(self, n: int) -> dict:
|
async def hotplug(self, n: int) -> dict:
|
||||||
"""Enable hotplug.
|
"""Enable hotplug.
|
||||||
@@ -482,9 +486,12 @@ class CGMinerAPI(BaseMinerAPI):
|
|||||||
:return: Confirmation of setting option opt to value val.
|
:return: Confirmation of setting option opt to value val.
|
||||||
"""
|
"""
|
||||||
if val:
|
if val:
|
||||||
return await self.send_command("ascset", parameters=f"{n}, {opt}, {val}")
|
return await self.send_command("ascset", parameters=f"{n}, "
|
||||||
|
f"{opt}, "
|
||||||
|
f"{val}")
|
||||||
else:
|
else:
|
||||||
return await self.send_command("ascset", parameters=f"{n}, {opt}")
|
return await self.send_command("ascset", parameters=f"{n}, "
|
||||||
|
f"{opt}")
|
||||||
|
|
||||||
async def lcd(self) -> dict:
|
async def lcd(self) -> dict:
|
||||||
"""Get a general all-in-one status summary of the miner.
|
"""Get a general all-in-one status summary of the miner.
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from tools.cfg_util.cfg_util_sg.func.ui import update_ui_with_data, update_prog_
|
|||||||
from tools.cfg_util.cfg_util_sg.layout import window
|
from tools.cfg_util.cfg_util_sg.layout import window
|
||||||
from tools.cfg_util.cfg_util_sg.miner_factory import miner_factory
|
from tools.cfg_util.cfg_util_sg.miner_factory import miner_factory
|
||||||
from config.bos import bos_config_convert
|
from config.bos import bos_config_convert
|
||||||
|
from tools.cfg_util.cfg_util_sg.func.ui import enable_buttons, disable_buttons
|
||||||
from settings import CFG_UTIL_CONFIG_THREADS as CONFIG_THREADS, CFG_UTIL_REBOOT_THREADS as REBOOT_THREADS
|
from settings import CFG_UTIL_CONFIG_THREADS as CONFIG_THREADS, CFG_UTIL_REBOOT_THREADS as REBOOT_THREADS
|
||||||
|
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ async def import_config(idx):
|
|||||||
|
|
||||||
|
|
||||||
async def scan_network(network):
|
async def scan_network(network):
|
||||||
|
disable_buttons()
|
||||||
await update_ui_with_data("status", "Scanning")
|
await update_ui_with_data("status", "Scanning")
|
||||||
await update_ui_with_data("ip_count", "")
|
await update_ui_with_data("ip_count", "")
|
||||||
await update_ui_with_data("hr_total", "")
|
await update_ui_with_data("hr_total", "")
|
||||||
@@ -53,10 +55,13 @@ async def scan_network(network):
|
|||||||
asyncio.create_task(update_prog_bar(progress_bar_len))
|
asyncio.create_task(update_prog_bar(progress_bar_len))
|
||||||
await update_ui_with_data("ip_count", str(len(all_miners)))
|
await update_ui_with_data("ip_count", str(len(all_miners)))
|
||||||
await update_ui_with_data("status", "")
|
await update_ui_with_data("status", "")
|
||||||
|
enable_buttons()
|
||||||
|
|
||||||
|
|
||||||
async def miner_light(ips: list):
|
async def miner_light(ips: list):
|
||||||
|
disable_buttons()
|
||||||
await asyncio.gather(*[flip_light(ip) for ip in ips])
|
await asyncio.gather(*[flip_light(ip) for ip in ips])
|
||||||
|
enable_buttons
|
||||||
|
|
||||||
|
|
||||||
async def flip_light(ip):
|
async def flip_light(ip):
|
||||||
@@ -91,6 +96,7 @@ async def reboot_generator(miners: list):
|
|||||||
|
|
||||||
|
|
||||||
async def reboot_miners(ips: list):
|
async def reboot_miners(ips: list):
|
||||||
|
disable_buttons()
|
||||||
await update_ui_with_data("status", "Rebooting")
|
await update_ui_with_data("status", "Rebooting")
|
||||||
await set_progress_bar_len(2 * len(ips))
|
await set_progress_bar_len(2 * len(ips))
|
||||||
progress_bar_len = 0
|
progress_bar_len = 0
|
||||||
@@ -106,6 +112,7 @@ async def reboot_miners(ips: list):
|
|||||||
progress_bar_len += 1
|
progress_bar_len += 1
|
||||||
asyncio.create_task(update_prog_bar(progress_bar_len))
|
asyncio.create_task(update_prog_bar(progress_bar_len))
|
||||||
await update_ui_with_data("status", "")
|
await update_ui_with_data("status", "")
|
||||||
|
enable_buttons()
|
||||||
|
|
||||||
|
|
||||||
async def restart_backend_generator(miners: list):
|
async def restart_backend_generator(miners: list):
|
||||||
@@ -124,6 +131,7 @@ async def restart_backend_generator(miners: list):
|
|||||||
|
|
||||||
|
|
||||||
async def restart_miners_backend(ips: list):
|
async def restart_miners_backend(ips: list):
|
||||||
|
disable_buttons()
|
||||||
await update_ui_with_data("status", "Restarting Backends")
|
await update_ui_with_data("status", "Restarting Backends")
|
||||||
await set_progress_bar_len(2 * len(ips))
|
await set_progress_bar_len(2 * len(ips))
|
||||||
progress_bar_len = 0
|
progress_bar_len = 0
|
||||||
@@ -139,6 +147,7 @@ async def restart_miners_backend(ips: list):
|
|||||||
progress_bar_len += 1
|
progress_bar_len += 1
|
||||||
asyncio.create_task(update_prog_bar(progress_bar_len))
|
asyncio.create_task(update_prog_bar(progress_bar_len))
|
||||||
await update_ui_with_data("status", "")
|
await update_ui_with_data("status", "")
|
||||||
|
enable_buttons()
|
||||||
|
|
||||||
|
|
||||||
async def send_config_generator(miners: list, config):
|
async def send_config_generator(miners: list, config):
|
||||||
@@ -157,6 +166,7 @@ async def send_config_generator(miners: list, config):
|
|||||||
|
|
||||||
|
|
||||||
async def send_config(ips: list, config):
|
async def send_config(ips: list, config):
|
||||||
|
disable_buttons()
|
||||||
await update_ui_with_data("status", "Configuring")
|
await update_ui_with_data("status", "Configuring")
|
||||||
await set_progress_bar_len(2 * len(ips))
|
await set_progress_bar_len(2 * len(ips))
|
||||||
progress_bar_len = 0
|
progress_bar_len = 0
|
||||||
@@ -175,9 +185,11 @@ async def send_config(ips: list, config):
|
|||||||
await update_ui_with_data("status", "Getting Data")
|
await update_ui_with_data("status", "Getting Data")
|
||||||
await asyncio.sleep(3)
|
await asyncio.sleep(3)
|
||||||
await refresh_data(ips)
|
await refresh_data(ips)
|
||||||
|
enable_buttons()
|
||||||
|
|
||||||
|
|
||||||
async def refresh_data(ip_list: list):
|
async def refresh_data(ip_list: list):
|
||||||
|
disable_buttons()
|
||||||
await update_ui_with_data("status", "Getting Data")
|
await update_ui_with_data("status", "Getting Data")
|
||||||
await update_ui_with_data("hr_total", "")
|
await update_ui_with_data("hr_total", "")
|
||||||
ips = [ipaddress.ip_address(ip) for ip in ip_list]
|
ips = [ipaddress.ip_address(ip) for ip in ip_list]
|
||||||
@@ -225,9 +237,11 @@ async def refresh_data(ip_list: list):
|
|||||||
window["hr_total"].update(f"{total_hr} TH/s")
|
window["hr_total"].update(f"{total_hr} TH/s")
|
||||||
|
|
||||||
await update_ui_with_data("status", "")
|
await update_ui_with_data("status", "")
|
||||||
|
enable_buttons()
|
||||||
|
|
||||||
|
|
||||||
async def scan_and_get_data(network):
|
async def scan_and_get_data(network):
|
||||||
|
disable_buttons()
|
||||||
await update_ui_with_data("status", "Scanning")
|
await update_ui_with_data("status", "Scanning")
|
||||||
await update_ui_with_data("hr_total", "")
|
await update_ui_with_data("hr_total", "")
|
||||||
await update_ui_with_data("ip_count", "")
|
await update_ui_with_data("ip_count", "")
|
||||||
@@ -279,6 +293,7 @@ async def scan_and_get_data(network):
|
|||||||
total_hr = round(sum(hashrate_list), 2)
|
total_hr = round(sum(hashrate_list), 2)
|
||||||
await update_ui_with_data("hr_total", f"{total_hr} TH/s")
|
await update_ui_with_data("hr_total", f"{total_hr} TH/s")
|
||||||
await update_ui_with_data("status", "")
|
await update_ui_with_data("status", "")
|
||||||
|
enable_buttons()
|
||||||
|
|
||||||
|
|
||||||
async def get_formatted_data(ip: ipaddress.ip_address):
|
async def get_formatted_data(ip: ipaddress.ip_address):
|
||||||
|
|||||||
@@ -6,6 +6,48 @@ from tools.cfg_util.cfg_util_sg.layout import window
|
|||||||
import pyperclip
|
import pyperclip
|
||||||
|
|
||||||
|
|
||||||
|
def disable_buttons():
|
||||||
|
button_list = ["scan",
|
||||||
|
"import_file_config",
|
||||||
|
"export_file_config",
|
||||||
|
"import_iplist",
|
||||||
|
"export_iplist",
|
||||||
|
"export_csv",
|
||||||
|
"select_all_ips",
|
||||||
|
"refresh_data",
|
||||||
|
"open_in_web",
|
||||||
|
"reboot_miners",
|
||||||
|
"restart_miner_backend",
|
||||||
|
"import_config",
|
||||||
|
"send_config",
|
||||||
|
"light",
|
||||||
|
"generate_config",
|
||||||
|
]
|
||||||
|
for button in button_list:
|
||||||
|
window[button].Update(disabled=True)
|
||||||
|
|
||||||
|
|
||||||
|
def enable_buttons():
|
||||||
|
button_list = ["scan",
|
||||||
|
"import_file_config",
|
||||||
|
"export_file_config",
|
||||||
|
"import_iplist",
|
||||||
|
"export_iplist",
|
||||||
|
"export_csv",
|
||||||
|
"select_all_ips",
|
||||||
|
"refresh_data",
|
||||||
|
"open_in_web",
|
||||||
|
"reboot_miners",
|
||||||
|
"restart_miner_backend",
|
||||||
|
"import_config",
|
||||||
|
"send_config",
|
||||||
|
"light",
|
||||||
|
"generate_config",
|
||||||
|
]
|
||||||
|
for button in button_list:
|
||||||
|
window[button].Update(disabled=False)
|
||||||
|
|
||||||
|
|
||||||
def copy_from_table(table):
|
def copy_from_table(table):
|
||||||
selection = table.selection()
|
selection = table.selection()
|
||||||
copy_values = []
|
copy_values = []
|
||||||
@@ -40,6 +82,9 @@ async def set_progress_bar_len(amount):
|
|||||||
|
|
||||||
|
|
||||||
async def sort_data(index: int or str):
|
async def sort_data(index: int or str):
|
||||||
|
if window["scan"].disabled:
|
||||||
|
print("disabled")
|
||||||
|
return
|
||||||
await update_ui_with_data("status", "Sorting Data")
|
await update_ui_with_data("status", "Sorting Data")
|
||||||
data_list = window['ip_table'].Values
|
data_list = window['ip_table'].Values
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,13 @@ layout = [
|
|||||||
|
|
||||||
[sg.Table(
|
[sg.Table(
|
||||||
values=[],
|
values=[],
|
||||||
headings=["IP", "Model", "Hostname", "Hashrate", "Temperature", "Current User", "Wattage"],
|
headings=["IP",
|
||||||
|
"Model",
|
||||||
|
"Hostname",
|
||||||
|
"Hashrate",
|
||||||
|
"Temperature",
|
||||||
|
"Current User",
|
||||||
|
"Wattage"],
|
||||||
auto_size_columns=False,
|
auto_size_columns=False,
|
||||||
max_col_width=15,
|
max_col_width=15,
|
||||||
justification="center",
|
justification="center",
|
||||||
|
|||||||
@@ -46,11 +46,14 @@ async def ui():
|
|||||||
if 2 > len(value['ip_table']) > 0:
|
if 2 > len(value['ip_table']) > 0:
|
||||||
asyncio.create_task(import_config(value['ip_table']))
|
asyncio.create_task(import_config(value['ip_table']))
|
||||||
if event == "restart_miner_backend":
|
if event == "restart_miner_backend":
|
||||||
asyncio.create_task(restart_miners_backend([window['ip_table'].Values[item][0] for item in value['ip_table']]))
|
if len(window["ip_table"].Values) > 0:
|
||||||
|
asyncio.create_task(restart_miners_backend([window['ip_table'].Values[item][0] for item in value['ip_table']]))
|
||||||
if event == "reboot_miners":
|
if event == "reboot_miners":
|
||||||
asyncio.create_task(reboot_miners([window['ip_table'].Values[item][0] for item in value['ip_table']]))
|
if len(window["ip_table"].Values) > 0:
|
||||||
|
asyncio.create_task(reboot_miners([window['ip_table'].Values[item][0] for item in value['ip_table']]))
|
||||||
if event == 'light':
|
if event == 'light':
|
||||||
asyncio.create_task(miner_light([window['ip_table'].Values[item][0] for item in value['ip_table']]))
|
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":
|
||||||
@@ -58,13 +61,15 @@ async def ui():
|
|||||||
if event == "export_csv":
|
if event == "export_csv":
|
||||||
asyncio.create_task(export_csv(value["file_iplist"], [window['ip_table'].Values[item] for item in value['ip_table']]))
|
asyncio.create_task(export_csv(value["file_iplist"], [window['ip_table'].Values[item] for item in value['ip_table']]))
|
||||||
if event == "send_config":
|
if event == "send_config":
|
||||||
asyncio.create_task(send_config([window['ip_table'].Values[item][0] for item in value['ip_table']], value['config']))
|
if len(window["ip_table"].Values) > 0:
|
||||||
|
asyncio.create_task(send_config([window['ip_table'].Values[item][0] for item in value['ip_table']], value['config']))
|
||||||
if event == "import_file_config":
|
if event == "import_file_config":
|
||||||
asyncio.create_task(import_config_file(value['file_config']))
|
asyncio.create_task(import_config_file(value['file_config']))
|
||||||
if event == "export_file_config":
|
if event == "export_file_config":
|
||||||
asyncio.create_task(export_config_file(value['file_config'], value["config"]))
|
asyncio.create_task(export_config_file(value['file_config'], value["config"]))
|
||||||
if event == "refresh_data":
|
if event == "refresh_data":
|
||||||
asyncio.create_task(refresh_data([window["ip_table"].Values[item][0] for item in value["ip_table"]]))
|
if len(window["ip_table"].Values) > 0:
|
||||||
|
asyncio.create_task(refresh_data([window["ip_table"].Values[item][0] for item in value["ip_table"]]))
|
||||||
if event == "generate_config":
|
if event == "generate_config":
|
||||||
await generate_config_ui()
|
await generate_config_ui()
|
||||||
if event == "__TIMEOUT__":
|
if event == "__TIMEOUT__":
|
||||||
|
|||||||
Reference in New Issue
Block a user