added custom command functionality
This commit is contained in:
@@ -85,6 +85,8 @@ class BMMiner(BaseMiner):
|
||||
try:
|
||||
# run the command and get the result
|
||||
result = await conn.run(cmd)
|
||||
result = result.stdout
|
||||
|
||||
except Exception as e:
|
||||
# if the command fails, log it
|
||||
logging.warning(f"{self} command {cmd} error: {e}")
|
||||
|
||||
@@ -34,6 +34,7 @@ class BOSMiner(BaseMiner):
|
||||
try:
|
||||
# run the command and get the result
|
||||
result = await conn.run(cmd)
|
||||
result = result.stdout
|
||||
except Exception as e:
|
||||
# if the command fails, log it
|
||||
logging.warning(f"{self} command {cmd} error: {e}")
|
||||
|
||||
@@ -50,6 +50,7 @@ class CGMiner(BaseMiner):
|
||||
for i in range(3):
|
||||
try:
|
||||
result = await conn.run(cmd)
|
||||
result = result.stdout
|
||||
except Exception as e:
|
||||
print(f"{cmd} error: {e}")
|
||||
if i == 3:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user