Skip to main content

Object-oriented commandline

Project description

ci python3.8 pypi codecov.io mit black

Object oriented commandline

Install

pip install spall

Development

poetry install

Example Usage

from spall import Subprocess

cmd = str(...)  # any command here e.g. git

proc = Subprocess(cmd)  # instantiate executable as object

passing = ...  # insert passing command here

returncode = proc.call(passing)  # this will print to console
print(returncode)  # -> 0

proc.call(passing, capture=True)  # this will record the output
proc.stdout()  # -> [...]

# stdout is consumed
proc.stdout()  # -> []

# this will record the output twice
proc.call(passing, capture=True)
proc.call(passing, capture=True)
proc.stdout()  # -> [..., ...]
proc.stdout()  # -> []

 # this will redirect stdout to /dev/null
proc.call(passing, devnull=True)

# this will pipe stdout to file
proc.call(file="~/example.txt")

failing = ...  # insert failing command here

# will raise a ``subprocess.CalledProcessError``
returncode = proc.call(failing)
print(returncode)  # -> > 0

# this, however, will not
returncode = proc.call(failing, suppress=True)
print(returncode)  # -> > 0

# all the keyword arguments above can be set as the default for the
# instantiated object
proc = Subprocess(cmd, capture=True)

proc.call(passing)
proc.stdout()  # -> [...]

# but they will be overridden through the method
proc.call(passing, capture=False)
proc.stdout()  # -> []

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

spall-0.1.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

spall-0.1.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file spall-0.1.1.tar.gz.

File metadata

  • Download URL: spall-0.1.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.8.11+ Linux/5.15.11-200.fc35.x86_64

File hashes

Hashes for spall-0.1.1.tar.gz
Algorithm Hash digest
SHA256 72a06d24a3dc333fd66212f2b5247a5d813baaa4bacfd4fed69a324788475cf1
MD5 97373f34ea6b192e41d80b0c4be227c2
BLAKE2b-256 f049888dbd19d207b83e5cb3936f2054b292b50dae44ead9df7f332371156be2

See more details on using hashes here.

File details

Details for the file spall-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: spall-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.8.11+ Linux/5.15.11-200.fc35.x86_64

File hashes

Hashes for spall-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 997c8fa6fd3135466c8de53182c68ef32dfbf1e2cfc882f3a816057b21d51176
MD5 b7c032af34a5ff2b517258b7bfa32e42
BLAKE2b-256 3d4afae03b3fb98e026193917bdb2ccce8df0b9d71c05bcd0fcf232c312e31e8

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