Skip to main content

Integration of shell and basic GNU core unilities for better coding.

Project description

niceshell - Python 3 module for better shell coding

Requirements

  • Python 3.6+ (tested on 3.6.0)

Installation

Automatic installation

python3 -m pip install niceshell

Manual installation

cd /tmp/
version=1.0.0 # Choose desired version
wget -c "https://github.com/Andrew15-5/niceshell/releases/download/v${version}/niceshell-${version}-py3-none-any.whl"
python3 -m pip -U --user install niceshell-${version}-py3-none-any.whl

Usage

from niceshell import *
ext = "py"

process1 = ls(f"*.{ext}", batch=True)
if process1.exit_code():
    print("No Python scripts here. :(")
    print("stderr:", process1.error_output(), end='')
    exit(1)

process2 = ls(f"*.{ext}", True).shell("head -n 5")
print("stdout:", process2.output(), end='')
files = process2.get_lines()

ln(files, "/tmp/").wait()

Important note

Due to different preferences among coders some things like:

  • raised error instead of silencly returned error code or None
  • type of raised error and its message;
  • behavior of edge cases (the way parameter's data is handled);
  • parameter names and their ordinal position
  • behavior of command with provided input text (with sudo)

can be inconvenient to some extent for someone and be perfect for others. Therefore, I encourage everyone to test result of each function, method, variable, constant, etc. to be 100% sure of how your script/program/app will handle every situation.

There are some tests in "tests" directory (./niceshell/tests/) to get you started. And of course you can see implementation of whatever the module provides for better understanding of what you are looking for.

Complete list of modules and their functions/classes

Note: list can be exteneded in future updates.

  • __init__
    • GID ($USER's group ID)
    • GROUP ($USER's group name)
    • HOME ($USERS's home dir aka '~')
    • UID ($USER's ID)
    • USER ($USER)
  • core
    • expose_tilde()
    • normalize_short_and_long_args()
    • quotes_wrapper()
    • shell()
    • Shell
    • ShortArgsOption
  • extra
    • force_sudo_password_promt()
    • get_root_privileges()
    • get_root_privileges_or_exit()
    • has_root_privileges()
  • gnu_coreutils
    • cd()
    • cp()
    • ln()
    • ls()
    • mv()
    • rm()

TODO list

  • Add ability to install module via pip
  • Add ability to get command's output and pipe it to another command
  • Add function that check if sudo can be used without password
  • Add ability to provide input to command in core.Shell
  • Add cd
  • Add mv
  • Add rm
  • Add cp
  • Add shell() function for chain to start from small 's'
  • Add remaining Popen methods/properties to Shell class

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

niceshell-1.0.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

niceshell-1.0.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file niceshell-1.0.0.tar.gz.

File metadata

  • Download URL: niceshell-1.0.0.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.10

File hashes

Hashes for niceshell-1.0.0.tar.gz
Algorithm Hash digest
SHA256 895381da92e51c4f803f7933dc74d340b52e93d8b6999aa23f92e9c4fac29795
MD5 e314c27eba5f9dabbcf6bfa4e2398b3a
BLAKE2b-256 c84633aa2f0be0fb7e5f30eae39fef0ec785f05aababac1cb93cb71b41af6342

See more details on using hashes here.

File details

Details for the file niceshell-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: niceshell-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.10

File hashes

Hashes for niceshell-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7df834292ff5e2b5ee2c6c34d867bb7defe98ee192df5ff1b0b77a4800e828a9
MD5 f3e9468fb5d2cc6ab52ac09dbaac02b1
BLAKE2b-256 c245d6b1e04afd19b58f07526a4d60fa6db96326c3170eae0a636da8a8176c36

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