shell#

Description#

Plugin to run shell commands.

Configuration#

shell:
    # No configuration required

Actions#

Module reference#

class platypush.plugins.shell.ShellPlugin(*args, **kwargs)[source]#

Bases: Plugin

Plugin to run shell commands.

__init__(*args, **kwargs)[source]#
exec(cmd: str, background: bool = False, ws: bool = False, ignore_errors: bool = False)[source]#

Run a command.

Parameters:
  • cmd – Command to execute

  • background – If set to True, execute the process in the background, otherwise wait for the process termination and return its output (default: False).

  • ignore_errors – If set, then any errors in the command execution will be ignored. Otherwise a RuntimeError will be thrown (default value: False)

  • ws

    If set to True then the output of the command will be sent asynchronously over a websocket channel (default: False). In this case, the method will return a response in the format:

    {
        "ws_path": "/ws/shell?id=<cmd_id>"
    }
    

    Where ws_path is the websocket path where the output of the command will be sent. The websocket will be closed when the command terminates.

Returns:

A response object where the output field will contain the command output as a string, and the errors field will contain whatever was sent to stderr.