pexpect-executor
Automate interactive CLI tools actions to create previews or tests in Python
Documentation: https://radiandevcore.gitlab.io/tools/pexpect-executor
Package: https://pypi.org/project/pexpect-executor/
Preview
CLI examples
pexpect-executor --help
pexpect-executor --down --down --down --down --down --space --enter -- gcil -H -B
pexpect-executor --press a --press a --enter -- gcil
pexpect-executor --ctrl c -- gcil
Python examples
#!/usr/bin/env python3
# Modules libraries
from pexpect_executor import Executor
# Configure
Executor.configure(host='previews', tool='pexpect-executor')
# List
Executor('ls -la', workdir='/').\
finish()
# More
Executor('ls -la | more -5', delay_press=0.5, workdir='/').\
read().\
press('s').\
read().\
press('s').\
read().\
press('b').\
read().\
press('b').\
read().\
press(' ').\
read().\
wait(1).\
press(Executor.KEY_ENTER).\
read().\
wait(1).\
press('q').\
finish()
# Prompt
Executor('').\
finish()
Usage
usage: pexpect-executor [-h] [--version] [--no-color] [--update-check] [--settings] [--set GROUP KEY VAL]
[--delay-init SECS] [--delay-press SECS] [--delay-prompt SECS] [--hold-prompt] [--host HOST]
[--tool TOOL] [--mask STRINGS] [--workdir WORKDIR] [--up] [--down] [--left] [--right]
[--enter] [--space] [--backspace] [--press KEY] [--ctrl KEY] [--read] [--wait SECS] [--finish]
[--]
[command ...]
pexpect-executor: Automate interactive CLI tools actions
internal arguments:
-h, --help # Show this help message
--version # Show the current version
--no-color # Disable colors outputs with 'NO_COLOR=1'
# (or default settings: [themes] > no_color)
--update-check # Check for newer package updates
--settings # Show the current settings path and contents
--set GROUP KEY VAL # Set settings specific 'VAL' value to [GROUP] > KEY
# or unset by using 'UNSET' as 'VAL'
configuration arguments:
--delay-init SECS # Delay the initial action execution (in s, default: 1.0)
--delay-press SECS # Delay the press actions execution (in s, default: 0.5)
--delay-prompt SECS # Delay the prompt actions execution (in s, default: 1.0)
--hold-prompt # Hold the prompt execution without a new line
--host HOST # Configure the host name (default: preview, env: EXECUTOR_HOST)
--tool TOOL # Configure the tool name (default: executor, env: EXECUTOR_TOOL)
--mask STRINGS # Mask specific strings from console outputs (credentials for example)
--workdir WORKDIR # Use a specific working directory path
actions arguments:
--up # Press the <UP> key
--down # Press the <DOWN> key
--left # Press the <LEFT> key
--right # Press the <RIGHT> key
--enter # Press the <ENTER> key
--space # Press the <SPACE> key
--backspace # Press the <BACKSPACE> key
--press KEY # Press the specified <KEY>
--ctrl KEY # Press the specified Ctrl+<KEY>
--read # Read the buffered data output (forced)
--wait SECS # Wait the specified time (in s, example: 1.0)
--finish # Finish the execution (forced)
positional arguments:
-- # Positional arguments separator (recommended)
command # Command arguments to execute (use -- to separate)
Userspace available settings
pexpect-executor creates a settings.ini configuration file in a userspace folder.
For example, it allows to disable the automated updates daily check ([updates] > enabled)
The settings.ini file location and contents can be shown with the following command:
pexpect-executor --settings
Supported systems
| Systems | Supported |
|---|---|
| Linux (shell) | ✓ |
| macOS (shell) | ? |
| Windows (shell) | ~ |
| Android (Termux) | ✓ |
Environment available configurations
pexpect-executor uses colored for colors outputs.
If colors of both outputs types do not match the terminal's theme,
an environment variable NO_COLOR=1 can be defined to disable colors.
Dependencies
- colored: Terminal colors and styles
- pexpect: Interactive console applications controller
- setuptools: Build and manage Python packages
- update-checker: Check for package updates on PyPI
- wexpect-uv: Windows alternative of pexpect (uv rebuilt fork)
References
- commitizen: Simple commit conventions for internet citizens
- git-cliff: CHANGELOG generator
- gitlab-release: Utility for publishing on GitLab
- gcil: Launch .gitlab-ci.yml jobs locally
- mkdocs: Project documentation with Markdown
- mkdocs-coverage: Coverage plugin for mkdocs documentation
- mkdocs-exporter: Exporter plugin for mkdocs documentation
- mkdocs-material: Material theme for mkdocs documentation
- mypy: Optional static typing for Python
- pre-commit: A framework for managing and maintaining pre-commit hooks
- pre-commit-crocodile: Git hooks intended for developers using pre-commit
- PyPI: The Python Package Index
- termtosvg: Record terminal sessions as SVG animations
- twine: Utility for publishing on PyPI
Metadata
Release files for pexpect-executor 4.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pexpect_executor-4.5.0.tar.gz | 95.7 kB | Without provenance | Details for pexpect_executor-4.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pexpect_executor-4.5.0-py3-none-any.whl | Python 3 | none | any | Details for pexpect_executor-4.5.0-py3-none-any.whl |
Total release size: 129.4 kB
Release files / pexpect_executor-4.5.0.tar.gz
| Download URL | pexpect_executor-4.5.0.tar.gz |
|---|---|
| Size | 95.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e9e74f797d482b7e963829e2cc521de2f4d0f418df8b0785452eb668de3dde8
|
|
BLAKE2b-256 checksum How to use checksums |
a25071d4d1f77f042781fa05f83d95934657766aaa6a7c25ecb74da9e19132f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Release files / pexpect_executor-4.5.0-py3-none-any.whl
| Download URL | pexpect_executor-4.5.0-py3-none-any.whl |
|---|---|
| Size | 33.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e155031dafbacb672c33663e3b7ba325db47233cfcb61eb4dfb6e641ab9e4bf7
|
|
BLAKE2b-256 checksum How to use checksums |
4e5370e7ee7ff814f7a971ba7f289060754febba0f938a72a06328ee571f2e87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Security for pexpect-executor 4.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.