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.3.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

shpyx-0.0.3-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file shpyx-0.0.3.tar.gz.

File metadata

  • Download URL: shpyx-0.0.3.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

File hashes

Hashes for shpyx-0.0.3.tar.gz
Algorithm Hash digest
SHA256 abdf0eb84a7d3aad479ab8b41e8902fa7d78290437a6cafc7cbb7eb407942851
MD5 88f11784a83a3fd2b076313840ae94bf
BLAKE2b-256 e477404386c30c12240e198cb9b0cd2da0f4dd3e9a5d7d9d034cf0b728eaa1b4

See more details on using hashes here.

File details

Details for the file shpyx-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: shpyx-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

File hashes

Hashes for shpyx-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 75b1f96d6a66a3b408ac51a78f31f4eb6b7e08578c34921f7f294ed81c1a7bf5
MD5 6ad2e801e59ec35d3b0230fed51765c9
BLAKE2b-256 9209dad4e658ecc0e1679e92cfd9ffb94b9f5265141beb90163a7f143fdc5fb2

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