blocking and non-blocking shell cmd exec

This commit is contained in:
Robin Müller 2023-04-14 00:21:01 +02:00
parent 8993ccdf66
commit 005e15b21b
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC

View File

@ -40,6 +40,7 @@ class ActionId(enum.IntEnum):
XSC_REBOOT = 32 XSC_REBOOT = 32
FULL_REBOOT = 34 FULL_REBOOT = 34
EXECUTE_SHELL_CMD_BLOCKING = 40 EXECUTE_SHELL_CMD_BLOCKING = 40
EXECUTE_SHELL_CMD_NON_BLOCKING = 41
SYSTEMCTL_CMD_EXECUTOR = 42 SYSTEMCTL_CMD_EXECUTOR = 42
@ -55,7 +56,8 @@ class OpCode:
ANNOUNCE_VERSION = "announce_version" ANNOUNCE_VERSION = "announce_version"
ANNOUNCE_CURRENT_IMAGE = "announce_current_image" ANNOUNCE_CURRENT_IMAGE = "announce_current_image"
ANNOUNCE_BOOT_COUNTS = "announce_boot_counts" ANNOUNCE_BOOT_COUNTS = "announce_boot_counts"
EXECUTE_SHELL_CMD_BLOCKING = "exec_shell_cmd_blocking" EXECUTE_SHELL_CMD_BLOCKING = "exec_cmd_blocking"
EXECUTE_SHELL_CMD_NON_BLOCKING = "exec_cmd_non_blocking"
SYSTEMCTL_CMD_EXECUTOR = "systemctl_cmd" SYSTEMCTL_CMD_EXECUTOR = "systemctl_cmd"
SET_PREF_SD = "set_pref_sd" SET_PREF_SD = "set_pref_sd"
REBOOT_XSC = ["reboot_xsc"] REBOOT_XSC = ["reboot_xsc"]
@ -87,7 +89,8 @@ class Info:
ANNOUNCE_CURRENT_IMAGE = "Announce current image" ANNOUNCE_CURRENT_IMAGE = "Announce current image"
ANNOUNCE_BOOT_COUNTS = "Announce boot counts" ANNOUNCE_BOOT_COUNTS = "Announce boot counts"
SYSTEMCTL_CMD_EXECUTOR = "Perform systemctl command" SYSTEMCTL_CMD_EXECUTOR = "Perform systemctl command"
EXECUTE_SHELL_CMD_BLOCKING = "Execute shell command (blocking)" EXECUTE_SHELL_CMD_BLOCKING = "Execute shell command blocking"
EXECUTE_SHELL_CMD_NON_BLOCKING = "Execute shell command non-blocking"
SET_PREF_SD = "Set preferred SD card" SET_PREF_SD = "Set preferred SD card"
REBOOT_XSC = "XSC reboot with prompt" REBOOT_XSC = "XSC reboot with prompt"
REBOOT_FULL = "Full regular reboot" REBOOT_FULL = "Full regular reboot"
@ -222,13 +225,20 @@ def pack_core_commands(q: DefaultPusQueueHelper, op_code: str):
action_id=ActionId.SYSTEMCTL_CMD_EXECUTOR, action_id=ActionId.SYSTEMCTL_CMD_EXECUTOR,
user_data=cmd_data user_data=cmd_data
)) ))
elif op_code in OpCode.EXECUTE_SHELL_CMD_BLOCKING: elif op_code == OpCode.EXECUTE_SHELL_CMD_BLOCKING:
custom_cmd = input("Please specify command to execute: ") custom_cmd = input("Please specify command to execute: ")
q.add_pus_tc(create_action_cmd( q.add_pus_tc(create_action_cmd(
object_id=CORE_CONTROLLER_ID, object_id=CORE_CONTROLLER_ID,
action_id=ActionId.EXECUTE_SHELL_CMD_BLOCKING, action_id=ActionId.EXECUTE_SHELL_CMD_BLOCKING,
user_data=custom_cmd.encode() user_data=custom_cmd.encode()
)) ))
elif op_code == OpCode.EXECUTE_SHELL_CMD_NON_BLOCKING:
custom_cmd = input("Please specify command to execute: ")
q.add_pus_tc(create_action_cmd(
object_id=CORE_CONTROLLER_ID,
action_id=ActionId.EXECUTE_SHELL_CMD_NON_BLOCKING,
user_data=custom_cmd.encode()
))
elif op_code in OpCode.XSC_REBOOT_0_0: elif op_code in OpCode.XSC_REBOOT_0_0:
add_xsc_reboot_cmd( add_xsc_reboot_cmd(
q=q, reboot_self=False, chip=Chip.CHIP_0, copy=Copy.COPY_0_NOM q=q, reboot_self=False, chip=Chip.CHIP_0, copy=Copy.COPY_0_NOM