Skip to main content
Run Python scripts inside the container on the specified DUT for test automation and data processing.

Syntax

lager python [OPTIONS] [RUNNABLE] [ARGS]...

Global Options

OptionDescription
--box TEXTLagerbox name or IP address
--helpShow help message and exit

Commands

CommandDescription
pythonRun Python script on Lager Box

Command Reference

python

Run a Python script on the Lager Box.
lager python [OPTIONS] [RUNNABLE] [ARGS]...
Arguments:
  • RUNNABLE - Python script or command to execute
  • ARGS - Additional arguments for the script
Options:
  • --box TEXT - Lagerbox name or IP
  • --image IMAGE - Docker image to use (default: lagerdata/gatewaypy3:v0.1.84)
  • --env FOO=BAR - Set environment variables for the script
  • --passenv VAR - Pass environment variables from current environment
  • --kill - Terminate a running Python script
  • --download FILE - Download named files from Lager Box after script completes
  • --allow-overwrite - Allow overwriting existing files with —download
  • --signal [SIGINT|SIGQUIT|SIGABRT|SIGKILL|SIGUSR1|SIGUSR2|SIGTERM|SIGSTOP] - Signal to use with —kill (default: SIGTERM)
  • --timeout SECONDS - Max runtime in seconds for the script
  • -d, --detach - Run in detached mode
  • -p, --port PORT - Forward ports to the Python process
  • --add-file FILE - Add files to folder before upload

Examples

# Run a Python script
lager python script.py --box my-lager-box

# Run with environment variables
lager python test.py --box my-lager-box --env API_KEY=abc123 --env DEBUG=true

# Run in detached mode
lager python long_running.py --box my-lager-box --detach

# Download files after completion
lager python data_processor.py --box my-lager-box --download results.csv

# Kill running script
lager python --box my-lager-box --kill

# Run with port forwarding
lager python web_server.py --box my-lager-box -p 8080

# Run with timeout
lager python analysis.py --box my-lager-box --timeout 300

Notes

  • Default Docker image: lagerdata/gatewaypy3:v0.1.84
  • Use --env to set environment variables for the script
  • Use --passenv for secrets/tokens from current environment
  • --download retrieves files after script completion
  • --kill terminates running scripts with specified signal
  • Port forwarding syntax: -p SRC_PORT[:DST_PORT][/PROTOCOL]
  • Detached mode runs script in background
  • Timeout prevents scripts from running indefinitely

pip Command

Run pip commands in the Python container associated with the DUT Lager Box. Useful for installing Python packages that scripts may depend on within the Lager Python environment.

Syntax

lager pip [OPTIONS] [ARGS]...

Options

OptionDescription
--gateway GATEWAY_IDID of Lager Box to which DUT is connected
--helpShow help message and exit

Examples

# Install a package
lager pip install pandas --gateway gw-1234

# List installed packages
lager pip list --gateway gw-1234

# Uninstall a package
lager pip uninstall numpy --gateway gw-1234

Notes

  • Runs pip in the Lager Python container, not on your local machine
  • Use --gateway to specify the target Lager Box
  • Useful for managing dependencies for Python scripts run via lager python
  • All pip commands and arguments are supported