Skip to main content

Configurable shell command execution in Python

Project description

shpyX - Configurable shell command execution in Python

Installation

Install with pip:

pip install shpyx

Usage

TODO

Motivation

Running shell commands in Python is often useful when the user is interested in combining shell and Python logic, or managing the outcome of shell commands in Python.

The Python standard library provides a simple way of doing so via the subprocess module:

import subprocess

cmd = "ls -l"
p = subprocess.Popen([cmd], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
cmd_stdout, cmd_stderr = p.communicate()

While this is sufficient for many cases, we might also want to:

  1. Inspect the return code
  2. Handle commands that are stuck (due to blocking I/O, for example)
  3. Handle signals by the main Python process
  4. Add formatted printing of every executed cmd and it's output
  5. etc

The goal of this project is to provide a friendly API for running shell commands, with emphasis on configurability.

You might also want to check out other packages that deal with similar problems, like bash or invoke.

Security

One must be cautious when running shell commands from Python, as the spawned shell gains the same permissions as Python process.

Check an untrusted command twice before running it!

Contributing

TODO

Linters and tests

TODO

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

shpyx-0.0.2.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

shpyx-0.0.2-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

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