Skip to main content

SuperProcessor: the perfect wrapper for subprocess.run

Project description

SuperProcessor

the perfect wrapper for subprocess.run

Goal

Write Shell commands in Python with ease. Simplify Scripting for All.

Description

This module is meant to ease use of subprocess.run, minimizing and reducing all possible edge cases that are prone to come with use of traditional run().

Dependencies

None! This module relies on zero external dependencies, making use of only the builtin module subprocess.

Installation

Install either over Pypi with

pip3 install superprocessor

or over git-pip

pip3 install git+https://github.com/samocorp/superprocessor.git

Usage

This module is famous for the cmd function, which has a signature of

cmd(* args: str, ** kwargs) -> Tuple(stdout: str, stderr: Union[str, None])

As you can see, this function implements a Golang-style error handling, of returing both the std output and error of the command in the shell.

If no error is encountered, the second value of the returned tuple is of NoneType.

Importing and using the function is easy.

from superprocessor import cmd

cmd('mkdir -p ', NEW_DIR_P, \
'&& cd', NEW_DIR_P, \
'&& npm install')

See /examples for more use cases.

Since a tuple is returned, you have to unpack it for every call.

# WRONG
OUT = cmd(...)


# RIGHT
OUT, ERR = cmd(...)

Although unrecommended, you might end up un-naming it

 out, _ = cmd(...)

Configurations

Create wickedly easy configuration overrides for example:

# logging insightful clues to stdout
# default: False
cmd(..., log=True)
# or environment SUPER_LOGS=TRUE     

Happy Scripting :-)

Support

Please reach out to us for anything at

thesamocorp@gmail.com

Create issues, fork and request merge requests, and don't be a stranger.

License

This project is governed by the MIT License.

Copyright SamoCorp 2021.

All Rights Reserved.

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

superprocessor-0.1.2.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

superprocessor-0.1.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file superprocessor-0.1.2.tar.gz.

File metadata

  • Download URL: superprocessor-0.1.2.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.2

File hashes

Hashes for superprocessor-0.1.2.tar.gz
Algorithm Hash digest
SHA256 dfa7c987bb3dcbff55352008881dee976709c8eb00df74e73450d5b1ed66b5f1
MD5 58f154e7acc1af7fa6fca9a3fbaf6e90
BLAKE2b-256 52d6b0ea988a6a74d669b537ba76ef6bc9ccd57ac5fe706ec5c0b1abc7e9ab17

See more details on using hashes here.

File details

Details for the file superprocessor-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: superprocessor-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.2

File hashes

Hashes for superprocessor-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d259ddade397497ef8631ea0ef3dbe33c80a821cbfec688870d5161165d900de
MD5 6773a818da186ffeb2522dc97ced8ae6
BLAKE2b-256 60a938b8307203701d4c3c0599c4c17afc4921c44f9bb18ae08cd3e9e7306a62

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