Skip to content

Instantly share code, notes, and snippets.

@max-l
Created March 29, 2021 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save max-l/82368034e3cbf6b804885effe6be5839 to your computer and use it in GitHub Desktop.
Save max-l/82368034e3cbf6b804885effe6be5839 to your computer and use it in GitHub Desktop.
with subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
text=True
) as p:
p.wait()
if p.returncode != 0:
err = p.stderr.read().strip()
raise Exception(f"failed:\n{cmd}\n{err}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment