Skip to main content

Jumpstarter shell driver, for running controlled shell commands on the exporter.

Project description

Shell driver

jumpstarter-driver-shell provides functionality for shell command execution.

Installation

:substitutions:
$ pip3 install --extra-index-url {{index_url}} jumpstarter-driver-shell

Configuration

Example configuration:

export:
  shell:
    type: jumpstarter_driver_shell.driver.Shell
    config:
      methods:
        ls: "ls"
        method2: "echo 'Hello World 2'"
        #multi line method
        method3: |
          echo 'Hello World $1'
          echo 'Hello World $2'
        env_var: "echo $1,$2,$ENV_VAR"
      # optional parameters
      cwd: "/tmp"
      log_level: "INFO"
      shell:
        - "/bin/bash"
        - "-c"

API Reference

Assuming the exporter driver is configured as in the example above, the client methods will be generated dynamically, and they will be available as follows:

.. autoclass:: jumpstarter_driver_shell.client.ShellClient
    :members:

.. function:: ls()
   :noindex:

   :returns: A tuple(stdout, stderr, return_code)

.. function:: method2()
    :noindex:

    :returns: A tuple(stdout, stderr, return_code)

.. function:: method3(arg1, arg2)
    :noindex:

    :returns: A tuple(stdout, stderr, return_code)

.. function:: env_var(arg1, arg2, ENV_VAR="value")
    :noindex:

    :returns: A tuple(stdout, stderr, return_code)

CLI Usage

The shell driver also provides a CLI when using jmp shell. All configured methods become available as CLI commands, except for methods starting with _ which are considered private and hidden from the end user:

$ jmp shell --exporter shell-exporter
$ j shell
Usage: j shell [OPTIONS] COMMAND [ARGS]...

  Shell command executor

Commands:
  env_var  Execute the env_var shell method
  ls       Execute the ls shell method
  method2  Execute the method2 shell method
  method3  Execute the method3 shell method

CLI Command Usage

Each configured method becomes a CLI command with the following options:

$ j shell ls --help
Usage: j shell ls [OPTIONS] [ARGS]...

  Execute the ls shell method

Options:
  -e, --env TEXT  Environment variables in KEY=VALUE format
  --help          Show this message and exit.

Examples

# Execute simple commands
$ j shell ls
file1.txt  file2.txt  directory/

# Pass arguments to shell methods
$ j shell method3 "first arg" "second arg"
Hello World first arg
Hello World second arg

# Set environment variables
$ j shell env_var arg1 arg2 --env ENV_VAR=myvalue
arg1,arg2,myvalue

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jumpstarter_driver_shell-0.7.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jumpstarter_driver_shell-0.7.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file jumpstarter_driver_shell-0.7.0.tar.gz.

File metadata

File hashes

Hashes for jumpstarter_driver_shell-0.7.0.tar.gz
Algorithm Hash digest
SHA256 4c2726c30079c1b88cd5681b0e9129378be0fe359315d5901ea89f160723d8bb
MD5 9d5d559d0366eade24abdc75292c4cbd
BLAKE2b-256 1c19904bf9ef607fddd1a313b8cd66c0c2901fbcfa59826bdce26bf1da689121

See more details on using hashes here.

File details

Details for the file jumpstarter_driver_shell-0.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for jumpstarter_driver_shell-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5c713b022ad7272d91e30ae967c400c1aae92e4cc4413ead06eb828c3c72fb7
MD5 94a7859426bab490652ba2a01e8dae19
BLAKE2b-256 9e6fa5671a9ba23a5c924827d83deba718c55e0a64a870f9e8861bb611cb46d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page