Skip to main content

A shortcut for running shell command.

Project description

cmding

Cmder is a simple module which aims to bring enjoyable experience for running shell commands in Python.

By wrapping Python subprocess.Popen, cmder provides a convenient way for you to run any shell command through Python and offers some additional features.

Installation

pip install cmder

Features

  • Running any command using either a string or a list.
  • Running any command like you run them from the shell. The pipe and redirection operations are native permitted due to the pre-filled argument shell=True.
  • Automatically reformat the command. Break long command string into multiple lines and format them nicely.
  • Profile command running time and memory usage. Using /usr/bin/time to profile the time and memory usage of the running command.

Usage

Import the module and call run the same way you call subprocess.run with two additional keyword argument: msg and pmt. msg cam be a simple string for display a message before and after running the command. Set pmt to True or False will enable or disable time and memory profiling feature. Since cmder.run wrappers subprocess.Popen, all other keyword arguments allowed for subprocess.Popen are also allowed here.

import cmder
cmder.run('ls -lh', msg='List files with details ...', pmt=True)

Note:

  • Without a message string passed by msg, profiling time and memory will be ignored even the pmt argument was set to True.

Limitations

  1. Since the time and memory profiling depends on GNU version /usr/bin/time, it does not work on BSD system.
  2. Since the argument shell=True was pre-filled when call subprocess.Popen, user should be aware of the potential security issue and use this module with caution.

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

cmder-5.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

cmder-5.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file cmder-5.0.tar.gz.

File metadata

  • Download URL: cmder-5.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for cmder-5.0.tar.gz
Algorithm Hash digest
SHA256 e7787993e5340ff3bef5d60d68ba60981ebe001c458d1654c23b27851fc53a60
MD5 bb5e4cca6834d86228fd0d8e9b017189
BLAKE2b-256 150fa9eae1b1175e45668630d3e2938858a6f99fba7ddede30f73fd82111a107

See more details on using hashes here.

File details

Details for the file cmder-5.0-py3-none-any.whl.

File metadata

  • Download URL: cmder-5.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for cmder-5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f0ec07bc2d4ea29bbbdbcd6e30fd655de08d8f717d60971b86b0d657dd74303d
MD5 eabfa920b252a31f1fd91d1254fe828f
BLAKE2b-256 17c8eb65662fc83a0590f9071f49c93001a35e1f1cbbaef2a919716bd32ace51

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