GithubHelp home page GithubHelp logo

isabella232 / subprocess-tee Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pycontribs/subprocess-tee

0.0 0.0 0.0 62 KB

A subprocess.run drop-in replacement that supports a tee mode, being able to display output in real time while still capturing it. No dependencies needed

License: MIT License

Python 95.99% Dockerfile 4.01%

subprocess-tee's Introduction

subprocess-tee

This package provides a drop-in alternative to subprocess.run that captures the output while still printing it in real-time, just the way tee does.

Printing output in real-time while still capturing is valuable for any tool that executes long-running child processes. For those, you do want to provide instant feedback (progress) related to what is happening.

# from subprocess import run
from subprocess_tee import run

result = run("echo 123")
result.stdout == "123\n"

You can add tee=False to disable the tee functionality if you want, this being a much shorter alternative than adding the well known stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL.

Keep in mind that universal_newlines=True is implied as we expect text processing, this being a divergence from the original subprocess.run.

You can still use check=True in order to make it raise CompletedProcess exception when the result code is not zero.

subprocess-tee's People

Contributors

ssbarnea avatar apatard avatar chedi avatar bkbncn avatar pre-commit-ci[bot] avatar stoned avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.