Skip to main content

Multiplexed Exec Tool

Project description

muXec

PyPI version

A command line tool for running multiple commands simultaneously while observing their output

        ________________________________________
       /                 /                     /
      /   _ __ ___  _   /__  _____  ___       /
     /---| '_ ` _ \| | | \ \/ / _ \/ __|-----/
    /    | | | | | | |_| |>  <  __/ (__     /
   /     |_| |_| |_|\__,_/_/\_\___|\___|   /
  /                /                      /
 /________________/______________________/

          muXec - Multiplexed Exec

To date, the tool has only been tested on MacOS and xterm with python3.9, and may behave differently in untested setups.

Install

pip install --upgrade muxec

Visit on PyPi

Usage

positional arguments:
  commands              commands to run. if using args, escape entire command with quotes

optional arguments:
  -h, --help            show this help message and exit
  -p PARALLELISM, --parallelism PARALLELISM
                        number of commands to run in parallel (default: 4)
  -x, --xargs           pipe in standard input as input to the command
  -I REPLACE_STR, --replace-str REPLACE_STR
                        when using xargs mode, replace occurrences of replace-str in the command with input, default: {}
  --break-on-fail       immediately break whole execution if any command fails
  -m MODE, --mode MODE  output print mode, either 'plain' or 'tty' (or 'auto' to pick the right one automatically)

To use from python script:

from muxec.run import run
from muxec.consts import MODE_PLAIN

run(parallelism=4, commands=["cmd", "other"], break_on_fail=True, print_mode=MODE_PLAIN)

Examples

muxec -p 2 'ls -la' 'for i in 1 2 3 4 5 ; do date; sleep 1; done'

gif1

muxec -p 6 'ls -la' 'for i in 1 2 3 4 5 ; do date; sleep 1; done' 'echo echo' 'sleep 3 ; echo exiting ; exit 1' 'python --version' 'df -h'

gif2

cat images.txt | muxec --xargs -p 4 --break-on-fail 'docker pull'

gif3

Open Issues

  • Terminal resize is not handled

  • There is still no full support for all control sequences or for colors (see spellr/culour)

Development

To enable logging: export LOG_HINT_ENVVAR=1. Logs will be written to /tmp/muxec.log (file is overwritten on each run).

PyCharm IDE does not provide the required terminal to run pty, but you can run the program from regular terminal and attach debugger.

Set up Python Debug Server configuration in PyCharm:

debug

Then set export DEBUG_HINT_ENVVAR=1 and run the script: python main.py ...

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

muxec-0.1.9-py3.9.egg (22.1 kB view details)

Uploaded Source

muxec-0.1.9-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file muxec-0.1.9-py3.9.egg.

File metadata

  • Download URL: muxec-0.1.9-py3.9.egg
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for muxec-0.1.9-py3.9.egg
Algorithm Hash digest
SHA256 10e94a7d8f4f270d970cde20fa7c5eaf71148d6610a512082f844a7380248d61
MD5 ae3c10f601d55fa4bcd28b6629c9d25f
BLAKE2b-256 bbd43a836ca3d413251cd71e3f326a1609a5b7a04600bfb4a832df0c86fb60c7

See more details on using hashes here.

File details

Details for the file muxec-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: muxec-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for muxec-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 15e6b9b3eb044deb92c1748b7aeeff2249616bebd1f177eb5154161788e59c4d
MD5 6e4618b603434112ec2282e80805da28
BLAKE2b-256 c74dd24d60cea64d385212b4085a83c57427814da769fc252bf4ebf7e5ebe923

See more details on using hashes here.

Supported by

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