Created
December 12, 2020 16:33
-
-
Save andfanilo/aa3e4a6a15124c58e88262e193e1febf to your computer and use it in GitHub Desktop.
Output subprocess in Streamlit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import streamlit as st | |
def run_command(args): | |
"""Run command, transfer stdout/stderr back into Streamlit and manage error""" | |
st.info(f"Running '{' '.join(args)}'") | |
result = subprocess.run(args, capture_output=True, text=True) | |
try: | |
result.check_returncode() | |
st.info(result.stdout) | |
except subprocess.CalledProcessError as e: | |
st.error(result.stderr) | |
raise e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment