Skip to main content

A library of small functions that simplify scripting in python

Project description

pysh

A library of small functions that simplify scripting in python

Installation

pip install pysh

Usage

sh

Run a shell command and display the output:

sh("git status")

Capture the output of a shell command:

res = sh("git status", capture=True)
print(res.stdout)

cd

Change the current working directory:

cd("path/to/dir")

Change the current working directory temporarily:

with cd("path/to/dir"):
    sh("git status")

env

Set an environment variable:

env(var="value")

Set an environment variable temporarily:

with env(PGPASSWORD="MyPassword", PGUSER="postgres"):
    sh("createdb -h localhost -p 5432 -O postgres mydb")

which

Checks whether an executable/script/builtin is available:

git_is_installed = which("git")

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

pysh-3.3.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

pysh-3.3.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file pysh-3.3.1.tar.gz.

File metadata

  • Download URL: pysh-3.3.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.11.3 Linux/6.0.19-4-MANJARO

File hashes

Hashes for pysh-3.3.1.tar.gz
Algorithm Hash digest
SHA256 e13f4ee9b5b16df1666434053903caba40aaad7f4ec50b00442ec1523aab9d70
MD5 3149334bf0492276166841d38d4ce0fa
BLAKE2b-256 b18321df6f4f0ace0b88473325b5d0f965dabfdd13d61ca57af43f665b47bd91

See more details on using hashes here.

File details

Details for the file pysh-3.3.1-py3-none-any.whl.

File metadata

  • Download URL: pysh-3.3.1-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.11.3 Linux/6.0.19-4-MANJARO

File hashes

Hashes for pysh-3.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7350f825c0b8bbeb26d6dcced515718a3c34e2f6daea750d4714b9f7688f548a
MD5 68e668b33e034f43640b832826a1e5a6
BLAKE2b-256 bb737d5dd3505f0d24a689a5226a13ae05f394023dc05d3b108590bc9bf5bfcc

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