added custom command functionality

This commit is contained in:
UpstreamData
2022-05-06 16:01:50 -06:00
parent 267c388a95
commit c01908ff9a
5 changed files with 30 additions and 1 deletions

View File

@@ -3,7 +3,12 @@ import asyncio
import sys
from tools.cfg_util.cfg_util_qt.imgs import FAULT_LIGHT, TkImages
from tools.cfg_util.cfg_util_qt.scan import btn_scan
from tools.cfg_util.cfg_util_qt.commands import btn_light, btn_reboot, btn_backend
from tools.cfg_util.cfg_util_qt.commands import (
btn_light,
btn_reboot,
btn_backend,
btn_command,
)
from tools.cfg_util.cfg_util_qt.configure import (
generate_config_ui,
btn_import,
@@ -106,6 +111,10 @@ async def main():
_table = "cmd_table"
_ips = value[_table]
asyncio.create_task(btn_backend(_ips))
if event == "btn_cmd":
_table = "cmd_table"
_ips = value[_table]
asyncio.create_task(btn_command(_ips, value["cmd_txt"]))
if event == "__TIMEOUT__":
await asyncio.sleep(0)

View File

@@ -60,3 +60,19 @@ async def btn_backend(ip_idxs: list):
else:
table_manager.data[ip]["Command Output"] = "Restart Backend command failed."
table_manager.update_tables()
@disable_buttons
async def btn_command(ip_idxs: list, command: str):
table_manager = TableManager()
_table = window["cmd_table"].Widget
iids = _table.get_children()
for idx in ip_idxs:
item = _table.item(iids[idx])
ip = item["values"][0]
miner = await MinerFactory().get_miner(ip)
success = await miner.send_ssh_command(command)
if not isinstance(success, str):
success = f"Command {command} failed."
table_manager.data[ip]["Command Output"] = success
table_manager.update_tables()